Day of the week condition for binary sensor

Hi, I’m trying to create a binary sensor that will report on or off when my wife is working from home. I need to detect that her phone is home, and that it is also Monday through Friday during work hours. I can’t seem to find any references to time/day of the week conditions in value_template parameters. Is what I am looking to do possible?

1 Like

You might find the Workday binary sensor is useful - assuming that your wife doesn’t work on holidays.

1 Like

That is useful, Thanks! Still curious though if there is a way to work the time of the day into the sensor. ie. it’s a workday, during work hours.

i have never seen time incorporated into a sensor before. It can, however, be included in any automations you create from the sensor

You mean like a time condition?

It sounds like you just want a whole bunch of AND conditions in an automation. Very easy, and without needing to use a template. Use the workday binary sensor, device tracking and a time condition all together.

1 Like

If you decide you want a template, this is what you are looking for:

{{ now().weekday() in (0,1,2,3,4) and now().hour >=8 and now().hour <= 17 }}
2 Likes

so would this work without having to create a workday binary sensor? (I can’t test anything at the moment because I’m away from home and managed to crash my Pi last night while editing yaml remotely :tired_face:)

Awesome! Thanks @treno :grinning: