Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/ha-vacuum-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -27,7 +27,7 @@ const STATES_INTERCEPTABLE = {
},
paused: {
action: 'resume_cleaning',
service: 'start_pause'
service: 'start'
},
};

Expand Down
36 changes: 32 additions & 4 deletions src/dialogs/more-info/controls/more-info-vacuum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down