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

POWER_WATT was used from amshan, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfPower.WATT instead #69

Open
lindsand opened this issue Jan 4, 2024 · 5 comments
Assignees

Comments

@lindsand
Copy link

lindsand commented Jan 4, 2024

Warnings after upgrading to HA Core 2024.1.0 4.1.2024

Logger: homeassistant.const
Source: helpers/deprecation.py:204
First occurred: 17:51:09 (17 occurrences)
Last logged: 17:52:52

POWER_WATT was used from amshan, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfPower.WATT instead.

ELECTRIC_CURRENT_AMPERE was used from amshan, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricCurrent.AMPERE instead.

ELECTRIC_POTENTIAL_VOLT was used from amshan, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricPotential.VOLT instead.

ENERGY_KILO_WATT_HOUR was used from amshan, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfEnergy.KILO_WATT_HOUR instead.

@troppavegen84
Copy link

So, where/how do I change this?

@lindsand
Copy link
Author

The values are assigned in sensor.py and field native_unit_of_measurement is the one getting warnings

https://github.com/toreamun/amshan-homeassistant/blob/master/custom_components/amshan/sensor.py

    AmsHanSensorEntityDescription(
        key=obis_map.FIELD_ACTIVE_POWER_EXPORT,
        device_class=SensorDeviceClass.POWER,
        native_unit_of_measurement=ha_const.POWER_WATT,
        state_class=SensorStateClass.MEASUREMENT,
        icon=ICON_POWER_EXPORT,
        name="Active power export (Q2+Q3)",
        decimals=0,
        use_configured_scaling=True,

Valid values are included from HA:
from homeassistant import const as ha_const

so defined here:
https://github.com/home-assistant/core/blob/dev/homeassistant/const.py

...

Power units
class UnitOfPower(StrEnum):
"""Power units."""

WATT = "W"
KILO_WATT = "kW"
BTU_PER_HOUR = "BTU/h"

_DEPRECATED_POWER_WATT: Final = DeprecatedConstantEnum(
UnitOfPower.WATT,
"2025.1",
)
"""Deprecated: please use UnitOfPower.WATT."""
_DEPRECATED_POWER_KILO_WATT: Final = DeprecatedConstantEnum(
UnitOfPower.KILO_WATT,
"2025.1",
)

Electric_current units
class UnitOfElectricCurrent(StrEnum):
"""Electric current units."""

MILLIAMPERE = "mA"
AMPERE = "A"

_DEPRECATED_ELECTRIC_CURRENT_MILLIAMPERE: Final = DeprecatedConstantEnum(
UnitOfElectricCurrent.MILLIAMPERE,
"2025.1",
)
"""Deprecated: please use UnitOfElectricCurrent.MILLIAMPERE."""
_DEPRECATED_ELECTRIC_CURRENT_AMPERE: Final = DeprecatedConstantEnum(
UnitOfElectricCurrent.AMPERE,
"2025.1",
)
"""Deprecated: please use UnitOfElectricCurrent.AMPERE."""

and so on also for the other units.

@lindsand
Copy link
Author

lindsand commented Feb 9, 2024

Here is a related one, total_increasing would be preferred.

Logger: homeassistant.components.sensor
Source: components/sensor/init.py:576
Integration: Sensor (documentation, issues)
First occurred: 16:42:45 (2 occurrences)
Last logged: 16:42:45

Entity sensor.adn9_energy_active_negative (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using;
expected None or one of 'total', 'total_increasing';

Entity sensor.adn9_energy_active_positive (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using;
expected None or one of 'total', 'total_increasing';

@toreamun toreamun self-assigned this Dec 22, 2024
@toreamun toreamun mentioned this issue Dec 23, 2024
@toreamun
Copy link
Owner

Should be fixed in next release.

@crackers81
Copy link

Should be fixed in next release.

When will that air on hacs?

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

No branches or pull requests

4 participants