Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide indicator when value 0 and entity unavailable #149

Open
i4mr000t opened this issue Mar 7, 2024 · 4 comments
Open

Hide indicator when value 0 and entity unavailable #149

i4mr000t opened this issue Mar 7, 2024 · 4 comments

Comments

@i4mr000t
Copy link

i4mr000t commented Mar 7, 2024

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.

@regevbr
Copy link
Collaborator

regevbr commented Mar 10, 2024

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

@i4mr000t
Copy link
Author

i4mr000t commented Mar 10, 2024

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.

@regevbr
Copy link
Collaborator

regevbr commented Mar 10, 2024

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

@i4mr000t
Copy link
Author

i4mr000t commented Mar 10, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants