olibos/HomeAssistant-RecycleApp

Integration is using deprecated `DEVICE_CLASS_*` constants

Closed this issue Β· 4 comments

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

Hello @frenck ,

I'll change that with the next release.

Thank you for your feedback

Hello @frenck ,

Is there any linting tool from Home Assistant which checks such kind of depreciations?
Or a Github action to validate the code ?

Thank you again for your input πŸ™‚

πŸ‘‹ @olibos,

We have "some" tooling, but not too many (as our primary goal, in general, is maintaining Core itself, of course). We do list changes in the release notes (dev changes, underneath the breaking changes section each release).

We also raise warnings in logs when things deprecate; however, in this case, for constants, that is not possible.

And we publish blog articles on technical changes for developers on our dev blog:

https://developers.home-assistant.io

Anyways, thanks for the migration!

Oh! And a Happy New Year πŸ₯‚

../Frenck

Thank you!

I'll check those resources.

And happy new year to you too πŸ₯‚πŸΎπŸŽ‰