StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
620 stars 111 forks source link

[BUG] binary_sensor defaults to switch icon in Lovelace interface #529

Closed filmgarage closed 3 years ago

filmgarage commented 3 years ago

Environment

Describe the bug

I added the three inputs of the shelly i3 as switches, but they default to a switch icon in Lovelace (mdi:light-switch)

But my inputs are not always fysical switches. I use the i3 to make all kinds of sensors smart: For this use I change the device_class to door, lock, there are plenty types: https://www.home-assistant.io/integrations/binary_sensor/#device-class After changing the device_class the states are right for their type (open/close, wet/dry, locked/unlocked) However the icon does not represent the device_class and remains a 'switch'.

I can change the icon back to a door, lock, etc but In that case we lose the ability to have a "dynamic icon", that changes to show the state of the binary_sensor.

Steps to Reproduce

Expected behavior

Icon of the entity changes to a door that shows open or closed state

mdi:door-closed
mdi:door-open

Screenshots

Traceback/Error logs

No related error logs, I assume that the switch icon is a feature, however it limits the use of the binary_sensor abilities.

Additional context

hakana commented 3 years ago

Try to set the icon to empty and see if that works. I will look into this also but right now I don't have access to the system.

filmgarage commented 3 years ago

I am not sure if I understand you correctly with setting the icon to 'empty'... Like the following in the customize section?

homeassistent:
  customize:
    binary_sensor.some_shelly_switch
      device_class: door
      icon:

I tried this an it has no effect, but maybe I should try something else?

filmgarage commented 3 years ago

Sorry, it took some time to update, working now with the above code!