How can i set this on Specific time ? like at in the evening 20:00 to 5:00 morning Only?
where i need to add the timer for 10 min off?
where i need to add the entity_id for the lamp and entity_id for the sensor motion ?
Thanks!
Mp
- alias: kids Night lamp
trigger:
- platform: state
entity_id: binary_sensor.XXXX
to: 'on'
condition:
- condition: time
after: '20:00:00'
before: '05:00:00'
action:
- service: homeassistant.turn_on
entity_id: binary_sensor.XXXX
Note the indentation (spacing) this is very important.
Note my comments below:
- id: kids_night_lamp_on
alias: 'Kids Night Lamp On'
trigger:
- platform: state
entity_id: binary_sensor.XXXX #<- This should be your motion sensor
to: 'on'
condition:
- condition: time
after: '20:00:00' # <- motion will only trigger the light on between these times
before: '05:00:00'
action:
- service: homeassistant.turn_on
entity_id: light.your_light # <- this should be your light entity_id
You will need another automation to turn the lights off after 10 minutes.
- id: kids_night_lamp_off
alias: 'Kids Night Lamp Off'
trigger:
- platform: state
entity_id: binary_sensor.XXXX #<- This should be your motion sensor
to: 'off'
for:
minutes: 10
action:
- service: light.turn_off
entity_id: light.your_light # <- this should be your light entity_id
a general advice - when you post a piece of code, on a new string put 4 single backquotes, then new line, your code, newline and another 4 single backquotes, thatâs to preserve formatting which is essential in HA
heâll also need to think what to do if his âonâ automation triggers more than once within 10 minsâŠ
His code was actually block quoted. Just had bad indentation. Also itâs 3x backquotes.
See my edited post. It does not matter if a light that is already on gets turned on again though a condition would remove this extraneous network traffic.
My off automation is triggered by no movement for 10 minutes, not the light being on for 10 minutes.
Yes it should be in 2 separate codes. One to turn light on after movement and between the hours you want. The second to turn off the light if no movement has been detected for 10 minutes.
I have very similar code for my lights working perfectly.
The reason light.turn_off wonât work is because you arenât turning off a light. You are turning off a switch.
homeassistant.turn_xx works on any domain so thatâs why it worked in the first automation. You should be using switch.turn_on/switch.turn_off for you service calls.