mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-27 23:07:20 +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: {
|
docked: {
|
||||||
action: 'start_cleaning',
|
action: 'start_cleaning',
|
||||||
service: 'start_pause'
|
service: 'start'
|
||||||
},
|
},
|
||||||
idle: {
|
idle: {
|
||||||
action: 'start_cleaning',
|
action: 'start_cleaning',
|
||||||
service: 'start_pause'
|
service: 'start'
|
||||||
},
|
},
|
||||||
off: {
|
off: {
|
||||||
action: 'turn_on',
|
action: 'turn_on',
|
||||||
@ -27,7 +27,7 @@ const STATES_INTERCEPTABLE = {
|
|||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
action: 'resume_cleaning',
|
action: 'resume_cleaning',
|
||||||
service: 'start_pause'
|
service: 'start'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,9 +41,20 @@ class MoreInfoVacuum extends PolymerElement {
|
|||||||
<p></p>
|
<p></p>
|
||||||
<div class="status-subtitle">Vacuum cleaner commands:</div>
|
<div class="status-subtitle">Vacuum cleaner commands:</div>
|
||||||
<div class="horizontal justified layout">
|
<div class="horizontal justified layout">
|
||||||
<div hidden$="[[!supportsPause(stateObj)]]">
|
<template is="dom-if" if="[[supportsStart(stateObj)]]">
|
||||||
<paper-icon-button icon="hass:play-pause" on-click="onPlayPause" title="Start/Pause"></paper-icon-button>
|
<div>
|
||||||
|
<paper-icon-button icon="hass:play" on-click="onStart" title="Start"></paper-icon-button>
|
||||||
</div>
|
</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)]]">
|
<div hidden$="[[!supportsStop(stateObj)]]">
|
||||||
<paper-icon-button icon="hass:stop" on-click="onStop" title="Stop"></paper-icon-button>
|
<paper-icon-button icon="hass:stop" on-click="onStop" title="Stop"></paper-icon-button>
|
||||||
</div>
|
</div>
|
||||||
@ -135,12 +146,17 @@ class MoreInfoVacuum extends PolymerElement {
|
|||||||
return (stateObj.attributes.supported_features & 1024) !== 0;
|
return (stateObj.attributes.supported_features & 1024) !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportsStart(stateObj) {
|
||||||
|
return (stateObj.attributes.supported_features & 8192) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
supportsCommandBar(stateObj) {
|
supportsCommandBar(stateObj) {
|
||||||
return (((stateObj.attributes.supported_features & 4) !== 0)
|
return (((stateObj.attributes.supported_features & 4) !== 0)
|
||||||
| ((stateObj.attributes.supported_features & 8) !== 0)
|
| ((stateObj.attributes.supported_features & 8) !== 0)
|
||||||
| ((stateObj.attributes.supported_features & 16) !== 0)
|
| ((stateObj.attributes.supported_features & 16) !== 0)
|
||||||
| ((stateObj.attributes.supported_features & 512) !== 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 */
|
/* 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() {
|
onLocate() {
|
||||||
this.hass.callService('vacuum', 'locate', {
|
this.hass.callService('vacuum', 'locate', {
|
||||||
entity_id: this.stateObj.entity_id
|
entity_id: this.stateObj.entity_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user