Display error icon if unavailable
This commit is contained in:
parent
cedff05684
commit
fefa4e6d5c
|
@ -28,17 +28,11 @@
|
|||
color: #DCC91F;
|
||||
}
|
||||
|
||||
/* Color the icon if entity is offline */
|
||||
ha-state-icon[data-domain=light][data-online=offline],
|
||||
ha-state-icon[data-domain=switch][data-online=offline],
|
||||
ha-state-icon[data-domain=binary_sensor][data-online=offline] {
|
||||
color: #D3D3D3;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<ha-state-icon id='icon' state-obj='[[stateObj]]'
|
||||
data-domain$='[[stateObj.domain]]' data-state$='[[stateObj.state]]' data-online$='[[stateObj.online]]'>
|
||||
data-domain$='[[stateObj.domain]]' data-state$='[[stateObj.state]]'>
|
||||
</ha-state-icon>
|
||||
</template>
|
||||
</dom-module>
|
||||
|
|
|
@ -6,6 +6,9 @@ const { util: { temperatureUnits } } = hass;
|
|||
|
||||
function binarySensorIcon(state) {
|
||||
const activated = state.state && state.state === 'off';
|
||||
if (state.state && state.state === 'unavailable') {
|
||||
return 'mdi:alert-circle-outline';
|
||||
}
|
||||
switch (state.attributes.sensor_class) {
|
||||
case 'opening':
|
||||
return activated ? 'mdi:crop-square' : 'mdi:exit-to-app';
|
||||
|
@ -33,6 +36,8 @@ function binarySensorIcon(state) {
|
|||
export default function stateIcon(state) {
|
||||
if (!state) {
|
||||
return defaultIcon;
|
||||
} else if (state.state && state.state === 'unavailable') {
|
||||
return 'mdi:alert-circle-outline';
|
||||
} else if (state.attributes.icon) {
|
||||
return state.attributes.icon;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue