Times of day sensor

I have struggled with this for a bit, hence I ended up here again :grin:

My application is rather typical I think, but I was not able to find a framework for a solution yet.

I want to be able to set a schedule for the covers to open and close based on a schedule, but also take into account the sun rise and sun set, as well as workdays and Saturday, Sunday and bank holiday.
On top of that, some rooms, e.g. children should be able to have a separate schedule, but also take into account the sun and weekends, bank holidays…

So I came up with a framework like so:

have schedule helpers for the covers, e.g. one for the main house, one for child 1 and one for child 2. To keep it simple for now :joy:

Then, at midnight every day, an automation would be triggered to calculate the open and close times for each section of covers, depending which is first, sunrise or schedule and which is last sunset or schedule. Also it would take into account if the day is a bank holiday with the integration workday - Workday - Home Assistant. The result would be put into a times of day helper sensor and those binary_sensor with attributes after and before would be then used to trigger automations to call scripts to open and close the covers.

Now it turns out, that even with spooks installed, I cannot change the before and after times of an times of day sensor, which I find surprising and of course disappointing, sigh :weary: there is no action available with binary_sensor

I found examples where people use the input_datetime helper instead, but I do not need it as an input field. Those however can be changed within a script with te action input_datetime.set_datetime

Is it common practice to use input sensors as internal variables ? If so, then I will go ahead with input_datetime helper.

one more thought why it still would be nice and convenient to use the binary_sensor helper instead of the input_datetime helper is, that the first one has of course two times and therefore the states on and off, whereas the second one has only one time, which is equivalent with the state

Yes, that is what the Input helpers are for…

In general, sensors and binary sensors are not meant to be changed by the user.

1 Like

ok then, I will use it like so.
I had the impression, that those are primarily for inputting data through the dashboard.

They can be used that way, but you don’t have to put them on the Dashboard, and even when you do there are dashboard cards that only display the value without a direct way to alter them.

1 Like

ok, I can see the point in that, but it would increase the versatility of the times of day sensor a lot if it were able to be changed within a script.

so, the input part of the name is misleading :grin:

While it has been updated a little for UI use, Times of Day is an old integration… its purpose has mostly been subsumed by the addition of schedules, calendars, and the massive expansion of the functionality of templating and template-based entities over the years.

I think your interpretation was what was originally intended, but these days the ā€œinputā€ part mostly denotes that it is user-created. Integrations can create analogous entities like number, text, and select that can be controlled/altered by the user.

1 Like

ok, I see, so I was barking up an old tree then :deciduous_tree: :dog2: :grin:

ok, that makes sense, I completely misunderstood the input part then…

There are a number of ways to get the on/off state by using template sensors or by set a Calendar event instead of using Input Datetime helpers.