WTH I can not use the schedule integration for scheduling devices?

Recently needed to make a schedule to control a thermostat, found out about the new schedule integration, nice! Schedule - Home Assistant

However to use it to control a device I need to make an automation full of templates
(see Question: How to Use the Scheduler / Helper Function in the 2022.9 Release - #5 by 123 for example)

WTH?

I should be able to use the schedule integration to simply make a device turn on and off according to the schedule

You don’t.

You can.

How?

No information here at least

That is integration documentation, not a cookbook full of examples to fit everyone’s need.

As I have done this exact change recently in a generic thermostat, here it is:

climate:
  - platform: generic_thermostat
    name: Termostato Sala
    heater: switch.tomada_sala
    target_sensor: sensor.temperature_sala
    min_temp: 18
    max_temp: 23
    min_cycle_duration:
      seconds: 5
    hot_tolerance: 0.5

automation:
  - alias: "Thermostat Sala On/Off"
    id: thermostat_sala_on_off
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id: schedule.sala_thermostat
        from:
          - 'on'
          - 'off'
        to:
          - 'on'
          - 'off'
    action:
      - choose:
          - alias: "Switch on and within working period for thermostat --> turn on thermostat"
            conditions:
              - condition: state
                entity_id: climate.termostato_sala
                state: "off"
              - condition: state
                entity_id: schedule.sala_thermostat
                state: "on"
            sequence:
              - service: climate.turn_on
                target:
                  entity_id: climate.termostato_sala
          - alias: "Switch off --> turn off thermostat + plug"
            conditions:
              - not:
                  - condition: state
                    entity_id: climate.termostato_sala
                    state: "off"
			  - condition: state
				entity_id: schedule.sala_thermostat
				state: "off"
            sequence:
              - service: homeassistant.turn_off
                target:
                  entity_id: 
                    - climate.termostato_sala
                    - switch.tomada_sala

Hope this helps.

1 Like

As I have done this exact change recently in a generic thermostat, here it is:

So, you set up a time\date in the schedule, and then an automation that’s triggered when that time\date is reached by reading the change from “off” to “on” in the schedule?

Is there a simple way of changing the time that a scheduled event is triggered form a lovelace card, but without exposing any other details?

For example, if I want to have a scheduled event that’s triggered every Monday, and I want to be able to give someone a dashboard that will let them change the specific time an automation is triggered, but not allow them to set it for another day?

So, if the lights in my delivery bay automatically turn off at 10pm, but I want to give the shift leader a manual override that will turn them off earlier at a pre-scheduled time. I want him to have each day of the week with it’s own separate override, but I don’t want someone to be able to accidentally change the day of the week so that the light turn off on a different day, which could be dangerous if the bay is in use (Unfortunately, trucks are sometimes positioned so that they block motion sensors to keep the lights on, which is a non-HA related problem).

Here’s what I would do it without unnecessary complications:

  • Start with the scheduled automation which turns off the lights at 10pm.
  • Either set up a separate automation or add another trigger (use trigger_id and choose) to the above automation which turns off the light (immediately or after a predefined delay) when a button is pressed. You can use either a hardware button or a software one in the dashboard.
  • Pressing the button will turn off the lights, so when the automation is triggered at 10pm, nothing will happen because the lights are already off. If you’re using toggle, just add a condition which checks if the lights are on.

This way, you can be sure that it will only affect the current day’s schedule, without worrying about other days.

I’ve more or less already got this set up with an RFID fob by the door so that a key holder can turn everything on or off in one go, but I’d like to know how to do it as I’ve got a few other ideas that I’d like to try out.

It seems like useful knowledge to have for the future as I’m slowly in housing my cloud systems and I use several for device scheduling.

I don’t know if you have HACS installed or not, but the Scheduler custom integration has some pretty powerful stuff, including built-in conditions, actions and its own scheduler card.

I have a feeling it will do everything you’re asking for - have a read and see if it covers your requirements. If not, we’ll go back a step and attempt this via a normal automation, or a mix of both.

Here’s what one of my (extremely basic) scheduler cards looks like, just to give you an idea of the possibilities

don’t know if you have HACS installed or not, but the Scheduler custom integration has some pretty powerful stuff, including built-in conditions, actions and its own scheduler card.

I downloaded it earlier on and have been looking into it to see if it solves my problems.

My only reservation is that it’s not part of HA by default and I’ve had some past bad experiences with open source add ons and integrations on other software that was broken by updates long after the original author stopped supporting it, or which went to a payment based model, where features were taken away after people had started using it.

XBMC\Kodi used to be really bad for that. Add ons that I’d been using for years broke and the original had moved on to other things so had taken down the source code.

This one is still actively maintained at the time of writing, and the dev is pretty much on his toes to keep up with any breaking changes. Even if it were a native integration, there’s no guarantee it won’t be deprecated due to “reasons”.

Yes, all this could change in the future, but custom integrations have their pros and cons.
On the one hand, the dev could simply abandon the project, but anyone else would be able to fork it and pick up where he left off (you can also apply the changes locally yourself).
On the other hand, you don’t have to wait for anyone from the HA team to fix any issues which might occur. As explained above, since he’s not splitting his time on a hundred other integrations, he can solve issues and apply (sensible) feature requests within a short timespan and doesn’t have to wait for the next HA release to push a fix.

For now, despite your bad experience with Kodi, I wouldn’t worry too much about it - you can cross that bridge when you get to it.

1 Like

It’s definitely on my radar.

Once I’ve got some more of the basic functionality of my server up can give it a proper look over.

To be honest, I’m still getting to grips with the basic stuff that’s included by default.

1 Like