Hey, just wondering if anyone can give me some advice on an automation I’m doing. I have set up an automation with my hue sensor and hue bulb using the Lux entity so the bulb wont come on during the day where there is enough light already. The automation works perfectly, I am now trying to get it so when the light does turn on when there isn’t enough light Ie night or dull days the light will turn off after 3 minutes of no motion but I’m struggling with the no motion side of things, do I need to make a new automation for that or can I just use another trigger? This is my config file so far.
Thanks in advance.
- alias: Turn off kitchen light 10 minutes after last movement
trigger:
platform: state
entity_id: sensor.motion_sensor
to: 'off'
for:
minutes: 10
action:
service: homeassistant.turn_off
entity_id: light.kitchen_light
Thank you @sjee, yeah I have seen that, so I need to create another automation? So I will have three automations 1 to only turn the light on when its dark, 2 for the light not to turn on at all when there is enough light, and a 3rd to say turn off light after 3 minutes?
That’s great @sjee@Underknowledge. I will create the 3rd automation when I get home, and see how I get on.
So it should look like this, with the 3 automation?
- id: '1561406598184'
alias: Motion Light Sensor On
trigger:
- entity_id: binary_sensor.dining_room_sensor_1_motion
platform: state
to: 'on'
condition:
- below: '70'
condition: numeric_state
entity_id: sensor.dining_room_sensor_1_light_level
action:
- alias: ''
data:
entity_id: light.dining_room
service: homeassistant.turn_on
- id: '1561408367485'
alias: Motion Light Sensor Off
trigger:
- entity_id: binary_sensor.dining_room_sensor_1_motion
platform: state
to: 'off'
condition:
- above: '80'
condition: numeric_state
entity_id: sensor.dining_room_sensor_1_light_level
action:
- data:
entity_id: light.dining_room
service: homeassistant.turn_off
- id: '1561453677647'
alias: LIghts Off After 3 Minutes
trigger:
- entity_id: binary_sensor.dining_room_sensor_1_motion
for: 00:03:00
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.dining_room
service: homeassistant.turn_off
@Underknowledge I have been using the automation editor for now, to understand better how it all works… but starting to use just the text editor now.
Ahhhh that’s a good spot that, that’s using the automation editor that, that hasn’t put in the ’ ’ either side of the 00:03:00. or do you mean the for needs them?
for: is expecting a string. because the string includes the special character “:” that yaml uses in other areas (like after for:) to denote a key:value pair then it will get confused trying to figure out how to interpret that unless you explicitly declare it as a string by wrapping it in quotation marks.
It’s the same with ‘on’ & ‘off’. those require the quotation marks too since yaml treats a regular on or off as a boolean. And when you write “to:” then it is expecting a string not a boolean so you have to tell it you’re giving it a string by wrapping the ‘on’ in quotation marks.
And the sooner you can get away from using the automation editor the better off you will be.
Hi,
If the app turn on the light then the motion is not registered, then the light will not be turning off. How do you include that condition to turn off the light when google assistant turn on the light? Thanks
Thanks for the reply. I am new to home assistant so I don’t know much to yet. Can you explain the above code? Where do you get these names define? x.motion_bad, x.bad_movement, x.bad_ambiance, x.bad_mode_state? Thank in advance.
Motion_bad is the actual motion sensor
Bath movement is an input_number (I can set the timeout dynamic) bad ambiance is the light to control and bath mode States is an template sensor. ( When you’re in the shower or taking a bath you don’t like to sit in the dark
The only intersting part for you atm is the second trigger for the automation.
When the light xy is on for x minutes run this Automation