Closed shortbloke closed 2 years ago
Agree Issue exists - hope for a solution!
Thanks for reporting guys, unfortunately I can't take a look these days nor test the latest HA. Just by code inspection it's not obvious, I'll need to add some debugging log and see live what happens - or likely involve you if I don't reproduce it with the regular sensor_electricity_energy_today
.
Thanks, looks like a very obvious culprit. I wonder if the logs show anything pointing in that direction, @shortbloke ?
It's somehow weird that a constant stops working because the core had removed it, and yet the integration kind of works...
On Tue, 19 Apr 2022 at 16:15, petitpiton @.***> wrote:
The use of DEVICECLASS constants was deprecated in 2021.12 release. I know the code uses these. Maybe the deprecation has now moved to functionality removed?
https://www.home-assistant.io/blog/2021/12/11/release-202112/#updates-for-custom-integration-developers http://url
— Reply to this email directly, view it on GitHub https://github.com/custom-components/sensor.owlintuition/issues/21#issuecomment-1102710932, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUNRBM35E4QGWNMO4QGQGLVF25ZJANCNFSM5TDEAHOA . You are receiving this because you were assigned.Message ID: @.***>
@glpatcern Not getting any errors in the logs. However comparing the sensors that do work vs those that don't:
Solar Exported Today (not working):
2022-04-19 17:55:11 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.owl_intuition_solar_exported_today, old_state=None, new_state=<state sensor.owl_intuition_solar_exported_today=1.95; unit_of_measurement=kWh, icon=mdi:flash, friendly_name=Solar Exported Today @ 2022-04-19T17:55:11.456695+01:00>>
Solar Exported Today with my template applied (working):
2022-04-19 17:54:04 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.owl_solar_exported_today_template, old_state=None, new_state=<state sensor.owl_solar_exported_today_template=unknown; state_class=total_increasing, unit_of_measurement=kWh, device_class=energy, friendly_name=Owl Solar Exported Today (template) @ 2022-04-19T17:54:04.840644+01:00>>
The non-working sensor lacks device and state class information.
Adding some extra logging to `OwlIntuitionSensor(Entity)::init()
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Battery - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': None, 'state_class': None, 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_battery
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Battery Level - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'battery', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_battery_lvl
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Radio - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'signal_strength', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_radio
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Power - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_power
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Today - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_energy_today
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Cost Today - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': None, 'state_class': None, 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_cost_today
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Solar Generating - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solargen
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Solar Generated Today - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solargen_today
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Solar Exporting - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solarexp
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Solar Exported Today - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solarexp_today
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Power P1 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Today P1 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Power P2 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Today P2 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Power P3 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'power', 'state_class': 'measurement', 'attribution': 'Powered by OWL Intuition'}
2022-04-19 18:38:33 DEBUG (MainThread) [custom_components.owlintuition.sensor] Name: OWL Intuition Electricity Today P3 - self._attrs: {'last_update': None, 'last_reset': None, 'device_class': 'energy', 'state_class': 'total_increasing', 'attribution': 'Powered by OWL Intuition'}
Appears to show the sensors are initialised with the correct device_class
and state_class
The update call seems to be passing the correct info too. I've just deleted and recreated the database (waiting now) to see if that happens to fix it or not.
Thanks @mib1185 I'll take a look. @glpatcern I'll work on refactoring and I'll submit a PR if I can get it working.
Thanks @mib1185 I'll take a look. @glpatcern I'll work on refactoring and I'll submit a PR if I can get it working.
That's OK with me! Given those breaking changes in HA, it should be relatively simple to find what are nowadays the constants to be used to describe state_class
and device_class
valid values.
Glad my hunch was right about the system constants. When will the fix be merged?
@petitpiton indeed, apologies to @shortbloke as I missed the notification of the PR, will comment on that and hopefully merge it right away.
Since updating to 2022.4 (currently on 2022.4.2 - 11 April 2022) the Solar Generating and Exporting data no longer appears to work with the Energy Dashboard. The data is still available as a sensor, but not one that the Energy dashboard can use. The statistics panel reports that they state_class isn't supported:
The entity
sensor.owl_intuition_solar_exported_today
has the following attributes:There isn't a state class attribute
state_class: total_increasing
My Electricity consumption figures continue to work as they are using my template sensors which set the state_class.Looking at the breaking changes in the release, I can't determine which of these is the likely cause of this regression.
Workaround, using template sensor for all sensors used in the Energy Dashboard:
Resulting entity properties (example):