Dose you slider show up on the frontend? Do I need to do somthing to get it to show up on the front end?
not sure what happend but the slider just showed up on the frontend.
If you haven’t overwritten your Frontpage in groups, the slider should show by default
I let the home tab in groups alone so anytime I add something it would show up there. About an hour later it just showed up. Then I added it to another light and it showed up right away. Not sure why that happened. Thanks for your help
To switch on lights when there is motion, and to switch them off with a delay when there is no motion you can also use just 2 automations and skip the timer scripts: Home Assistant automatically times how long ago a motion sensor turned off. E.g. automation.yaml:
## Motion sensor kitchen
- alias: Lights on when motion on
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: 'on'
action:
- service: light.turn_on
entity_id: group.kitchen
- alias: Light off after 90 sec when motion off
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: 'off'
for:
minutes: 1
seconds: 30
action:
- service_template: light.turn_off
entity_id: group.kitchen
Will this cancel the off timer as well?
Eg. If the motion sensor sees movement again, while the off timer runs.
Yes. If motion is detected again within 1:30 the lights stay on.
can not for the life of me get this to work, any one else tried??? most likely my formating
update… code as expected was correct my problem was my lack of knowledge re how I split up my automation file…
All of this should be able to be done with one automation as well. I haven’t tested this but it should work.
- alias: Lights on/off based on motion
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor
to: 'off'
for:
minutes: 1
seconds: 30
action:
service_template: >
{% if trigger.to_state.state == "on" %}
homeassistant.turn_on
{% elif trigger.to_state.state == "off" %}
homeassistant.turn_off
{% endif %}
entity_id: group.kitchen
I like how you have done this,
but how would you make the “for:” timer dynamic (use a input slider//template)?
If you were to replace your automatons and script posted above with this, I think it should do the same thing. This is untested though.
entrence_delay:
name: Entrence Delay
initial: 2
min: 0
max: 20
step: .5
.
- alias: Lights on/off based on motion
trigger:
- platform: state
entity_id: sensor.fibaro_system_fgms001_motion_sensor_burglar_9_10
to: '8'
- platform: state
entity_id: sensor.fibaro_system_fgms001_motion_sensor_burglar_9_10
to: '0'
for:
seconds: '{{ states.input_slider.entrence_delay.state|float * 60 }}'
action:
service_template: >
{% if trigger.to_state.state == "8" %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id:
- light.entre
I tried this and it doesn’t work, as you cannot turn off something with a data_template, i.e. you get an error in the log
“Invalid service data for light.turn_off: extra keys not allowed @ data[‘brightness’]. Got ‘255’
extra keys not allowed @ data[‘color_temp’]. Got ‘255’”
pity as I have wasted a morning trying to do this in 1 automation instead of 2.
Tried with scene.turn_on/scene.turn_off but there is no scene off… so back to 2 automatons I think arggh
I also found out that switching off lights with one automation that waits for sensor state to be off for xx minutes does not work well: it seems multiple off timers start, each time the motion sensor state changes to off, and the lights start to turn off randomly until all timers have ended. I didn’t notice it at first because the delay time was only 30 seconds, but it gets annoying with a 30 minute delay time.
So, back to using a timer script with the automation to trigger it…
You might want to look into using Appdaemon, It looks difficult but it is not to hard to get going. It solves all these problems!
hello, I’m new to Home Assistant. I have made an esp8266 MQTT motion sensor. when motion is detected it will be sending MQTT message “Motion Detected” to HA… what I want to do he when HA received Motion detected message I want the light to turn on and keep it on for 3 mins then turn it back off. I have made an automation to turn on the light when motion is detected. someone, please help me can I make it to auto turn off after 3 mins?
You basically just need to scroll up in this thread, and you will find plenty of examples where lights are turned on triggered by motion detected or sun setting, and then turned off after a set amount of time.
Hello @Ashfaaa
This is the way I’m doing it, thanks to @Pilot, which I’m happy with…
- alias: Light off after 90 sec when motion off
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: 'off'
for:
minutes: 1
seconds: 30
action:
- service_template: light.turn_off
entity_id: group.kitchen
Hi @Ashfaaa, someone had the same (arduino sketch) problem.
You can use the automation with timed scripts, or use another sketch.
you have any better sketch.? im kinda new to all this
Sorry, no. But everything you need is the linked thread.