mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Update state-card and more-info card to support new methods. (#1532)
* Update state-card and more-info card to support new start and pause methods * Revert some changes * fixed checking the same thing twice
This commit is contained in:
parent
6bcfdfaaf8
commit
255ea41648
@ -11,11 +11,11 @@ const STATES_INTERCEPTABLE = {
|
||||
},
|
||||
docked: {
|
||||
action: 'start_cleaning',
|
||||
service: 'start_pause'
|
||||
service: 'start'
|
||||
},
|
||||
idle: {
|
||||
action: 'start_cleaning',
|
||||
service: 'start_pause'
|
||||
service: 'start'
|
||||
},
|
||||
off: {
|
||||
action: 'turn_on',
|
||||
@ -27,7 +27,7 @@ const STATES_INTERCEPTABLE = {
|
||||
},
|
||||
paused: {
|
||||
action: 'resume_cleaning',
|
||||
service: 'start_pause'
|
||||
service: 'start'
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -41,9 +41,20 @@ class MoreInfoVacuum extends PolymerElement {
|
||||
<p></p>
|
||||
<div class="status-subtitle">Vacuum cleaner commands:</div>
|
||||
<div class="horizontal justified layout">
|
||||
<div hidden$="[[!supportsPause(stateObj)]]">
|
||||
<paper-icon-button icon="hass:play-pause" on-click="onPlayPause" title="Start/Pause"></paper-icon-button>
|
||||
</div>
|
||||
<template is="dom-if" if="[[supportsStart(stateObj)]]">
|
||||
<div>
|
||||
<paper-icon-button icon="hass:play" on-click="onStart" title="Start"></paper-icon-button>
|
||||
</div>
|
||||
<div hidden$="[[!supportsPause(stateObj)]]">
|
||||
<paper-icon-button icon="hass:pause" on-click="onPause" title="Pause"></paper-icon-button>
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[!supportsStart(stateObj)]]">
|
||||
<div hidden$="[[!supportsPause(stateObj)]]">
|
||||
<paper-icon-button icon="hass:play-pause" on-click="onPlayPause" title="Pause"></paper-icon-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div hidden$="[[!supportsStop(stateObj)]]">
|
||||
<paper-icon-button icon="hass:stop" on-click="onStop" title="Stop"></paper-icon-button>
|
||||
</div>
|
||||
@ -135,12 +146,17 @@ class MoreInfoVacuum extends PolymerElement {
|
||||
return (stateObj.attributes.supported_features & 1024) !== 0;
|
||||
}
|
||||
|
||||
supportsStart(stateObj) {
|
||||
return (stateObj.attributes.supported_features & 8192) !== 0;
|
||||
}
|
||||
|
||||
supportsCommandBar(stateObj) {
|
||||
return (((stateObj.attributes.supported_features & 4) !== 0)
|
||||
| ((stateObj.attributes.supported_features & 8) !== 0)
|
||||
| ((stateObj.attributes.supported_features & 16) !== 0)
|
||||
| ((stateObj.attributes.supported_features & 512) !== 0)
|
||||
| ((stateObj.attributes.supported_features & 1024) !== 0));
|
||||
| ((stateObj.attributes.supported_features & 1024) !== 0)
|
||||
| ((stateObj.attributes.supported_features & 8192) !== 0));
|
||||
}
|
||||
|
||||
/* eslint-enable no-bitwise */
|
||||
@ -171,6 +187,18 @@ class MoreInfoVacuum extends PolymerElement {
|
||||
});
|
||||
}
|
||||
|
||||
onPause() {
|
||||
this.hass.callService('vacuum', 'pause', {
|
||||
entity_id: this.stateObj.entity_id
|
||||
});
|
||||
}
|
||||
|
||||
onStart() {
|
||||
this.hass.callService('vacuum', 'start', {
|
||||
entity_id: this.stateObj.entity_id
|
||||
});
|
||||
}
|
||||
|
||||
onLocate() {
|
||||
this.hass.callService('vacuum', 'locate', {
|
||||
entity_id: this.stateObj.entity_id
|
||||
|
Loading…
x
Reference in New Issue
Block a user