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

[FEATURE]: Unit kWh not valid for deviceclass power #369

Closed
mvdwetering opened this issue Mar 26, 2023 · 10 comments
Closed

[FEATURE]: Unit kWh not valid for deviceclass power #369

mvdwetering opened this issue Mar 26, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@mvdwetering
Copy link
Contributor

mvdwetering commented Mar 26, 2023

Describe the solution you are looking for

I can't find a template to report a bug so using feature instead. If I need to report it elsewhere please let me know, but since I am using the Stick I suppose it should go here.

Is your feature request related to a problem? (optional)

I just installed the plugwise-beta to use my Plugwise Circle(+) with Home Assistant through the stick. It seems to work as expected, but after enabling all sensors I noticed these errors in the Home Assistant logs menu.

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:669
Integration: Sensor (documentation, issues)
First occurred: 16:47:37 (4 occurrences)
Last logged: 16:47:38

Entity sensor.power_consumption_current_hour_c2434 (<class 'custom_components.plugwise.sensor.USBSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['kW', 'W']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_production_current_hour_c2434 (<class 'custom_components.plugwise.sensor.USBSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['kW', 'W']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_consumption_current_hour_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['kW', 'W']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_production_current_hour_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using native unit of measurement 'kWh' which is not a valid unit for the device class ('power') it is using; expected one of ['kW', 'W']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

It seems to indicate that either the unit or deviceclass for some sensors is wrong.

What type of installation are you running?

Home Assistant OS

How did you install plugwise-beta?

HACS

What kind of Plugwise device is having issues?

USB: Stick

What firmware version is your Plugwise product at?

Circle is at 2011-06-27 10:52:18
Circle+ is at 2011-06-27 10:47:37
Stick I don't know as it is not shown as a device in Home Assistant

Your setup

USB stick, Circle+ and Circle

Additional context

No response

@mvdwetering mvdwetering added the enhancement New feature or request label Mar 26, 2023
@bouwew
Copy link
Contributor

bouwew commented Mar 26, 2023

Thanks, this will be fixed in plugwise-beta v0.34.8, to be released during the coming days.

@bouwew
Copy link
Contributor

bouwew commented Mar 26, 2023

If you want to test, please test the prerelease v0.34.8b2, this version contains the fixes.

@mvdwetering
Copy link
Contributor Author

mvdwetering commented Mar 28, 2023

Unfortunately I did not have time to check this earlier :(

It looks like the previous errors in the log are replaced by different ones:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:497
Integration: Sensor (documentation, issues)
First occurred: 19:56:19 (10 occurrences)
Last logged: 19:56:19

Entity sensor.power_consumption_current_hour_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_production_current_hour_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_consumption_today_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_consumption_previous_hour_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Entity sensor.power_consumption_yesterday_c461b (<class 'custom_components.plugwise.sensor.USBSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

Also happens after removing and re-adding the integration.

@bouwew
Copy link
Contributor

bouwew commented Mar 29, 2023

Ah yes, we have seen this before.
I will remove the device_class so that they can keep the state_class = measurements which means the data can be stored with history.

@mvdwetering
Copy link
Contributor Author

Couldn't it be total_increasing as mentioned in the logs?

Description in developer docs says that is for things like daily amount of gas. I assume these sensors are similar?

I think everything with a state_class goes into history

@bouwew
Copy link
Contributor

bouwew commented Mar 29, 2023

No it can't. These are all sensors that reset/change up or down after a certain time interval. According to the HA documentation they can be Total or None: https://developers.home-assistant.io/docs/core/entity/sensor#available-state-classes

After reading the linked info again I think we should opt for Total. I will look if I can implement/add the last_reset attribute.

@bouwew bouwew reopened this Mar 29, 2023
@bouwew
Copy link
Contributor

bouwew commented Mar 29, 2023

Before I make any more changes, how do the history-graphs of these sensors look like?
One fixed value per hour/day?
Or increasing values per hour/day like this?
image

@mvdwetering
Copy link
Contributor Author

mvdwetering commented Mar 31, 2023

This is how it looks for me on the history page.
plugwise_power

Strangely enough only the "Power consumption current hour" sensor seems to do something (production is expected to do nothing as I don't produce on the plugs). The other consumptions (previous hour/today/yesterday) seem to be stuck at 0. The "day" ones might be due to me reinstalling the integration and it has not been running for a day yet.

Btw, I am not neccesarily interested in all these sensors. I just enabled them all just to see what they do and how they could be used. It looks like if the "current hour" one could be a proper energy sensor in Home Assistant I could get rid of the Integration helper sensor that now calculates energy from the "power usage"

@bouwew
Copy link
Contributor

bouwew commented Mar 31, 2023

Yes, I have enabled some of the sensors in my own system. I see the same for the _current_... and _today_... sensors.
So these will become sensors with state_class measurements.
But I see that the _previous_... sensors are different: the provide one update per time-interval (hour/day). These should become sensors with state_class = Total.

bouwew added a commit that referenced this issue Apr 9, 2023
@bouwew
Copy link
Contributor

bouwew commented Apr 9, 2023

Fixed via #376

@bouwew bouwew closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants