Hi guys!
I run Home Assistant on a Raspberry Pi in combination with a Zigbee stick and loads of Ikea lights and motion sensors, and some aquara door sensors thrown in. I’ve been running the setup for quite some time, but without much added smarts. I’m changing this by automating my home step by step…
I’ve been really struggeling to get Home Assistant do what I want it to do: I failed to modify and get the automations I found online, or the automations just don’t do exactly what I want them to do…
Now, I’m no newbie to coding, but then I’m talking C-type languages If then else and a whole lot more… But the Hass language has really got me confused…
Long story short, my first big automation is this:
I want 2 lights to turn on, when motion is detected. But between 7:00 and 19:00 I want it to be brighter then between 1900 and 700. After 3 minutes the lights should go off.
The code below works (as of now). But I’m very much aware that this is not the way to go…
It relies on 3 scenes where the light intensity of the 2 bulbs in question is either set to 1%, 100% or off…
- id: '1661194722124'
alias: DIY Motion activated lights gang Avond
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.beneden_gang_motion_on_off
- binary_sensor.boven_gang_motion_on_off
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: time
before: 07:00:00
after: '19:00:00'
weekday:
- sun
- sat
- thu
- fri
- wed
- tue
- mon
action:
- service: scene.turn_on
target:
entity_id: scene.gang_s_avonds
metadata: {}
mode: single
- id: '1661197191194'
alias: DIY Motion activated lights gang Ochtend
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.beneden_gang_motion_on_off
- binary_sensor.boven_gang_motion_on_off
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: time
before: '19:00:00'
after: 07:00:00
weekday:
- sun
- sat
- thu
- fri
- wed
- tue
- mon
action:
- service: scene.turn_on
target:
entity_id: scene.gang_s_ochtends
metadata: {}
mode: single
- id: '1661197292370'
alias: Lampen gang uit na 3 minuten
description: ''
trigger:
- platform: device
type: turned_on
device_id: f5bd06d461a75408f4399c6da340ca78
entity_id: light.beneden_gang_lamp_light
domain: light
for:
hours: 0
minutes: 3
seconds: 0
condition: []
action:
- service: scene.turn_on
target:
entity_id: scene.new_scene
metadata: {}
mode: single
I’m not quite done with this automation either;
I want to add the fact that one light should be turned up to 100% for 5 minutes when a door opens (magnetic on_off sensor).
But that can wait for now: I want to wrap my head around the basics before going even deeper and maybe confusing myself even more…
Thank you for your consideration, help in the matter or general advice!