Dear forum members,
I’m working on a 3D Floorplan for my Lovelace dashboard.
There are a lot of tutorials out there how to edit the raw Lovelace config and so on, but none of them explains how the code for modifying the CSS values on a light status change works.
For my WLED ARGB lamps, I can just use the given example as they are “smart” (they return a status → on/off and which color and brightness etc.)
opacity: >-
${states['light.lamp1'].state === 'on' ?
(states['light.lamp1'].attributes.brightness / 255)
: '0'}
But now there is my problem: I modded a 2,4 GHz remote which was shipped with my two daylight led panels so that I can simulate a button press on it with my ESPHome Wemos D1 Mini and a few optocouplers.
Because another user told me I should try a template, I created a template light:
light:
- platform: template
lights:
wandleuchten:
friendly_name: "Wandleuchten"
value_template: "{{ state_attr('counter.wand_counter', 'value')}}"
turn_on:
service: automation.trigger
target:
entity_id: automation.walllights_on
turn_off:
service: automation.trigger
target:
entity_id: automation.walllights_off
The automations increase/reset the counter before the light switch will be toggled.
But when testing the lovelace card, the following happens:
Video
explanation: the two buttons on the left side (ON and OFF) directly toggle the switch.wandleuchte_on or switch.wandleuchte_off entity, so you can see when they turn yellow → their action is executed
Problem: The toggle in the light card turns itself off after a second without turning off the lights in reallife
EDIT: I fixed the problem by changing the value template as described below and adding the new entity to the entity list of the custom:config-template-card (This was missing in there so the Floorplan would only show the current state of the LED wall panels after a refresh and not “live”)