Tmbao / amberelectric-usages

MIT License
5 stars 1 forks source link

State class not matching device class error #2

Closed mitchellkellett closed 4 months ago

mitchellkellett commented 7 months ago

Having an issue when trying to use this. I've uploaded the amberelectric_usages directory to the custom_components directory. Added the service via Devices & Services > Add Integration, filled in the API Key, selected the NMI, and can see it gets initialised. But no data is ever populated into statistics, the entity never gets any data in it (ie recording the last date time refreshed). I then looked in the logs and I can see the below.

I'm not manually configuring this via the configuration.yaml file, so it can't be that.

Log Output

Entity sensor.[entityid]_usages_latest_time (<class 'custom_components.amberelectric_usages.sensor.AmberUsagesLatestDataSensor'>) is using state class 'measurement' which is impossible considering device class ('timestamp') it is using; expected None; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/Tmbao/amberelectric-usages/issues

Note that I've replaced my actual entityid with [entityid].

Version Info

Core: 2024.1.5 Supervisor: 2023.12.1 Operating System: 11.4 Frontend:20240104.0

Tmbao commented 7 months ago

Hi Mitch, the AmberUsagesLatestDataSensor is basically just a placeholder sensor and not really necessary for the integration to work. Back in the day, I thought it was required to keep the coordinator running, which populates the data to your HA statistics. I could investigate to see whether I can get rid of that placeholder sensor.

In the meantime can you double check if you can see anything like this

image
mitchellkellett commented 7 months ago

Hey, yep. I've got the following: image

Is there a way that I can force it to fetch the data so I can be sure it's working? Or do I have to wait x minutes?

I'm still getting this in the logs though, but from what you says, it's meaningless.

Entity sensor.testing_usages_latest_time (<class 'custom_components.amberelectric_usages.sensor.AmberUsagesLatestDataSensor'>) is using state class 'measurement' which is impossible considering device class ('timestamp') it is using; expected None; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/Tmbao/amberelectric-usages/issues

Tmbao commented 7 months ago

@mitchellkellett not really, but can you try and turn on the debug mode, I think you should be able to see more useful logs to see how things are going. The coordinator is scheduled by HA core, which I configure to run once an hour (often more than enough because amber updates data once a day)

image
Tmbao commented 7 months ago

I just committed 7c44e6ce552a907e6328dbc1d00fba0c9805d941.

It should hopefully fix the annoying error that you're having 🙏 but I couldn't reproduce it on my HAS so I can't confirm for sure