StyraHem / ShellyForHASS

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

[BUG] Shelly provides undefined unit_of_measure property #582

Open jpearce73 opened 2 years ago

jpearce73 commented 2 years ago

Environment

Describe the bug

Shelly Motion sensor exports a unit_of_measure property which is null. This trips up the history_graph component which now tries to display a line graph rather than a binary state graph. This report applies to all the binary sensors exported by Shelly (vibration, connected status).

Steps to Reproduce

Click on the entity to bring up details, the graph is a line graph (with no data because value is not numeric)

Expected behavior

Compare to a sonoff motion sensor which does not export unit_of_measure and displays graph correctly

Screenshots

image image

Traceback/Error logs

Additional context

This has shown up recently, within the last few upgrades. It might have been a change to the history_graph that triggered it because I do not see changes to SHelly Motion. But I think root cause is the incorrect export of unit_of_measure.

Vallefor commented 2 years ago

As a workaround I commented this lines and all my motion sensors starts to show right graph https://github.com/StyraHem/ShellyForHASS/blob/a8fc34ce016462f12b73d5e9871fb38553859376/custom_components/shelly/binary_sensor.py#L169-L172

Btw, do not know is it have negative effect on other sensors or not. But binary sensors shouldn't have units of measure.