lovelace-paper-buttons-row
lovelace-paper-buttons-row copied to clipboard
Doesn't not pull color from light entity
Currently on 2021.5, the button doesn't not pull the color for a light entity.
I don't believe it ever did, for simplicity I just use active and inactive colours from the theme, rather than dynamically fetching the colour of a light. That could be a interesting feature to add, for now you could emulate it using Jinja2 templates.
Ah I see. I falsely presumed that it had this feature similarly to custom-button-card and a few others. It would indeed be a great addition.
for now you could emulate it using Jinja2 templates.
@jcwillox , can you please elaborate how can I use Jinja2 templates to emulate the colors? It would be a great feature to have if the buttons could pull light entity colors. Thanks a lot for all your efforts!
This is something that I plan to implement properly into the codebase hopefully with the next release, but here's a very basic snippet to pull the colour from the light, note that it only handles RGB colours and doesn't handle the light being turned off or brightness.
- type: custom:paper-buttons-row
buttons:
- entity: light.monitor_leds
styles:
button:
color: >-
{{ "#%02x%02x%02x" % state_attr("light.monitor_leds", "rgb_color") }}
This is something that I plan to implement properly into the codebase hopefully with the next release, but here's a very basic snippet to pull the colour from the light, note that it only handles RGB colours and doesn't handle the light being turned off or brightness.
- type: custom:paper-buttons-row buttons: - entity: light.monitor_leds styles: button: color: >- {{ "#%02x%02x%02x" % state_attr("light.monitor_leds", "rgb_color") }}
Thanks a lot for this, @jcwillox . To handle the 'off' state, I slightly modified the code and it is working great. Thanks again!
- type: custom:paper-buttons-row
buttons:
- entity: light.monitor_leds
styles:
button:
color: >-
{% if states(config.entity) == 'on' %} {{"#%02x%02x%02x" % state_attr(config.entity, "rgb_color")}} {% else %} {% endif %}
I finally got around to adding support for this, better late then never, am I right 😂.
Check out release 2.0.0.