So I’m trying to make a dummy light that my node-red automations will use to 2-way-mirror a real light. I started out with a template that I was able to set up so it did mirror both ways but then my automations on top of that made for some crazy loops of (for example) changing brightness again and again endlessly. (The long story is that I’m using node-red to make physical dimmers control LIFX bulbs using zwave scene events and I apparently can only control these dimmers physically, so the dummy light is to have something to control from the UI)
So I scrapped the level_template and value_template and now just want it to be dumb from HA’s eyes and I’ll set everything up from Node-Red. The problem is, I’m able to change the brightness on this dummy light but if I try turning off, nothing happens.
light:
- platform: template
lights:
kitchen_island:
friendly_name: "Kitchen Island"
turn_on:
service: light.turn_on
entity_id: light.kitchen_island
turn_off:
service: light.turn_off
entity_id: light.kitchen_island
set_level:
service: light.turn_on
data_template:
brightness: "{{ brightness }}"
entity_id: light.kitchen_island
Again, moving slider, etc works and I can pick up those state changes. But trying to turn off simply doesn’t work (it doesn’t send a state change and also the UI shows the toggle remaining on).
Also, if anyone is curious, below is how I had I set up my template before. It did indeed mirror the level of my dimmer switch correctly and also send movements to it. But again, this messed up some of my other automations (that require combination of z-wave scene activated events and level changes) so I’ll need it to be dumb. This may be useful to future Googlers though because it works well at mirroring another light.
light:
- platform: template
lights:
kitchen_island:
friendly_name: "Kitchen Island"
level_template: >-
{% if states.light.kitchen_island_dimmer_level.attributes.brightness %}
{{states.light.kitchen_island_dimmer_level.attributes.brightness | int}}
{% else %}
0
{% endif %}
value_template: >-
{% if states.light.kitchen_island_dimmer_level.attributes.brightness %}
on
{% else %}
off
{% endif %}
turn_on:
service: light.turn_on
entity_id: light.kitchen_island_dimmmer_level
turn_off:
service: light.turn_off
entity_id: light.kitchen_island_dimmer_level
set_level:
service: light.turn_on
data_template:
brightness: "{{ brightness }}"
entity_id: light.kitchen_island_dimmer_level
Solved it with input-boolean and input-number
input_boolean:
kitchen_island:
input_number:
kitchen_island:
min: 0
max: 255
light:
- platform: template
lights:
kitchen_island:
friendly_name: "Kitchen Island"
turn_on:
service: input_boolean.turn_on
entity_id: input_boolean.kitchen_island
turn_off:
service: input_boolean.turn_off
entity_id: input_boolean.kitchen_island
set_level:
service: input_number.set_value
data_template:
value: "{{ brightness }}"
entity_id: input_number.kitchen_island
7 Likes