2024年11月24日星期日 下午12:57:44

timer

2 年 前
#16595 引用
You’ll need a timer  and an automation.



0
2 年 前
#16596 引用
timer:
  laundry:
    duration: '01:00:00'

automation:
  - alias: Turn on the timer
    trigger:
      - platform: state
        entity_id: switch.some_switch
        to: 'on'
    action:
      - service: timer.start
        data:
          entity_id: timer.laundry
          duration: '03:00:00'
0
1 年 前
#20928 引用
The timer is Idle when it’s finished, canceled, or never started
The timer is Active when it is currently running
The timer has the state Paused when it is paused



We can check the status of timers using events in Home Assistant. So we can see if the timer is canceled, finished, started, restarted, or paused. We are going to check if the timer is finished or canceled in this example to keep it simple.

In our use case, we are going to use the random function of Home Assistant to turn off the lights after a random time interval between 1 and 30 minutes. In this case, it can happen that Home Assistant gets restarted in between. I will show you that the timer will still be alive after the restart.

I created a simple dashboard that contains the status of the light and the status of the timer so that we can follow the progress of our timer.

https://www.smarthomejunkie.net/how-to-use-timers-perfectly-in-home-assistant/
0