Skip to content

Commit

Permalink
Merge pull request #30 from papadi/patch-1
Browse files Browse the repository at this point in the history
Update button state when target entity is a group
  • Loading branch information
finity69x2 authored Dec 13, 2021
2 parents c139ef7 + d1bdfc6 commit df6810d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dist/light-brightness-preset-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CustomLightBrightnessRow extends Polymer.Element {
hassChanged(hass) {

const config = this._config;
const stateObj = hass.states[config.entity];
var stateObj = hass.states[config.entity];
const custTheme = config.customTheme;
const custSetpoint = config.customSetpoints;
const revButtons = config.reverseButtons;
Expand All @@ -140,7 +140,12 @@ class CustomLightBrightnessRow extends Polymer.Element {
const custLowTxt = config.customLowText;
const custMedTxt = config.customMedText;
const custHiTxt = config.customHiText;


// if entity is a group, use the state of the 1st item in the group to read current state (e.g. current brightness)
if (stateObj && stateObj.attributes && Array.isArray(stateObj.attributes.entity_id) && stateObj.attributes.entity_id.length > 0) {
var firstChildEntity_id = stateObj.attributes.entity_id[0];
stateObj = hass.states[firstChildEntity_id];
}

let lowSetpoint;
let medSetpoint;
Expand Down

0 comments on commit df6810d

Please sign in to comment.