Add device class for low battery (#696)

* Add device class for low battery

* Fix per comments

* Update per comments

* Update per comments

Sorting and revert back to “Normal” for state description

* Fix Travis error
This commit is contained in:
Matt Schmitt 2017-12-06 02:05:30 -05:00 committed by Paulus Schoutsen
parent a061a58494
commit 13f5e33087
3 changed files with 24 additions and 18 deletions

View File

@ -37,14 +37,18 @@
"off": "[%key:state::default::off%]", "off": "[%key:state::default::off%]",
"on": "[%key:state::default::on%]" "on": "[%key:state::default::on%]"
}, },
"moisture": { "battery": {
"off": "Dry", "off": "Normal",
"on": "Wet" "on": "Low"
}, },
"gas": { "gas": {
"off": "Clear", "off": "Clear",
"on": "Detected" "on": "Detected"
}, },
"moisture": {
"off": "Dry",
"on": "Wet"
},
"motion": { "motion": {
"off": "[%key:state::binary_sensor::gas::off%]", "off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]" "on": "[%key:state::binary_sensor::gas::on%]"
@ -53,18 +57,6 @@
"off": "[%key:state::binary_sensor::gas::off%]", "off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]" "on": "[%key:state::binary_sensor::gas::on%]"
}, },
"smoke": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
},
"sound": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
},
"vibration": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
},
"opening": { "opening": {
"off": "Closed", "off": "Closed",
"on": "Open" "on": "Open"
@ -76,6 +68,18 @@
"safety": { "safety": {
"off": "Safe", "off": "Safe",
"on": "Unsafe" "on": "Unsafe"
},
"smoke": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
},
"sound": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
},
"vibration": {
"off": "[%key:state::binary_sensor::gas::off%]",
"on": "[%key:state::binary_sensor::gas::on%]"
} }
}, },
"calendar": { "calendar": {

View File

@ -3,9 +3,9 @@ window.hassAttributeUtil = window.hassAttributeUtil || {};
window.hassAttributeUtil.DOMAIN_DEVICE_CLASS = { window.hassAttributeUtil.DOMAIN_DEVICE_CLASS = {
binary_sensor: [ binary_sensor: [
'connectivity', 'light', 'moisture', 'motion', 'occupancy', 'opening', 'battery', 'cold', 'connectivity', 'gas', 'heat', 'light', 'moisture',
'sound', 'vibration', 'gas', 'power', 'safety', 'smoke', 'cold', 'heat', 'motion', 'moving', 'occupancy', 'opening', 'plug', 'power', 'presence',
'moving', 'plug', 'presence'], 'safety', 'smoke', 'sound', 'vibration'],
cover: ['garage'], cover: ['garage'],
}; };

View File

@ -205,6 +205,8 @@ window.hassUtil.domainIcon = function (domain, state) {
window.hassUtil.binarySensorIcon = function (state) { window.hassUtil.binarySensorIcon = function (state) {
var activated = state.state && state.state === 'off'; var activated = state.state && state.state === 'off';
switch (state.attributes.device_class) { switch (state.attributes.device_class) {
case 'battery':
return activated ? 'mdi:battery' : 'mdi:battery-outline';
case 'connectivity': case 'connectivity':
return activated ? 'mdi:server-network-off' : 'mdi:server-network'; return activated ? 'mdi:server-network-off' : 'mdi:server-network';
case 'light': case 'light':