mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Wait 2 seconds before resetting toggle to current state
This commit is contained in:
parent
ba76dfd3db
commit
a3a1408052
@ -90,11 +90,15 @@ export default new Polymer({
|
|||||||
service = turnOn ? 'turn_on' : 'turn_off';
|
service = turnOn ? 'turn_on' : 'turn_off';
|
||||||
}
|
}
|
||||||
|
|
||||||
const call = this.hass.serviceActions.callService(
|
const currentState = this.stateObj;
|
||||||
domain, service, { entity_id: this.stateObj.entityId });
|
this.hass.serviceActions.callService(domain, service,
|
||||||
|
{ entity_id: this.stateObj.entityId })
|
||||||
if (!this.stateObj.attributes.assumed_state) {
|
.then(() => setTimeout(() => {
|
||||||
call.then(() => this.forceStateChange());
|
// If after 2 seconds we have not received a state update
|
||||||
}
|
// reset the switch to it's original state.
|
||||||
|
if (this.stateObj === currentState) {
|
||||||
|
this.forceStateChange();
|
||||||
|
}
|
||||||
|
}, 2000));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user