Your code looks good and easy to do but Im still struggling to add a delay or something to make my bathroom light stop on longer than a 1min when motion is detected. I seem to get errors in the code or the light stops on but it never does it to what I tell it too.
this is my code. I hope you can help me with something that should be easy to do but not
I’m using a Desk Lamp to make things easier to test:
alias: Turn on/off Desk Lamp on motion between 09:00 and 18:00 and off after 10min without motion
description: ""
mode: restart
trigger:
- platform: state
id: "on"
entity_id:
- binary_sensor.motionmasterbedroom_occupancy
to: "on"
- platform: state
id: "off"
entity_id:
- binary_sensor.motionmasterbedroom_occupancy
to: "off"
for:
hours: 0
minutes: 10
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- "on"
- condition: time
after: "09:00:00"
before: "18:00:00"
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.light_hallway_upstairs
default:
- service: light.turn_off
data: {}
target:
entity_id: light.light_hallway_upstairs
This will trigger when motion is detected/cleared.
When it is detected, and time is between 09:00 and 18:00, lamp will turn on and automation is restarted.
When it is cleared for 10 minutes, lamp will turn off and automation is restarted. Note that lamp will always turn off, also outside the window 09:00-18:00
Thank you for this help I’m very new to this and I will have a look now at changing it! Can I easily add Sun instead of time as I did time just for now during the day to test to see if I could get it to work? so normally I have it to do this tast when the sun set and the sun raise but id also at some point later do it to light on the sensors!
I’m also not at all sure how to add things into a state!
You want to trigger when motion is detected, so: attribute: This depends a bit of the sensor; It looks like your sensor is a combined sensor for luminance and motion, so if the state is motion, leave empty. If the motion is only available as an attribute of a combined sensor, select motion. from: irrellevant, just leave empty to: detected
I dont seem to be getting these options you say, I have nothing to pick the state as Motion. I do know the sensor does luminance on it why I was trying to find ways to know which sensor I was using by using ID to find them but now Im picking the entity of it but get no options to pick if motion is detected
I’m not getting any light coming on at all now. So not sure what Ive done wrong. I found a different way to find the Desk light using Services also now with you saying to do it this way.
- id: '1693220576809'
alias: Turn on Desk Lamp
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_motion_ac02_motion
from: 'on'
for:
hours: 0
minutes: 3
seconds: 0
to: 'on'
condition:
- condition: time
after: 09:00:00
before: '18:00:00'
action:
- service: light.turn_on
data: {}
target:
device_id: 50c44d6919b421581237941a26338ab8
mode: single
- id: '1693220799421'
alias: Turn off Desk Lamp
description: ''
trigger: []
condition: []
action: []
mode: single
I did but looking on the code it does not go to the same as yours so I messed around with it until it did! now I took them all out and left them empty The light still does not come on and the code it nothing like yours is! Like I said I have no clue what to put in these options I have never done that or looked at them before so I’m trying to go off what you say but I also have Dyslexia which is also another issue I have to try to deal with Yes, I know it does not get it to work but I tend to have to keep changing things and guessing to try to get it to work. I have so far spent 2 months trying to get this to work and still cannot do it. It was easier in Smartlife as it stopped on easier than this!
Might be easy once I get my head around it but it’s not working for me yet
alias: Turn on Desk Lamp
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_motion_ac02_motion
for:
hours: 0
minutes: 3
seconds: 0
to: 'on'
condition:
- condition: time
after: 09:00:00
before: '20:00:00'
action:
- service: light.turn_on
data:
brightness_pct: 60
target:
device_id: 50c44d6919b421581237941a26338ab8
mode: single
- id: '1693220799421'
alias: Turn off Desk Lamp
description: ''
trigger: []
condition: []
action: []
mode: single
Do you mean it should come on right away then continuous motion for a minimum of 3 minutes? as this is what I want the light to turn on the light it used too using Smartlife, Id walk in and the light would then stop on as long as Im moving in the room for the length of the time Im in that room? But I also want it to not turn off after in 1 min when I go out of them room like all of them do as standard! I want it to turn off after 3 mins or maybe 2 mins just depending but 1 min is so annoying no time to do anything and causes things to also blink on and off which is also very annoying.
The trouble is nothing seems to work no matter what I do . took me 2 weeks to just get a light on in HA with the way you have to set it up with Automation and still learning Now! But now no light comes on at all on this Motion Sensor.
it gives me loads of error if i copy your code! Do you not think something else is at play here as I have tried all entities for the sensor to make sure is not missing anything!
I will try to copy the little bit you have just posted see what it does to me!