mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Display error icon if unavailable
This commit is contained in:
parent
cedff05684
commit
fefa4e6d5c
@ -28,17 +28,11 @@
|
|||||||
color: #DCC91F;
|
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>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ha-state-icon id='icon' state-obj='[[stateObj]]'
|
<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>
|
</ha-state-icon>
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@ -6,6 +6,9 @@ const { util: { temperatureUnits } } = hass;
|
|||||||
|
|
||||||
function binarySensorIcon(state) {
|
function binarySensorIcon(state) {
|
||||||
const activated = state.state && state.state === 'off';
|
const activated = state.state && state.state === 'off';
|
||||||
|
if (state.state && state.state === 'unavailable') {
|
||||||
|
return 'mdi:alert-circle-outline';
|
||||||
|
}
|
||||||
switch (state.attributes.sensor_class) {
|
switch (state.attributes.sensor_class) {
|
||||||
case 'opening':
|
case 'opening':
|
||||||
return activated ? 'mdi:crop-square' : 'mdi:exit-to-app';
|
return activated ? 'mdi:crop-square' : 'mdi:exit-to-app';
|
||||||
@ -33,6 +36,8 @@ function binarySensorIcon(state) {
|
|||||||
export default function stateIcon(state) {
|
export default function stateIcon(state) {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
return defaultIcon;
|
return defaultIcon;
|
||||||
|
} else if (state.state && state.state === 'unavailable') {
|
||||||
|
return 'mdi:alert-circle-outline';
|
||||||
} else if (state.attributes.icon) {
|
} else if (state.attributes.icon) {
|
||||||
return state.attributes.icon;
|
return state.attributes.icon;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user