Skip to content

Commit

Permalink
Rework state_icons to use templated state value (fix #51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Jan 8, 2022
1 parent f671d9f commit 28d6f24
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ console.info(
`color: #039be5; background: white; font-weight: 700;`
);

const computeIcon = (state, config) => {
return config.state_icons && config.state_icons[state];
const computeStateIcon = config => {
return config.state_icons && config.state_icons[config.state.toLowerCase()];
};

const computeStateText = config => {
Expand Down Expand Up @@ -283,7 +283,7 @@ export class PaperButtonsRow extends LitElement {
renderIcon(config: ButtonConfig, style, entity?: HassEntity) {
const icon =
config.icon !== false && (config.icon || config.entity)
? computeIcon(entity?.state, config) ||
? computeStateIcon(config) ||
config.icon ||
(entity && stateIcon(entity))
: false;
Expand Down

0 comments on commit 28d6f24

Please sign in to comment.