StyraHem / ShellyForHASS

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

Integration is using deprecated `DEVICE_CLASS_*` constants #736

Open frenck opened 1 year ago

frenck commented 1 year ago

Environment

Describe the bug

This custom integration uses deprecated DEVICE_CLASS_* constants in its codebase.

The DEVICE_CLASS_* constants have been deprecated and replaced in Home Assistant Core 2021.12 (over a year ago). I would highly suggest updating/migrating this integration to the new enums.

For example, for the device classes supported by the sensor platform, there is now a SensorDeviceClass enum. So if a sensor previously used the DEVICE_CLASS_ENERGY constant, it should now use SensorDeviceClass.ENERGY. Other platforms (like binary_sensor, and number) provide similar enumerations for their supported device classes.

The migration thus only consists of replacing constants with an enumeration member and is, therefore, very low impact and should be fairly straightforward.

If I can help resolve any questions regarding this change or migration, feel free to ask or respond to this issue. I'm happy to help!

Kindest regards,

../Frenck

Steps to Reproduce

n/a

Expected behavior

n/a

Screenshots

n/a

Traceback/Error logs

n/a

Additional context

n/a

GitHubxtsnl commented 1 year ago

I believe I run into this same issue. running: Home Assistant 2023.2.2 Supervisor 2023.01.1 Operating System 9.5 ShellyForHass: 1.0.2

Logger: homeassistant.helpers.frame
Source: helpers/frame.py:77
First occurred: 3:10:55 PM (2 occurrences)
Last logged: 3:11:14 PM

Detected integration that uses deprecated `async_get_registry` to access entity registry, use async_get instead. Please report issue to the custom integration author for shelly using this method at custom_components/shelly/__init__.py, line 356: await self.hass.helpers.entity_registry.async_get_registry()