I am using a wall tablet with Fully Kiosk, and want to switch the tablet motion detection entity switch from ON to OFF during the night between 9PM and 7AM, then back ON at 7AM.
How should I do that … ?
In the automation, I can not find a “from time … to time …”, but only a start time
I could create a 10 hours timer helper, but then wondering how to use it. It would be creating an automation with even start 9PM, action would be to set the switch OFF, but how to integrate the helper then the switch back on ?
You can use two automations one for ON and one for OFF, triggered by the time.
You can also combine these in a single automation using a Choose.
Trigger time-off, set id=off and trigger time-on, set id=on
Then for the action do a choose based on the id to set the switch OFF or ON
You need to add the correct action but somethinglike this;
MErci !!
ChatGPT m’a proposé ceci qui semble fonctionner … mais je me demande, si HA redémarre entre 21h00 et 7h00, si le trigger de 7h00 va encore fonctionner ?
Qu’en pensez vous ?
alias: Motion detection night schedule
description: OFF à 21h00, ON à 07h00
triggers:
- trigger: time
at: "20:00:00"
id: night_off
- trigger: time
at: "07:00:00"
id: morning_on
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: night_off
sequence:
- action: switch.turn_off
target:
entity_id: switch.lenovo_tab_m10_plus_3rd_gen_motion_detection
- conditions:
- condition: trigger
id: morning_on
sequence:
- action: switch.turn_on
target:
entity_id: switch.lenovo_tab_m10_plus_3rd_gen_motion_detection
mode: single
If Home Assistant is offline at 07:00:00 or 22:00:00 then the first example I posted will fail to turn the switch on or off because the automation’s Time Trigger will not be triggered.
The following version is more robust because it not only triggers at 07:00:00 and 22:00:00 but also whenever Home Assistant starts. It determines if the switch should be turned on or off based on whether the current hour is inside or outside of the time range (07:00:00 - 22:00:00).
Home Assistant’s automations cannot do anything when Home Assistant is down.
If Home Assistant is down, the second automation example I posted will trigger at the first possible opportunity and that is when Home Assistant starts running again.
trigger: homeassistant
event: start
Most of my automations are designed this way; in addition to their specific triggers, they also trigger on startup and determine what should be turned on or off. It ensures everything is set to its correct state after a power failure.