Hi all, newb Home assistant user here and trying to set up my first automations.
Have used the Xiaomi / Aqara gateway and sensors for some time with a few Yeelights, but want to dive further in home automation and also control my Philips Hue lights with these nice Xiaomi sensors.
So I’ve set up a Raspberry Pi with Home Assistant and got a few automations running correct after finding a few samples here on the forum.
What I’m trying to do is this:
-
Have one or more lights turn on after movement, auto turn off after a few minutes of no movement.
-
Have one or more lights turn on after movement, auto dim the lights after a few minutes of no movement.
So I have the first option running correct as far as I can tell, the lights go on when I enter the room and turn off just fine after a few minutes. Even if I use my Hue remote to change the White colour temperature (the lights always turn on than) they will return to an off state in time.
I’ve had to use 2 automations for this, maybe there’s a better way but at least it’s working:
- alias: Group berging ON motion
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001d9267e
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001d9267e
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: light.berging
data_template:
entity_id: light.berging
brightness: 254
And:
- alias: Turn off group berging
trigger:
platform: state
entity_id: light.berging
to: 'on'
for:
minutes: 5
action:
service: homeassistant.turn_off
entity_id: light.berging
Now the second option that I would like for other rooms - > So the lights should not turn off, but dim instead:
This example that I managed to put together (lol) seems to work fine for 1 or 2 times, but as soon as I use the Hue remote for example to change the White color temperature for a second, I get the problem that the lights will turn ON and stay in that state. So they do not dim to “1” again as I would like.
- alias: Group hal 1 ON motion
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001644e02
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001644e02
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: light.hal_spot_1
data_template:
entity_id: light.hal_spot_1
brightness: 254
And:
- alias: Set level light hal 1
trigger:
platform: state
entity_id: light.hal_spot_1
to: 'on'
for:
minutes: 5
action:
service: homeassistant.turn_on
entity_id: light.hal_spot_1
data:
brightness: 1
Could any of you HASSIO experts look at this and maybe give me a few directions on how to properly set this up?
Again I’m total newbee here so any help is highly appreciated !!
Cheers,’
H4ns