jcwillox / lovelace-paper-buttons-row

Adds highly configurable buttons that use actions and per-state styling.
MIT License
310 stars 10 forks source link

--rgb-*-*-color not retrieved automatically for cover-entity (presumably just any (binary) entity that has no 'on'-state) #160

Open arvidc opened 1 year ago

arvidc commented 1 year ago

The problem

Preface: I'm too unfamiliar with github (and especially pull requests) to submit a fix directly. But there is a (possibly partial, not sure if this extends to anywhere else) suggestion below.

Unlike what is suggested here, buttons for my cover entities do not automatically get the same color as --rgb-cover-active-color: https://github.com/jcwillox/lovelace-paper-buttons-row/blob/85524ff488ef024da17365562fe80c8fefad4329/README.md?plain=1#L158

What version of Paper Buttons Row has the issue?

2.1.3

What version of Home Assistant are you running?

2023.10.1

What version of the Frontend are you running?

20231005.0 - latest

Additional information

I believe the issue is that the check here is for stateObj.state === STATE_ON (so it only works with entities that have an "on" active state) instead of STATES_ON.has(stateObj.state) (which includes "on", but also "open" and "unlocked"). https://github.com/jcwillox/lovelace-paper-buttons-row/blob/85524ff488ef024da17365562fe80c8fefad4329/src/main.ts#L422-L424 I made that change locally in "paper-buttons-row.js" (well:Dt.has(r.state); in both instances) and that appears to have fixed it for me.