It's actually pretty simple to do this - you can use $project to create new fields that didn't exist in the original document - you can compute new values or you can conditionally project different values, depending on what original values are. You can even calculate in a single group phase both total alarms as well as only alarms on weekdays.
Here is what you need to do in the project phase:
{"$project" : {
"vehicleId" : 1,
"telemetryDate" : 1,
"alarmsTotal" : 1,
"alarmsWeekdays" : {
"$cond" : [
{
"$or" : [
{
"$eq" : [
{
"$dayOfWeek" : "$telemetryDate"
},
1
]
},
{
"$eq" : [
{
"$dayOfWeek" : "$telemetryDate"
},
7
]
}
]
},
0,
"$alarmsTotal"
]
}
}
}
The above says: "Pass through these three fields, but also compute a new field alarmWeekdays like so: ..."
The actual expression in more "English" terms happens to be:
IF `$dayOfWeek` of telemetryDate is equal to 1
OR `$dayOfWeek` of telemetryDate is equal to 7
THEN `$project` the value 0 as `alarmsWeekdays
ELSE `$project` the value from `$alarmsTotal` as `alarmsWeekdays`