mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Fix entity-toggle forceStateChange
This commit is contained in:
parent
8e33f925e1
commit
0b04e1e20f
@ -38,11 +38,15 @@ export default new Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateToggle(stateObj) {
|
updateToggle(stateObj) {
|
||||||
this.toggleChecked = stateObj && stateObj.state !== 'off';
|
this.toggleChecked = this._checkToggle(stateObj);
|
||||||
},
|
},
|
||||||
|
|
||||||
forceStateChange() {
|
forceStateChange() {
|
||||||
this.updateToggle(this.stateObj);
|
const newState = this._checkToggle(this.stateObj);
|
||||||
|
if (this.toggleChecked === newState) {
|
||||||
|
this.toggleChecked = !this.toggleChecked;
|
||||||
|
}
|
||||||
|
this.toggleChecked = newState;
|
||||||
},
|
},
|
||||||
|
|
||||||
turn_on() {
|
turn_on() {
|
||||||
@ -60,4 +64,8 @@ export default new Polymer({
|
|||||||
// the resync is not called automatic.
|
// the resync is not called automatic.
|
||||||
serviceActions.callTurnOff(this.stateObj.entityId).then(() => this.forceStateChange());
|
serviceActions.callTurnOff(this.stateObj.entityId).then(() => this.forceStateChange());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_checkToggle(stateObj) {
|
||||||
|
return stateObj && stateObj.state !== 'off';
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user