So I kind of have a small problem with automating my light timers, we constantly seem to have lights that turn off when we a all actively in front of them, I’ve got the automation set to restart on the trigger side and have moved the automation to call a script instead of delay timers being used as im told these if triggered again can stop the delay. Any help would be great (the wife now thinks its not funny…)
the Goal
the goal is to turn on lights in different combinations when the light level changes and time of day. and to turn off when we are not in front of the Philips Pir detector
The system is running on Zigbee2Mqtt.
advance apologies for the complex automation>script>scene, but I couldn’t think of a way to script it down to a pick and option, then pick another option based on time of the day vs light level.
- id: '1615045956352'
alias: '1- Automation - Kitchen Lights '
description: ''
trigger:
- platform: state
entity_id: binary_sensor.kitchen_pir_occupancy
from: 'off'
to: 'on'
for: 00:00:01
condition: []
action:
- choose:
- conditions:
- condition: time
after: '23:31'
before: 05:29
sequence:
- service: script.kitchen_lights_at_night
- service: light.turn_off
data: {}
target:
area_id:
- 82e9b832929a48e59806ac8f2efa08e4
- acf47f95c1044de6bac72f531a1b7953
- conditions:
- condition: time
after: 05:30
before: '23:30'
- condition: numeric_state
entity_id: sensor.driveway_light_level
below: '30000'
attribute: light_level
sequence:
- service: script.kitchen_lights_in_the_day
- service: light.turn_off
data: {}
target:
area_id:
- acf47f95c1044de6bac72f531a1b7953
- 82e9b832929a48e59806ac8f2efa08e4
- conditions:
- condition: numeric_state
entity_id: sensor.driveway_light_level
attribute: light_level
above: '30000'
- condition: time
after: 05:30
before: '23:30'
sequence:
- service: script.kitchen_lights_in_the_day_not_utility
- service: light.turn_off
data:
transition: 10
target:
area_id:
- acf47f95c1044de6bac72f531a1b7953
- 82e9b832929a48e59806ac8f2efa08e4
default: []
mode: restart
max: 3
the “day” Script
kitchen_lights_in_the_day:
alias: Kitchen Lights in the Day
sequence:
- choose:
- conditions:
- condition: time
after: 05:29
before: '11:59'
sequence:
- scene: scene.kitchen_lights_morning
- conditions:
- condition: time
after: '12:00'
before: '14:00'
sequence:
- scene: scene.kitchen_lights_lunch
- conditions:
- condition: time
after: '14:00'
before: '23:30'
sequence:
- scene: scene.kitchen_lights_night
default: []
- delay:
hours: 0
minutes: 5
seconds: 10
milliseconds: 0
- condition: state
entity_id: binary_sensor.kitchen_pir_occupancy
state: 'off'
for:
hours: 0
minutes: 1
seconds: 0
- service: light.turn_off
target:
area_id:
- acf47f95c1044de6bac72f531a1b7953
- 82e9b832929a48e59806ac8f2efa08e4
mode: restart
icon: mdi:lightbulb-on
and the “night scene”
icon: mdi:weather-sunny
- id: '1643039277759'
name: Kitchen Lights Night
entities:
light.kitchen_kickspace1:
min_mireds: 150
max_mireds: 500
effect_list:
- blink
- breathe
- okay
- channel_change
- finish_effect
- stop_effect
supported_color_modes:
- color_temp
- xy
color_mode: xy
brightness: 255
hs_color:
- 299.754
- 95.686
rgb_color:
- 254
- 11
- 255
xy_color:
- 0.385
- 0.155
color:
h: 300
hue: 300
s: 100
saturation: 100
x: 0.385
y: 0.155
device:
applicationVersion: 1
dateCode: '20131206'
friendlyName: Kitchen kickspace1
hardwareVersion: 1
ieeeAddr: '0x00124b00222efb28'
manufacturerID: 0
manufacturerName: GLEDOPTO
model: GL-C-008-1ID
networkAddress: 32662
powerSource: Mains (single phase)
softwareBuildID: 3.0.0
stackVersion: 2
type: Router
zclVersion: 1
linkquality:
icon: mdi:led-strip-variant
friendly_name: Kitchen kickspace1
supported_features: 63
state: 'on'
light.kitchen_main_lights:
effect_list:
- blink
- breathe
- okay
- channel_change
- finish_effect
- stop_effect
supported_color_modes:
- brightness
color_mode: brightness
brightness: 255
device:
applicationVersion: 0
dateCode: 'NULL'
friendlyName: Kitchen Main lights
hardwareVersion: 0
ieeeAddr: '0xec1bbdfffe7d15ee'
manufacturerID: 4107
manufacturerName: Sunricher
model: ZG9101SAC-HP
networkAddress: 7725
powerSource: Mains (single phase)
softwareBuildID: 2.5.3_r47
stackVersion: 0
type: Router
zclVersion: 3
linkquality: 25
friendly_name: Kitchen Main lights
supported_features: 45
state: 'on'
light.utility_light:
effect_list:
- Night
- Read
- Meeting
- Leasure
- Scenario 1
- Scenario 2
- Scenario 3
- Scenario 4
- Music
supported_color_modes:
- onoff
color_mode: onoff
icon: mdi:light-recessed
friendly_name: Utility Light
supported_features: 4
state: 'on'
switch.kitchen_lights_cabinets:
color_mode: xy
device:
applicationVersion: 67
friendlyName: kitchen_lights_cabinets
ieeeAddr: '0xec1bbdfffeac5165'
manufacturerID: 0
manufacturerName: _TYZB01_iuepbmpv
model: MS-104Z
networkAddress: 15043
powerSource: Mains (single phase)
type: Router
zclVersion: 3
linkquality: 65
power_on_behavior: 'on'
icon: mdi:hockey-puck
friendly_name: kitchen_lights_cabinets
state: 'on'
select.kitchen_lights_cabinets_power_on_behavior:
options:
- 'on'
- 'off'
- previous
color_mode: xy
device:
applicationVersion: 67
friendlyName: kitchen_lights_cabinets
ieeeAddr: '0xec1bbdfffeac5165'
manufacturerID: 0
manufacturerName: _TYZB01_iuepbmpv
model: MS-104Z
networkAddress: 15043
powerSource: Mains (single phase)
type: Router
zclVersion: 3
linkquality: 65
power_on_behavior: 'on'
icon: mdi:power-settings
friendly_name: kitchen_lights_cabinets_power_on_behavior
state: 'on'
switch.kitchen_dining_lights:
device:
applicationVersion: 67
friendlyName: 'Kitchen Dining Lights '
ieeeAddr: '0xec1bbdfffeac531a'
manufacturerID: 0
manufacturerName: _TYZB01_iuepbmpv
model: MS-104Z
networkAddress: 36458
powerSource: Mains (single phase)
type: Router
zclVersion: 3
linkquality: 25
power_on_behavior:
icon: mdi:light-recessed
friendly_name: 'Kitchen Dining Lights '
state: 'on'
select.kitchen_dining_lights_power_on_behavior:
options:
- 'on'
- 'off'
- previous
device:
applicationVersion: 67
friendlyName: 'Kitchen Dining Lights '
ieeeAddr: '0xec1bbdfffeac531a'
manufacturerID: 0
manufacturerName: _TYZB01_iuepbmpv
model: MS-104Z
networkAddress: 36458
powerSource: Mains (single phase)
type: Router
zclVersion: 3
linkquality: 25
power_on_behavior:
icon: mdi:power-settings
friendly_name: Kitchen Dining Lights power on behavior
state: unknown
icon: mdi:weather-sunny
the sensor config output from zigbee2mqtt
{
"battery": 64,
"illuminance": 16697,
"illuminance_lux": 47,
"led_indication": true,
"linkquality": 65,
"motion_sensitivity": "high",
"occupancy": false,
"occupancy_timeout": 0,
"temperature": 19.99,
"update": {
"state": "idle"
}