Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated constants to fix warnings in HA 2024.1 #1287

Merged
merged 4 commits into from
Jan 4, 2024

Conversation

hmmbob
Copy link
Contributor

@hmmbob hmmbob commented Dec 31, 2023

Had these warnings in my logs, which are linked to changes in 2024.1 (https://developers.home-assistant.io/blog/2023/12/19/constant-deprecation/ and https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation/):

2023-12-31 14:43:35.731 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_AUTO was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.AUTO instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.737 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_COOL was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.COOL instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.741 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_DRY was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.DRY instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.745 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_HEAT was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.HEAT instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.749 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_HEAT_COOL was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.HEAT_COOL instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.753 WARNING (MainThread) [homeassistant.components.climate.const] HVAC_MODE_OFF was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use HVACMode.OFF instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.757 WARNING (MainThread) [homeassistant.components.climate.const] SUPPORT_PRESET_MODE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.PRESET_MODE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.762 WARNING (MainThread) [homeassistant.components.climate.const] SUPPORT_TARGET_TEMPERATURE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.766 WARNING (MainThread) [homeassistant.components.climate.const] SUPPORT_TARGET_TEMPERATURE_RANGE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use ClimateEntityFeature.TARGET_TEMPERATURE_RANGE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.771 WARNING (MainThread) [homeassistant.const] TEMP_CELSIUS was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.CELSIUS instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.778 WARNING (MainThread) [homeassistant.components.fan] SUPPORT_PRESET_MODE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use FanEntityFeature.PRESET_MODE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.782 WARNING (MainThread) [homeassistant.components.fan] SUPPORT_SET_SPEED was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use FanEntityFeature.SET_SPEED instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.786 WARNING (MainThread) [homeassistant.components.fan] SUPPORT_PRESET_MODE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use FanEntityFeature.PRESET_MODE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.791 WARNING (MainThread) [homeassistant.components.fan] SUPPORT_SET_SPEED was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use FanEntityFeature.SET_SPEED instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.805 WARNING (MainThread) [homeassistant.const] ELECTRIC_CURRENT_AMPERE was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricCurrent.AMPERE instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.809 WARNING (MainThread) [homeassistant.const] ELECTRIC_POTENTIAL_VOLT was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricPotential.VOLT instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.814 WARNING (MainThread) [homeassistant.const] ENERGY_KILO_WATT_HOUR was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfEnergy.KILO_WATT_HOUR instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.819 WARNING (MainThread) [homeassistant.const] POWER_WATT was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfPower.WATT instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:35.824 WARNING (MainThread) [homeassistant.const] TEMP_CELSIUS was used from sonoff, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.CELSIUS instead, please create a bug report at https://github.com/AlexxIT/SonoffLAN/issues
2023-12-31 14:43:55.538 WARNING (MainThread) [homeassistant.components.light] Entity sonoff.sonoff_1000f7eeca (<class 'custom_components.sonoff.light.XLightL1'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <LightEntityFeature.EFFECT|TRANSITION: 36> and color modes, please create a bug report at /api/sonoff/a97f87d0-f357-4739-b9c8-641792345b61 and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation

With the changes, all warnings are gone. Tested locally, runs fine. I don't have a Sonoff climate device - someone should test this.

Needs HA >2022.5 because of https://developers.home-assistant.io/blog/2022/04/02/support-constants-deprecation/ and https://developers.home-assistant.io/blog/2022/05/03/constants-deprecations/.

Should fix #1278

@hmmbob hmmbob marked this pull request as draft January 1, 2024 13:54
@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 1, 2024

For some reason, my L1 led light isn't working properly anymore with these changes. If I hit the light in HA, it will actually turn on but HA won't show the correct state (looks like it's still off). HA also can't turn it off anymore.

@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 1, 2024

Hmm, looks like that might be unrelated to my changes, as I reverted back to the latest version and that didn't change the issue.

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 2, 2024

But

  • UnitOfEnergy, UnitOfPower, UnitOfTemperature - 2022.11
  • UnitOfElectricCurrent, UnitOfElectricPotential - 2023.1

@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 2, 2024

Yes, you are correct, I missed that. Don't know how you want to go about this? Do you want to keep supporting HA <2023.1, or is it ok to raise the minimum version to that one?

After all, the constant deprecation is valid for a year (final removal in 2025.1), but it will keep filling people's logs with the warning so I would suspect a lot of issues reported.

@hmmbob hmmbob marked this pull request as ready for review January 2, 2024 13:47
@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 2, 2024

I've updated the PR to raise minimum version of HA to 2023.1. That's a year ago already....

@Gzzloveyyt
Copy link

@hmmbob Despite using the code you modified, the lights and switches still cannot synchronize status

@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 4, 2024

@hmmbob Despite using the code you modified, the lights and switches still cannot synchronize status

That is correct, those are unrelated. This is only fixing the lengthy list of warnings in your log.

@AlexxIT AlexxIT merged commit ca812ac into AlexxIT:master Jan 4, 2024
@hmmbob hmmbob deleted the patch-1 branch January 4, 2024 06:50
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 4, 2024

Thanks! I agree that 1 year backward is OK. Support for older versions is very time consuming.

@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 4, 2024

As for the other issues with 2024.1, bdraco has pinpointed where to look.

Screenshot_20240104_075251_Discord

Commenting L40 in entity.py did fix the issue on my side.

As it is a backward compatibility thing for 2021 (and this PR is raising minimum version to 2023), it can probably be gone

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 4, 2024

Backward compatibility fixes break backward compatibility :)

@hmmbob hmmbob mentioned this pull request Jan 4, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 4, 2024

@hmmbob I don't have permissions for writing to beta channel. So it's useless to ping me there :)

@hmmbob
Copy link
Contributor Author

hmmbob commented Jan 4, 2024

Yeah, they closed the channel after the release - no one can write to it currently. I pinged you somewhat before that. But hey at least you saw the info (which I copy-pasted here earlier 😉 )

@yousaf465
Copy link
Contributor

@hmmbob I don't have permissions for writing to beta channel. So it's useless to ping me there :)

beta gets closed when current released is shipped, it will open with next beta.

@AlexxIT AlexxIT added this to the v3.5.4 milestone Jan 4, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 4, 2024

https://github.com/AlexxIT/SonoffLAN/releases/tag/v3.5.4

@clangren
Copy link

clangren commented Jan 4, 2024

Thanks for the update and fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deprecated constants warning which will be removed in HA Core 2025.1
5 participants