diff --git a/package.json b/package.json index 381e6e71ff..4bc4cf883c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "author": "Paulus Schoutsen (http://paulusschoutsen.nl)", "license": "MIT", "dependencies": { - "home-assistant-js": "git+https://github.com/balloob/home-assistant-js.git#3a610931d99384bb1d666f022e8ff4ed17595f64", + "home-assistant-js": "git+https://github.com/balloob/home-assistant-js.git#1c29568abc9af18627cd70cab2262b32786cd63d", "lodash": "^3.10.1", "moment": "^2.10.6" }, diff --git a/src/components/entity/ha-entity-toggle.js b/src/components/entity/ha-entity-toggle.js index 59ee410b42..89cabab9b4 100644 --- a/src/components/entity/ha-entity-toggle.js +++ b/src/components/entity/ha-entity-toggle.js @@ -23,11 +23,12 @@ export default new Polymer({ toggleChanged(ev) { const newVal = ev.target.checked; + const curVal = this._checkToggle(this.stateObj); - if (newVal && this.stateObj.state === 'off') { - this.turn_on(); - } else if (!newVal && this.stateObj.state !== 'off') { - this.turn_off(); + if (newVal && !curVal) { + this._call_service(true); + } else if (!newVal && curVal) { + this._call_service(false); } }, @@ -49,23 +50,27 @@ export default new Polymer({ this.toggleChecked = newState; }, - turn_on() { - // We call updateToggle after a successful call to re-sync the toggle - // with the state. It will be out of sync if our service call did not - // result in the entity to be turned on. Since the state is not changing, - // the resync is not called automatic. - serviceActions.callTurnOn(this.stateObj.entityId).then(() => this.forceStateChange()); - }, - - turn_off() { - // We call updateToggle after a successful call to re-sync the toggle - // with the state. It will be out of sync if our service call did not - // result in the entity to be turned on. Since the state is not changing, - // the resync is not called automatic. - serviceActions.callTurnOff(this.stateObj.entityId).then(() => this.forceStateChange()); - }, - _checkToggle(stateObj) { - return stateObj && stateObj.state !== 'off'; + return stateObj && stateObj.state !== 'off' && stateObj.state !== 'unlocked'; + }, + + // We call updateToggle after a successful call to re-sync the toggle + // with the state. It will be out of sync if our service call did not + // result in the entity to be turned on. Since the state is not changing, + // the resync is not called automatic. + _call_service(turnOn) { + let domain; + let service; + + if (this.stateObj.domain === 'lock') { + domain = 'lock'; + service = turnOn ? 'lock' : 'unlock'; + } else { + domain = 'homeassistant'; + service = turnOn ? 'turn_on' : 'turn_off'; + } + + serviceActions.callService(domain, service, {entity_id: this.stateObj.entityId}) + .then(() => this.forceStateChange()); }, }); diff --git a/src/components/entity/ha-state-label-badge.js b/src/components/entity/ha-state-label-badge.js index c3f7dde5f4..7eff163117 100644 --- a/src/components/entity/ha-state-label-badge.js +++ b/src/components/entity/ha-state-label-badge.js @@ -79,7 +79,7 @@ export default new Polymer({ return 'mdi:home-variant'; } // state == 'disarmed' - return 'mdi:lock-open'; + return domainIcon(state.domain, state.state); case 'binary_sensor': case 'device_tracker': case 'scene': diff --git a/src/components/ha-zone-cards.js b/src/components/ha-zone-cards.js index 9f16769768..1a2fd25cf3 100644 --- a/src/components/ha-zone-cards.js +++ b/src/components/ha-zone-cards.js @@ -19,8 +19,6 @@ const PRIORITY = { binary_sensor: 6, scene: 7, script: 8, - thermostat: 40, - media_player: 50, }; function getPriority(domain) { diff --git a/src/util/domain-icon.js b/src/util/domain-icon.js index 260340e556..851ea7d097 100644 --- a/src/util/domain-icon.js +++ b/src/util/domain-icon.js @@ -3,10 +3,10 @@ import defaultIcon from './default-icon'; export default function domainIcon(domain, state) { switch (domain) { case 'alarm_control_panel': - return state && state === 'disarmed' ? 'mdi:lock-open' : 'mdi:lock'; + return state && state === 'disarmed' ? 'mdi:bell-outline' : 'mdi:bell'; case 'binary_sensor': - return state && state === 'off' ? 'mdi:radiobox-blank' : 'mdi:radiobox-marked'; + return state && state === 'off' ? 'mdi:radiobox-blank' : 'mdi:checkbox-marked-circle'; case 'camera': return 'mdi:video'; @@ -29,6 +29,9 @@ export default function domainIcon(domain, state) { case 'light': return 'mdi:lightbulb'; + case 'lock': + return state && state === 'unlocked' ? 'mdi:lock-open' : 'mdi:lock'; + case 'media_player': let icon = 'mdi:cast'; if (state && state !== 'off' && state !== 'idle') { @@ -43,15 +46,6 @@ export default function domainIcon(domain, state) { case 'updater': return 'mdi:cloud-upload'; - case 'sun': - return 'mdi:white-balance-sunny'; - - case 'switch': - return 'mdi:flash'; - - case 'simple_alarm': - return 'mdi:bell'; - case 'scene': return 'mdi:google-pages'; @@ -61,6 +55,15 @@ export default function domainIcon(domain, state) { case 'sensor': return 'mdi:eye'; + case 'simple_alarm': + return 'mdi:bell'; + + case 'sun': + return 'mdi:white-balance-sunny'; + + case 'switch': + return 'mdi:flash'; + case 'thermostat': return 'mdi:nest-thermostat';