From fd798a8f29efcc90e86c942dcf570687bb05f78f Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Sun, 12 Feb 2017 14:08:16 -0500 Subject: [PATCH] Add device_class support to cover domain (#202) --- src/util/hass-util.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/hass-util.html b/src/util/hass-util.html index 5216fccf17..d5d6bc92d9 100644 --- a/src/util/hass-util.html +++ b/src/util/hass-util.html @@ -350,6 +350,16 @@ window.hassUtil.binarySensorIcon = function (state) { } }; +window.hassUtil.coverIcon = function (state) { + var open = state.state && state.state === 'open'; + switch (state.attributes.device_class) { + case 'garage': + return open ? 'mdi:garage-open' : 'mdi:garage'; + default: + return open ? 'mdi:window-open' : 'mdi:window-closed'; + } +}; + window.hassUtil.stateIcon = function (state) { if (!state) { return window.hassUtil.DEFAULT_ICON; @@ -368,6 +378,8 @@ window.hassUtil.stateIcon = function (state) { } } else if (domain === 'binary_sensor') { return window.hassUtil.binarySensorIcon(state); + } else if (domain === 'cover') { + return window.hassUtil.coverIcon(state); } return window.hassUtil.domainIcon(domain, state.state);