this post was submitted on 30 Sep 2025
26 points (96.4% liked)

homeassistant

16424 readers
81 users here now

Home Assistant is open source home automation that puts local control and privacy first.
Powered by a worldwide community of tinkerers and DIY enthusiasts.

Home Assistant can be self-installed on ProxMox, Raspberry Pi, or even purchased pre-installed: Home Assistant: Installation

Discussion of Home-Assistant adjacent topics is absolutely fine, within reason.
If you're not sure, DM @GreatAlbatross@feddit.uk

founded 2 years ago
MODERATORS
 

Currently, I have an automation that turns on my air conditioner for 37 minutes, every 3 hours. However, during that time, I cannot do anything like update, HAOS, etc. Because it breaks the timer, and then I have to manually shut it off.

top 18 comments
sorted by: hot top controversial new old
[–] AreaKode@lemmy.world 16 points 6 days ago (1 children)

Make sure you have this option checked:

[–] roofuskit@lemmy.world 4 points 5 days ago (1 children)

Been using home assistant from the very early days and I did not realize this function existed. Thank you.

[–] AreaKode@lemmy.world 3 points 5 days ago

I don't know why this isn't the default option. If I have a timer running, I want it to survive a reboot.

[–] oliof@piefed.social 1 points 3 days ago

I had good success with the scheduler card from HACS: https://github.com/nielsfaber/scheduler-card (also requires scheduler components, just follow install instructions).

[–] Bryan065@kbin.earth 7 points 5 days ago (1 children)

i would probably do it with two+ automations. Something like:

ON automation:

  • trigger:
    • time pattern - beginning of every 3 hours
  • then:
    • start timer with duration 37 minutes (select your timer helper)
    • Turn on AC unit

OFF automation:

  • trigger:
    • Manual Event
      • event type: timer.finished (case sensitive!)
      • event data : entity_id: timer.[timer_helper_entity]
  • then:
    • turn off AC unit

STARTUP_CHECK automation:

  • trigger:
    • when home assistant is started
  • if:
    • state - timer helper is idle
    • AC is on
  • then:
    • turn AC off

Note 1: make sure the timer helper has restore state and time when HA starts enabled

note 2: automations using the timer.finished event will not trigger on startup if the timer expires when Home Assistant is not running.

note 2a: the third automation is for your edge case that you reboot/shutdown HA when the OFF automation was supposed to fire. it should ensure the AC turns off after the timer was supposed to be finished and HA is started. this automation does not account for if the AC is turned on manually and you restart HA.

i can get you the .YAML or pictures when I'm at a computer.

[–] dream_weasel@sh.itjust.works 1 points 5 days ago

@shortwavesurfer@lemmy.zip you may also want an additional automation to start your ac at a particular time and reset the timer if you are concerned about drift in your AC schedule. I could see, for example, ensuring that it's running before you go to bed so it's cool for example.

Definitely multiple automations is the answer, this is almost exactly how I manage my hydroponic tower, except that I don't worry about the timer and I give it a manual run if I reboot (or don't. the plants can go a few hours without running the pump).

[–] CompactFlax@discuss.tchncs.de 7 points 6 days ago* (last edited 6 days ago) (1 children)

Save stop time to a helper. Helper state persists through automation restarts, ha restarts, and OS restarts.

Check the helper every minute. Or, just run until the stop time is reached, and create an automation to check and restart the timer when HA restarts.

[–] KairuByte@lemmy.dbzer0.com 3 points 5 days ago

This is the way. It’s a little annoying, but much more reliable. If you set an actual date and time, you can also ensure an old timer kicks off if HA was down for more than the minute it needed to hit.

[–] roofuskit@lemmy.world 4 points 6 days ago

Have the script generate the time and save it as a number or other variable, have the script start when home assistant does and check the variable, if the time has passed toggle the state of the AC and generate the next run time. If it time is in the future run the script again at that time.

The logic would look something like this: Start with home assistant or at the next interval of the script Check stored time, if it has elapsed toggle the state of the AC Generate new time and store it repeat the script at that time

[–] christianhawkins@feddit.org 2 points 6 days ago* (last edited 6 days ago)

There are many ways how you could go about this.

The easiest way with the fewest helpers imo is to execute it every minute, check if the ac should be on or off based on your time rules and then turn it to the state you want it, if it is not in that state.

description: Turn AC on between minutes 0-37 of hours 0,3,6,9,12,15,18,21; off otherwise
trigger:
  - platform: time_pattern
    minutes: "/1"  # runs every minute

condition: []

action:
  - choose:
      - conditions:
          - condition: template
            value_template: >
              {% if now().hour in [0,3,6,9,12,15,18,21] and 0 <= now().minute <= 37 %}
                true
              {% else %}
                false
              {% endif %}
        sequence:
          - condition: state
            entity_id: switch.ac
            state: "off"
          - service: switch.turn_on
            target:
              entity_id: switch.ac
    default:
      - condition: state
        entity_id: switch.ac
        state: "on"
      - service: switch.turn_off
        target:
          entity_id: switch.ac
mode: single```
[–] mhzawadi@lemmy.horwood.cloud 2 points 6 days ago (1 children)

Check your on the latest version as you can now get home assistant to save the timer before a restart, look for the restore option

https://www.home-assistant.io/integrations/timer/

[–] shortwavesurfer@lemmy.zip 1 points 6 days ago (1 children)

So my automation actions now read, turn on device, start the timer that has 37 minutes programmed into it. The delay for 37 minutes that I had before is now disabled, and then turn off device.

If I'm understanding correctly, now that I should turn on the device, start the timer, wait for the timer to finish, and then turn the device off.

[–] mhzawadi@lemmy.horwood.cloud 1 points 6 days ago (1 children)

kind of, why 37 minutes? if you can turn it on and off, why not use a temperature sensor to see if its too hot and turn it on till it gets cold

[–] shortwavesurfer@lemmy.zip 1 points 6 days ago* (last edited 6 days ago)

Because currently I don't own a temperature sensor. I plan to own one in the future, but at this moment I do not own one.

Edit: Also, that did not work. I believe it started the timer, but then it did not wait for the timer to finish. It just continued right on with the list of actions and turned off the device again.

[–] aion@lemmy.world 2 points 6 days ago (1 children)

If you have a zigbee/z-wave/thread network, you could get a temperature sensor and setup HA to use that to control the AC. There's a built in "generic thermostat" that would do most of the work for you.

[–] shortwavesurfer@lemmy.zip 2 points 6 days ago (1 children)

Yeah, I have plans on doing that at some point. I've just not wanted to spend the money on it lol.

I would likely go with the Third Reality sensor

[–] aion@lemmy.world 1 points 6 days ago (1 children)

I have a few of the Third Reality sensors, they work pretty well for this kind of application.

[–] shortwavesurfer@lemmy.zip 2 points 6 days ago

Yeah, I like my third reality smart plug, so the third reality temperature sensor is probably the one I will end up going with.

Mainly because the third reality products are official home assistant partners.