mini-climate-card icon indicating copy to clipboard operation
mini-climate-card copied to clipboard

Hide indicator when value 0 and entity unavailable

Open i4mr000t opened this issue 11 months ago • 4 comments

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): IMG_0231

I want to hide that „turbo“ icon when it’s unavailable.

i4mr000t avatar Mar 07 '24 17:03 i4mr000t

It is har to tell but my guess is that you should check if the value is equal to undefined or the string unavailable

regevbr avatar Mar 10 '24 10:03 regevbr

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.

i4mr000t avatar Mar 10 '24 17:03 i4mr000t

try hide: (value) => !(value > 0)

regevbr avatar Mar 10 '24 19:03 regevbr

Thank you very much, I’ll give that a try

Edit: It is working as expected. You can close the issue. THX

i4mr000t avatar Mar 10 '24 19:03 i4mr000t