I’m attempting to use my zigbee bulb as a nightlight but it’s connected to a dumb switch. I would like to have it turn on with certain settings during the night and different settings during the day. However, I will not have my phone so will rely on the dumb switch to turn it on. The problem is, the light still shows state “on” when the switch is off because it never has a chance to update. I changed the unavailable limit for mains devices but am not sure if there is a better way to detect it as available/unavailable. Maybe a custom sensor of some sort?
Anyway, here is what I came up with so far but it seems like it may be more complicated than necessary
alias: Nightlght
description: ''
trigger:
- platform: time
at: '21:00:00'
id: Night
- platform: time
at: 06:00:00
id: Morning
- platform: state
entity_id:
- light.master_light_level_light_color_on_off
from: unavailable
to: 'on'
id: Activated
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Morning
sequence:
- service: input_number.set_value
data:
value: 1
target:
entity_id: input_number.light_mode
- conditions:
- condition: trigger
id: Night
sequence:
- service: input_number.set_value
data:
value: 2
target:
entity_id: input_number.light_mode
- conditions:
- condition: trigger
id: Activated
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_number.light_mode
state: '1'
sequence:
- service: light.turn_on
data:
kelvin: 3000
brightness_pct: 100
target:
entity_id: light.master_light_level_light_color_on_off
- service: input_number.set_value
data:
value: 0
target:
entity_id: input_number.light_mode
- conditions:
- condition: state
entity_id: input_number.light_mode
state: '2'
sequence:
- service: light.turn_on
data:
brightness_pct: 10
color_name: darkred
target:
entity_id: light.master_light_level_light_color_on_off
- service: input_number.set_value
data:
value: 0
target:
entity_id: input_number.light_mode
default: []
default: []
mode: single
I attempted to use an input number to determine which light template to use and set it back to 0 so it only activates the first instance after the trigger times. How can I make this work when the dumb switch is used (i.e. the bulb becomes available again)?