mini-climate-card
mini-climate-card copied to clipboard
Hide indicator when value 0 and entity unavailable
I tried to hide an indicator when value is 0 and it’s working.
This entity I’m using is a simple power plug and it’s sometimes disconnected so the entity is sometimes unavailable.
is it possible to hide it when value is 0 AND entity is unavailable? I can’t get it to work.
My actual code looks like:
battery: icon: template: '(value) => (value === ''off'' ? ''mdi:battery-low'' : ''mdi:battery-high'' )' style: '(value) => (value === ''off'' ? {color: ''#FD5901''} : {color: ''#008083'' })' source: values: 'off': Voll 'on': Leer entity: binary_sensor.buro_damian_thermostat_batterie mapper: value => this.source.values[value]
My card looks like this when entity is unavailable (mobile):
I want to hide that „turbo“ icon when it’s unavailable.
It is har to tell but my guess is that you should check if the value is equal to undefined
or the string unavailable
just for reference. In my first post I showed the wrong code snippet.
this is the right one for the plug indicator:
booster: icon: template: '(value) => (value <= ''0'' ? ''mdi:fan-off'' : ''mdi:car-turbocharger'' )' style: '(value) => (value <= ''0'' ? {color: ''#FFFFFF''} : {color: ''#008083'' })' unit: W hide: (value) => value <= '0' round: 0 source: entity: sensor.shellyplug_s_5b1e25_power
so I already did hide the icon if the value is 0.
like here hide: (value) => value <= '0'
This is working correctly if the plug is off.
I think I have to add to this code snippet or statement to also hide when it’s unavailable or 0 but I don’t know this type of syntax to add or statements.
try hide: (value) => !(value > 0)
Thank you very much, I’ll give that a try
Edit: It is working as expected. You can close the issue. THX