At the moment there is no schedule entity type in HomeAssistant for interfacing with a schedule that exists on-device (eg Tasmota timers).
An entity type like this for developers to use that has start/end times and eg switch state or temperature setpoint for multiple different devices would be super useful - having the schedule run by HA helpers/automations just opens up so many more points of failure for something like a thermostat or immersion heater when you only change the schedule a handful of times a year.
At the moment my solution for my Heatmiser thermostat custom component is to expose an absolute tonne (126 total) of time and number entities attached to each thermostat device for each of the Monday-Sunday Period 1-6 start, stop, setpoint/switch status, but this a) feels very hacky/clunky and b) is missing a nice UI in HA(!).
Is this pretty niche? Yes, but hopefully there will be some likeminded souls/devs who have also been missing this!
(Also I’m half hoping someone can tell me I’m missing the obvious and it does already exist somehow!)
There is a schedule entity type.
So the above link is for the schedule integration, not a schedule entity type. The difference being that the schedule integration runs on HA itself, whereas what I’m looking for is an entity class/type to interact with a schedule that runs on the smart device itself (eg the thermostat).
My issue with the schedule integration is that it’s reliant on a good, consistent connection to HA - if I reboot at just the wrong time, or if my core network switch fails, or I need to update my hypervisor etc, the schedule won’t run on the end device properly.
Apologies if that wasn’t clear in the original post - let me know if this is still confusing!
It creates schedule entity types:
You would need an integration for that. It can use the existing schedule entity type.
What needed is an addtion to the API with esphome to add a schedule to a entity that runs on the device regardless if network / ha are up. I started work on a esphome component to do the device bit last year but ran out of time. Might revisit over the holidays. But im a bit daunted by how to extend the api.
ESPHome is not part of WTH.
No but the schedule helper and api is.
ESP home is just an example. Many devices, like Shelly for instance, feature integrated schedule options. As of now, I had to build a specific automation to handle Shelly schedules.
So I’m trying to develop an integration that does it - the WTH (for me) is the fact that HomeAssistant doesn’t have the framework in place for integration developers to implement on-device schedules elegantly!
There’s no mention of this schedule entity class in the developer docs anywhere, so I suppose if it does indeed exist in HA, the question ought to be WTH doesn’t the schedule entity class exist in the developer docs?(!)
The logical place for it would be here, same as every other entity type that is available to developers: Entity | Home Assistant Developer Docs
I’ll do some reading, but as far as I’ve been able to find there’s no way to use this schedule entity type in my integration (and I’m also not 100% sure it does what I’m describing above).
At this point, it might be better suited as a feature request, as there seems to be a bit of confusion as to what exactly the original WTH was about.
If I understand you correctly you want at a minimum an attribute added to schedule entity that contains the JSON for the schedule? I would also suggest a event is required to inform HA automation that the schedule has changed. Please could you confirm or deny so I can raise PR as I need this for ESP home.
schedule:
light_schedule:
name: "Light schedule"
wednesday:
- from: "17:00:00"
to: "21:00:00"
data:
brightness: 100
color_temp: 4000
thursday:
- from: "17:00:00"
to: "23:00:00"
data:
brightness: 90
color_temp: 3500
friday:
- from: "07:00:00"
to: "10:00:00"
data:
brightness: 80
color_temp: 3000
- from: "16:00:00"
to: "23:00:00"
data:
brightness: 60
color_temp: 2500
This would then allow your device to take (service/ API) attribute and store it on the embedded device
I guess what you need here is kind of like the difference between input_number
and number
.
Input_number → has an interface to set a number in UI, created by user, and state is managed by HA
Number → has an interface to set a number in UI, created by integration, and state is managed by the integration
What currently exists as schedule
helper could probably be more accurately named input_schedule
. Then if that was renamed, we could have a schedule
entity which is similar to number
: created by an integration, provides the scheduling interface to the user, and the state would be managed by the integration.
On the ESPhome device I am implementing a few components (Scheduled Action, Scheduled Templated Output, Scheduled Action with data, Scheduled Templated Output with data) Note data refers to the optional data fields in the helper.
What I was currently thinking was to expose the list of times, days, and data as attributes. (Im not a HA dev so trying to keep it simple). This would then allow devices to get the schedule information either via REST or templated entities.
This would be stepping stone to demonstrating the value of devices enacting the schedule on the device(EG Once schedule was set, the device would just follow it without dependence of HA or network) .
Hopefully it would lead to a update of the API, but this would require coordination of both HA and ESPhome devs
Had some more thoughts on how to achieve this.
Im now thinking of a frontend card that would expose the schedule data and provide a service containing the hidden schedule & data, that can be called by third party devices not just ESPhome. Also the card would display an indicator of the actual state of the device and a select that would allow control of the remote schedule (On, Off, Auto, Boost). @karwosts as the dev who has recently worked on the schedule helper does this make sense?