StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
623 stars 112 forks source link

[BUG] Set device_class for temperature sensors #683

Open bcutter opened 2 years ago

bcutter commented 2 years ago

Environment

Describe the bug

According to https://github.com/home-assistant/core/pull/69069 which was shipped with HA 2022.5 (see "Temperature Conversion" in the Breaking Changes section @ https://www.home-assistant.io/blog/2022/05/04/release-20225/#breaking-changes)

Sensors reporting a temperature but not setting device class to temperature will no longer have their values automatically converted.

Currently e. g. all Shelly Plug S providing a "* - Device temperature" sensor seem to be affected by this:

state_class: null
shelly_type: Shelly Plug S
shelly_id: XXXXXX
ip_address: xxx.xxx.xxx.xxx
unit_of_measurement: °C
icon: mdi:oil-temperature
friendly_name: Name - Device temperature

So the needed device_class: temperature is simply missing.

Steps to Reproduce

Expected behavior

Integration temperature sensors are compliant to HA 2022.5 and later.

Screenshots

Traceback/Error logs

Additional context

There seem to be no other negative effects (besides the missing ability to configure the unit of measurement in the UI) and everyone could easily work around this by setting the deviceclass using customize.yaml. But I think the integration should take care of this. ==> Update: setting it using customize.yaml did not change the UI. Maybe the integration has to do this._

From another integration (compliant): grafik

ShellyforHASS integration (missing unit of measurement section ==> Update: same with set parameter using customize.yaml): grafik

haywiremk commented 2 years ago

This is also impacting the H&T devices. I noticed those change from F to C on my graphs. I tried adding settings: temperature: { unit: "°F" }

However still shows as C units. The ShellyForHASS->Settings->Temperature (sample to convert to UI) does show that it read this configuration.yaml setting correctly.