Right. I’m stuck, and I’ve searched but I’m not even sure what I’m searching for!
I have the following (simplified) setup:
- I have a hotel, with nine rooms. I’ve linked into the API of my booking system which can tell me whether a room is booked or available today, and have an entity for each room returning “Booked” or “Available”.
- Each room has a heater in it connected to a Shelly, which presents an entity to homeassistant.
I want to the heating to come on from, say, 7-10 in the morning, then again from 6-10 in the evening, but only if the room is booked. Easy enough, done and sorted using a scheduling helper to trigger and the booked status as a condition using two automations - one to turn the heating on, one to turn it off according to the schedule.
But if the room becomes booked, then it must turn the heating on, but only if the schedule is active. Also relatively easy, using the booking as a trigger, and the schedule as a condition. Then I can turn it off again if the room becomes unbooked (e.g. due to a cancellation).
So far that’s four separate automations for each room for the heating, and there are nine rooms. Isn’t there an easier way to do this? It feels wrong to use the booking status to trigger an automation based on the schedule, plus if I trigger the automation based on the schedule, it won’t turn on the heater if it’s in the middle of it’s ‘on’ cycle because no event has been generated by the scheduled automation.
Additionally, and here it gets complicated - The room will be marked as available at midnight despite being occupied (because it’s available to be booked that same day). Is there some way I can store last night’s booking value within HA until 11 am (checkout time) so that it can be referenced by the scheduling automation the following morning?
I’ve sort of tied myself in knots and this feels like something which must have been done a million times before - hoping someone out there has done it already.
I’m a beginner but happy to get my hands dirty in YAML if I can just figure out what exactly I’m trying to do.