Custom device classes

Rather than maintaining an ever growing list of binary type device classes to support things like people having windows that open horizontally or gates or mailboxes, etc…

Could a custom device class option be implemented that would be defined something like this:

device_class:
  - binary_sensor:
      - <device_class_name>:
          state_off: <off state word>
          state_on: <on state word>
          icon_off: <mdi icon for off state>
          icon_on: <mdi icon for on state>

All options under name would be optional with undefined options defaulting to the device_class: none states and icons.

e.g.

device_class:
  - binary_sensor:
      - gate:
          state_off: 'Closed'
          state_on: 'Open'
          icon_off: 'mdi:gate'
          icon_on: 'mdi:gate-open'
      - maibox:
          state_off: 'Empty'
          state_on: 'Full'
          icon_off: 'mdi:mailbox'
          icon_on: 'mdi:mailbox-up'

EDIT: Cover and switch device classes too, see post 5 in this FR.

I would also appreciate the ability to use custom device classes like this. I’ve got some binary sensors that don’t fit into the “normal” categories. Some are alarms, some are status (like steam pressure OK vs LOW), and some are RUNNING vs FAULT. Tom has presented a good idea that I could use as-is.

I voted support for this also.

I was only really looking for a way to customise the mdi icons for the binary sensor motion device class.

  • I find the current ones (person and beacony thing with and without a slash) to be busy and not readily discernable.
    But it appears this customisation connot be done.
    I can customise the device class of all my sensors by a glob match… to, say “movement” but then the text isnt quite right.
    I can also do customisation at UI level but its then a per-entity type thing and a lot of work/maintenance.

Toms proposed approach is much more generalised… I think it’s a good idea.

This is a great idea. I was actually searching to see if someone had suggested an active/inactive device_class (of which I would have 3-4 already), but making device_class completely customizable is probably the best option.

A similar method could be used for covers and switches:

device_class:
  - binary_sensor:
      - gate:
          state_off: 'Closed'
          state_on: 'Open'
          icon_off: 'mdi:gate'
          icon_on: 'mdi:gate-open'
      - maibox:
          state_off: 'Empty'
          state_on: 'Full'
          icon_off: 'mdi:mailbox'
          icon_on: 'mdi:mailbox-up'
  - cover:
      - double_garage:
          state_off: 'Closed'
          state_on: Open'
          icon_off: 'mdi:garage-variant'
          icon_on: 'mdi:garage-open-variant'
  - switch:
      - television:
          icon_off: 'mdi:television-classic-off'
          icon_on: 'mdi:television-classic'
1 Like

I’m glad I’m not the only one that would like something like this. I currently have been sifting for an option to show pressed(on) and released(off). Please guys can we fit this in.

any news about it? I think it would be really interesting

Nope. I was hoping there would be a WTH month this year as part of the “streamlining” theme in which I could bring it up. But this has not happened.

Hard to believe this is still not implemented. It’s such a no-brainer. The hard coded device classes are really limiting, considering the amount of novel smart devices entering the market and all the DIY devices around.

2 Likes

I would like to add closing and opening here as well for this FR as this are states with (not that beautiful) icons, etc. for cover as well.