I’ve managed to solve a part of my automation, override. So if the light is on triggered manually, the motion sensor detects movement it does nothing. If the light off and motion sensor detects movement then it will turn it on and off after 10 second.
10 second is more for testing, i will change the value to my desired value later.
My issue was, i created two sperate automation, on and off. Which the off automation overrides manually state. New code is all in one automation.
- id: '1610238984385'
alias: Night light on motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.aeon_multipurpose_sensor_motion
to: 'on'
condition:
- condition: and
conditions:
- condition: state
entity_id: light.hue_lightstrip_plus_2_2
state: 'off'
action:
- service: light.turn_on
data: {}
entity_id: light.hue_lightstrip_plus_2_2
- delay: 00:00:10
- service: light.turn_off
data: {}
entity_id: light.hue_lightstrip_plus_2_2
mode: single
What left:
How to set motion activation after sunset
How to set motion deactivation after sunrise
Sunset to 22:59:59 at full brightness
23:00:00 to Sunrise at 35% brightness
Is there a way to set a time to sun and sun to time i.e 23:00:00 to sunrise and sunset to 22:59:59?
I think i may have found a way with scenes, but i have to define time to time, which defeat the purpose of time tracking with sunset and sunrise.
I use a timer. I have 1 automation that starts the timer and turns on the lights based on motion and any conditions. It’s mode is restart. Then a second automation on the timer expiration that turns the lights off.
I will add the code to mine and change where i need to for my device.
I have a samsung motion which works good for 85% of the time. My Aeotech MultiSensor 6 is a bit too slow for my liking. Maybe i need to update the code on samsung smartthing. Probably i wont as i want to connect it directly to my home assistant.
I use HUE motion sensors (inside and outside) and a couple IKEA TRADFRI switches connected to DECONZ/ConBee II and HUE lights on a HUE Hub. I have a bunch of Kasa wall switches and plugs (which I have problems with them not showing up on a restart of HA, if they are there they work pretty well. I have IKEA TRADFRI repeaters for the DECONZ network because I don’t have a lot of items on it. I might purchase a couple more to ensure good coverage. The biggest issue is the signal to the outdoor sensors is not great. I have considered moving DECONZ to ZHA but I asked about how to do that move without losing everything here on the forum and got no responses, so I’m holding off on that for now.
So, I’ve been playing with the code and testing it last night. I found a issue, issue was after 00:00:00 the lights would not work. When i check the brightness it was reduced to 0 every time i trigger it. I would manually change it to 100% and then trigger the motion and no luck. Light would not turn on and brightness would be 0%.
I’ve solved it by adding another line of time after 00:00:00 with all the setting i required. Works like a dream now.
Sunset and Sunrise seems to be working too. It afternoon now and am trying to trigger off the motion, but it wont trigger the lights. So, it look good.
I’ve notice another issue, my motion sensor or HA doesn’t reset the timer if i move around the room. I have a feeling it more HA side. As i will trigger the motion sensor, i made a dashboard for the motion sensor and say “detected” but the light just goes off when its timer reaches.
Would you know of a code to add?
Am doing a research in the forums for reset motion timer, but it hard for me to read their code as they add addition parameter which i don’t understand yet.
Here my latest code.
- id: '1610479739773'
alias: Motion activated with Sun and increase/reduce brightness
description: ''
trigger:
- platform: state
entity_id: binary_sensor.aeon_multipurpose_sensor_motion
to: 'on'
condition:
- condition: and
conditions:
- condition: state
entity_id: light.hue_lightstrip_plus_2_2
state: 'off'
action:
- choose:
- conditions:
- condition: sun
after: sunset
- condition: time
before: '22:59:00'
sequence:
- service: light.turn_on
data:
brightness_pct: 100
entity_id: light.hue_lightstrip_plus_2_2
- conditions:
- condition: sun
before: sunrise
- condition: time
after: '23:00:00'
sequence:
- service: light.turn_on
data:
brightness: 32
entity_id: light.hue_lightstrip_plus_2_2
- conditions:
- condition: sun
before: sunrise
- condition: time
after: 00:00:00
sequence:
- service: light.turn_on
data:
brightness_pct: 32
entity_id: light.hue_lightstrip_plus_2_2
default: []
- delay: 00:00:02
- service: light.turn_off
data: {}
entity_id: light.hue_lightstrip_plus_2_2
Sounds like a good setup. Do you think issue may be due to Ikea Tradfri repeaters not relaying back to HA after reboot? Maybe try another brand repeater?
Or maybe its Deconz itself?
Is your setup like this Kasa wall switches > Ikea Tradfri > Deconz > HA? In terms of communication.
So moving off to HA, not a bad idea. But if no one available to help then maybe break down your automation. Move one at a time. Pick a easy automation and re-create it in HA, Show and tell us what you want it to do for a single automate. Am sure then someone can help you create the code. Then learn and understand the code in HA. Keep going till everything has moved over. Remember test, test and test and modify till your happy. Take it in a small steps.
I love Philips Hue, i recently re-did my house and installed loads of philips lights from “Being Ceiling”, “Still Ceiling”, “Cher Pendant”, “Colour Spot Light” etc. I dont have a issue as they are creating their own mash and i believe my other zigbee devices are hopping on the mash. My ring alarm is using z-wave and comes with it own z-wave repeater and my Samsung motion sensor probably hopping on too.
As far as turning off the light, you’re right the delay that you have in there wont pay any attention to what’s going on with the motion sensor. While its probably possible to work this into the existing automation using wait and some timedelta stuff, the far easier solution would be to make a second automation that handles turning off the light. Something like:
alias: Light Turn Off
trigger:
- platform: state
entity_id: binary_sensor.aeon_multipurpose_sensor_motion
to: 'off'
for: "00:02:00"
condition:
- condition: state
entity_id: light.hue_lightstrip_plus_2_2
state: 'on'
action:
- service: light.turn_off
entity_id: light.hue_lightstrip_plus_2_2
You can add any other conditions you need, I just put one in to fire only if the light was already on.
Thank you, i was on the same wave length as you, i was just playing with the code and add triggered.
I think it worked.
- id: '1610479739773'
alias: Motion activated with Sun and increase/reduce brightness
description: ''
trigger:
- platform: state
entity_id: binary_sensor.aeon_multipurpose_sensor_motion
to: 'on'
condition:
- condition: and
conditions:
- condition: state
entity_id: light.hue_lightstrip_plus_2_2
state: 'off'
action:
- choose:
- conditions:
- condition: sun
after: sunset
- condition: time
before: '22:59:00'
sequence:
- service: light.turn_on
data:
brightness_pct: 100
entity_id: light.hue_lightstrip_plus_2_2
- conditions:
- condition: sun
before: sunrise
- condition: time
after: '23:00:00'
sequence:
- service: light.turn_on
data:
brightness: 32
entity_id: light.hue_lightstrip_plus_2_2
- conditions:
- condition: sun
before: sunrise
- condition: time
after: 00:00:00
sequence:
- service: light.turn_on
data:
brightness_pct: 32
entity_id: light.hue_lightstrip_plus_2_2
default: []
- service: light.turn_on
data: {}
entity_id: light.hue_lightstrip_plus_2_2
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.aeon_multipurpose_sensor_motion
from: 'on'
to: 'off'
for: 00:00:30
- service: light.turn_off
data: {}
entity_id: light.hue_lightstrip_plus_2_2
mode: single
It didn’t need delay, but wait for trigger.
You don’t know how happy i am now.
I was going to abandon HA to go back to Samsung Smartthing. I guest i learnt my lesson being patient is key.
I did install Node Red, but it messed up my HA and was running slow. Luckily i could still access the interface and delete it.
Now am going to test this on my landing light.
I was testing this on my Philips light strips behind my TV which these lights don’t have a physical switch, which i though could also be the problem, after reading someone else post with manual override with a switch.
Motion activates select light or group (if you created a group), only after sunset and stop at sunrise. Keeps the brightness at 100% till “22:29:59”, then change the brightness to 32% at “22:30:00” till sunrise. Also there’s another condition to change the brightness after “00:00:00” with the brightness of 32% to keep it working throughout the night. Without this condition after “00:00:00” it doesn’t work, probably cause its a another day or something. Bonus, bypass is also added, if you switch the light on via the app or physically from a switch then the motion sensor wont activate the timer and switch off.
I may create a another code with lux once i received my Xiaomi Aqara.