mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +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';
|
||||
}
|
||||
|
||||
const call = this.hass.serviceActions.callService(
|
||||
domain, service, { entity_id: this.stateObj.entityId });
|
||||
|
||||
if (!this.stateObj.attributes.assumed_state) {
|
||||
call.then(() => this.forceStateChange());
|
||||
const currentState = this.stateObj;
|
||||
this.hass.serviceActions.callService(domain, service,
|
||||
{ entity_id: this.stateObj.entityId })
|
||||
.then(() => setTimeout(() => {
|
||||
// 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