Need help with entity format

Hi all, I have:

  • 2 Zwave door sensors that are showing in HA as open / closed
  • 2 door sensors (through the Loxone integration) which are showing as on / off
    So if I display the stats of all my doors it looks like this:

…and not uniform for all 4 sensors.

I tried to convert the 2 Loxone sensors to the same format as the Zwave sensors through a helper. But there is no helper that creates a open / closed format.

Does anyone have an idea how I can have 2 Loxone door sensors use the same options (open / close) as the Zwave sensors so all 4 sensors use the same format?

Pretty sure you can just edit the entities in the UI, and change the ‘Show as’ to garage/door. This should change states to be open/closed instead of on/off.

1 Like

I honestly wouldn’t know how to do that. That’s all I get when I click on the entities in the UI - nothing to change…

What do you see when you click the gear icon shown in the upper-right corner?


This…

Looks like you will have to use Customizing Entities to set the binary_sensor’s device_class.

It may still work through the user interface, but you only gave screenshots for the related entities tab, not the settings tab. Try to click settings again.

Do you mean Settings / Entities? This shows the exact same screens

This actually looks really promising. I’ll look at that in detail tomorrow

That is a bug I run into too some times too. Usually if you click the related tab and then settings again, it shows the right tab.

The settings tab on your screenshot above should have a dropdown option for ‘Show as’ where you can select the device class for the entity. That’s assuming you are running a recent version of HA as this feature was only added recently I think. No need for customizing entities which is now yaml only.

This screen? (there is indeed a bug as it’s something showing the wrong “settings” page)
There is no “Show as” - My HA is 2022.6.6 and all integrations are also all up to date.
Have checked some of my other entities (door contacts) where the “Show As” option is being displayed. So it seems this entity in question is not supported.

For comparison:

I played with the entity customization (thanks for the tip) today.

I have referred to: Customizing entities - Home Assistant (home-assistant.io)
and: Customizing entities - Home Assistant (home-assistant.io)

My entry in configuration.yaml now is:

homeassistant:
  customize:
    sensor.balkonture_sz:
      device_class: door
      entity_picture: mdi:door-sliding
    sensor.balkonture_wz:
      device_class: garage_door
      entity_picture: mdi:garage-variant

and it does something to the entities (as the icons for the entities aren’t shown anymore) but it does not change how the the entities are displayed:

Before configuration.yaml entry:
10

After the configuration.yaml entry as per above (which should alter icon and entity type):
11

Any further clues/ideas what I could have done wrong? Are there entities that just can’t be changed?

I’ve also re-explored the path of using a helper but the derivative sensor helper only seems to work for analog sensors…

To change the appearance of the entity’s icon you should use the icon option not entity_picture.

I doubt you’ll be able to set either entity’s device_class to door or garage_door because they are meant for binary_sensor entities not sensors. The available device_classes for sensors is quite different from binary_sensors.

You’re right - this fixes at least the icon… :slight_smile:
Hm… You’re also right on the available device_classes for sensors :frowning:

I finally found a solution. Wrote this template in configuration.yaml:

template:
  - binary_sensor:
      - name: Garage
        state: >
          {% if states("sensor.balkonture_sz") == 'off' %}
            on
          {%- else  %}
            off
          {%- endif %}
      - name: Eingang
        state: >
          {% if states("sensor.balkonture_wz") == 'off' %}
            on
          {%- else  %}
            off
          {%- endif %}
and also:
  customize:
    binary_sensor.eingang:
      device_class: door
      icon: mdi:door
    binary_sensor.garage:
      device_class: garage_door
      icon: mdi:garage-variant

Now the 2 sensors are shown on my UI the same way as others:
20

Was a long way to get here but a nice little research project. Thanks to all contributors who helped me come to this solution, couldn’t have made it otherwise :slight_smile:

I may not be fully awake, but doesn’t that reverse the on/off state? I assume this is intentional, isn’t it? Nicely done, either way. :slight_smile:

Hi Paddy, yes I’ve reversed the on/off state as that type of door sensor goes to ON while closed while my other door sensors go to OFF while closed. Thanks :wink:

1 Like