Add new service clean_spot to vacuums as command in the toolbar (#379)

- Add it with the 'broom' icon between the stop and the locate commands.
- Fix an error in the supportsCommandBar function
This commit is contained in:
Eugenio Panadero 2017-08-06 18:29:50 +02:00 committed by Paulus Schoutsen
parent b34c2a6f92
commit 478f6eb3b1

View File

@ -50,6 +50,10 @@
<paper-icon-button icon='mdi:stop' <paper-icon-button icon='mdi:stop'
on-tap='onStop' title='Stop'></paper-icon-button> on-tap='onStop' title='Stop'></paper-icon-button>
</div> </div>
<div hidden$='[[!supportsCleanSpot(stateObj)]]'>
<paper-icon-button icon='mdi:broom'
on-tap='onCleanSpot' title='Clean spot'></paper-icon-button>
</div>
<div hidden$='[[!supportsLocate(stateObj)]]'> <div hidden$='[[!supportsLocate(stateObj)]]'>
<paper-icon-button icon='mdi:map-marker' <paper-icon-button icon='mdi:map-marker'
on-tap='onLocate' title='Locate'></paper-icon-button> on-tap='onLocate' title='Locate'></paper-icon-button>
@ -136,11 +140,16 @@ Polymer({
return (stateObj.attributes.supported_features & 512) !== 0; return (stateObj.attributes.supported_features & 512) !== 0;
}, },
supportsCleanSpot: function (stateObj) {
return (stateObj.attributes.supported_features & 1024) !== 0;
},
supportsCommandBar: function (stateObj) { supportsCommandBar: function (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 & 8) !== 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));
}, },
/* eslint-enable no-bitwise */ /* eslint-enable no-bitwise */
@ -177,6 +186,12 @@ Polymer({
}); });
}, },
onCleanSpot: function () {
this.hass.callService('vacuum', 'clean_spot', {
entity_id: this.stateObj.entity_id
});
},
onReturnHome: function () { onReturnHome: function () {
this.hass.callService('vacuum', 'return_to_base', { this.hass.callService('vacuum', 'return_to_base', {
entity_id: this.stateObj.entity_id entity_id: this.stateObj.entity_id