I moving all my lights from the Philips hue over to Home Assistant. Now I try to get the hang of using the motion sensor (PIR) to control the lights. With the help of Gemini I got a functioning YAML code, that works well. However, I tried several ways to integrate an additional condition, so that the light is not triggered when there is enough light. Every time the automation just didn't work anymore. I need help to understand how to deal with that.
Here's the functioning automation:
alias: Motion Hallway front (new)
description: >-
Turns on light based on time of day when motion is detected; turns off after 5
minutes of no motion.
triggers:
- type: occupied
device_id: 51c8ebb5a497aaafe3a816b8c092a313
entity_id: be0ab254feaa96064d1013129e4e8fef
domain: binary_sensor
trigger: device
id: motion_on
- type: not_occupied
device_id: 51c8ebb5a497aaafe3a816b8c092a313
entity_id: be0ab254feaa96064d1013129e4e8fef
domain: binary_sensor
for:
minutes: 5
trigger: device
id: motion_off
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: motion_on
sequence:
- choose:
- conditions:
- condition: time
after: "23:00:00"
before: "07:00:00"
sequence:
- action: light.turn_on
target:
entity_id: light.lamp_hallway_front
data:
brightness_pct: 10
- conditions:
- condition: time
after: "20:00:00"
before: "23:00:00"
sequence:
- action: light.turn_on
target:
entity_id: light.lamp_hallway_front
data:
brightness_pct: 60
default:
- action: light.turn_on
target:
entity_id: light.lamp_hallway_front
data:
brightness_pct: 100
- conditions:
- condition: trigger
id: motion_off
sequence:
- action: light.turn_off
target:
entity_id: light.lamp_hallway_front
mode: restart
Here's the code snipped considering the brightness, I have based on the GUI:
alias: "Motion Hallway front: day on"
description: ""
triggers:
- type: occupied
device_id: 51c8ebb5a497aaafe3a816b8c092a313
entity_id: be0ab254feaa96064d1013129e4e8fef
domain: binary_sensor
trigger: device
conditions:
- condition: time
after: "08:00:00"
before: "22:00:00"
- type: is_illuminance
condition: device
device_id: 51c8ebb5a497aaafe3a816b8c092a313
entity_id: c23481b5ffab4692cf41a82b6e4e244d
domain: sensor
above: 11
actions:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.lamp_hallway_front
data:
brightness_pct: 100
mode: single
What I tried so far is to integrate the following part into different places in the code and nothing worked.
- type: is_illuminance
condition: device
device_id: 51c8ebb5a497aaafe3a816b8c092a313
entity_id: c23481b5ffab4692cf41a82b6e4e244d
domain: sensor
above: 11
Can anybody provide some hints how to do that properly? Many thanks in advance.