#Safety device_class is wrong way round....

1 messages · Page 1 of 1 (latest)

strong remnant
#

Every time I use a binary_sensor to positively indicate a safe state, and set the device_class: safety I forget this is not going to work, as it indicates safe as being 'off'.. There is no other device_class with a positive 'on' state indicating that situation, so were left without a class on the subject. Always wonder why this has no class of its own in Home Assistant. Seems so counter intuitive:

Safety 'on' is Unsafe, Safety 'off is Safe ....

btw, not sure of the correct thread here, but as its a frontend thing figured Dahsboard to be the one

orchid fjord
#

Think of it like a warning light. While it's off, there is no issue but when it's on there is an issue. You can always flip the outcome using a template if you want.

strong remnant
#

Yeah I know. My binaries are templates….

#

And I understand the indication of issues perspective. It’s just that I feel we need a positive class too

#

Makes those compound templates much easier too

#

Not to mention the choice of words. Safety is a positive thing so Safety ‘on’ meaning Unsafe is really counterintuitive . That’s what we have Alert for

orchid fjord
#

you could use the Problem class. it's flipped and fits

strong remnant
#

yes, it's flipped alright, as in the word does align with what one expects. I'd still need to rewrite everything because now I use logic based on positive (Safe) , and Problem still would be the other way round. See the image: green binaries are 'on', meaning safe/secured/closed etc. Outside doors are unsafe/insecure/opened

mortal nebula
#

which incorporate device_class?

strong remnant
#

sure I am, and I've set the corresponding theme colors

#

its just that I 'want' my on to be the Safe state, and not the Unsafe state

mortal nebula
#

Right but if you use problem like Sonoma said, you can customize the colors for it to be the opposite

strong remnant
#

no not really, because 'on' would still be the Problem state

#

I have to reverse the complete logic in those templates and automation conditions...

mortal nebula
#

So all you really want is 1 to be safe?

strong remnant
#

yes

mortal nebula
#

and that gets you what? Just the ability to say 'on' in a condition with yaml?

#

Spook has an invert ability

#

You could always use a not condition too

strong remnant
#

they are quite complex```

  • binary_sensor:

    • unique_id: ramen_met_rolluiken_veilig
      state: >
      {{ (
      (is_state('binary_sensor.raam_voorkamer_contact','off') or
      is_state('binary_sensor.gasten','on') or
      state_attr('cover.rolluik_voorkamer','current_position') <= 15)
      and
      (is_state('binary_sensor.raam_logeerkamer_contact','off') or
      is_state('binary.gasten','on') or
      state_attr('cover.rolluik_logeerkamer','current_position') <= 15)
      and
      (is_state('binary_sensor.raam_marte_contact','off') or
      is_state('person.marte','home') or
      state_attr('cover.rolluik_marte','current_position') <= 15)
      and
      (is_state('binary_sensor.raam_studenten_contact','off') or
      is_state('person.louise','home') or
      state_attr('cover.rolluik_studenten','current_position') <= 15) )

         or is_state('input_boolean.negeer_ramen','on')}}
      

device_class: safety ## precies omgekeerd! 'on' betekent onveilig```

mortal nebula
#

Looking through the device classes, none of them have the reverse functionality

strong remnant
#

I check those in my Dashboard glance, like posted above, and they're also used in the automations

mortal nebula
#

right, but the UI translates, so I think that's a moot point

#

You select the word safe, whether it's on or off in yaml is a moot point

strong remnant
#

have a class with reversed functionality. In core

mortal nebula
#

right, then you'll just have to vote for that functionality

#

I don't see it happening anytime soon though

#

easy add, hard to get past the committee

strong remnant
#

there was this 'rule' we couldnt ask for new classes if all they did was be functional in the frontend. Which still is weird to me, because they serve no other purpose

mortal nebula
#

Well that's not so true anymore

#

device_class has other purposes, but just not other purposes in binary_sensor

strong remnant
#

ofc, thats what I meant indeed

#

I can have a discussion on the matter, just so it's registered at least

mortal nebula
#

I'm fairly sure this has already been asked for in Feature Requests

strong remnant
#

maybe even by me.... dont remember exactly, but I keep seeing this during optimizations, and keep forgetting there is no class available.. ill look it up

strong remnant
mortal nebula
#

That's not a frontend FR

strong remnant
#

wdym?

mortal nebula
#

Device_class is a backend function

#

You're asking for backend changes so that you can have the logic inverted

strong remnant
#

O I am sorry, yes let me move it to the community