sockless-coding / panasonic_cc

Panasonic Comfort Cloud - Home Assistant Component
MIT License
144 stars 35 forks source link

Feature request: support for energy module in 2021.8.0 #49

Closed maartenhendrix closed 2 months ago

maartenhendrix commented 3 years ago

Is it possible to add the following sensor attributes to support the new energy integration that is added in HA version 2021.8.0?

https://developers.home-assistant.io/blog/2021/05/25/sensor_attributes/

ugoogalizer commented 3 years ago

Agree this would be good to have the three required attributues added to the energy sensor please. I have been able to hack it for the moment by adding the following to the customize.yaml file:

sensor.aircon_daily_energy:
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy

But it's quite the hack because the energy consumption is reset daily by panasonic_cc (I don't know what impact that has yet). I haven't figured out yet what time of day it resets at (local midnight, UTC midnight) nor I don't think we can use templates in a customization so that means it will stay a hack until it can be added to panasonic_cc.

Note: If it resets at the same time every day, then I imagine it could be managed through creating a new attribute on thge sensor and updating it every time the do_update_energy() call is made within panasonic.py?

maartenhendrix commented 3 years ago

you could probably also use "homeassistant.util.dt.utc_from_timestamp(0)" as suggested by Pascal in: https://github.com/binsentsu/home-assistant-solaredge-modbus/issues/22#issuecomment-893401501

gulli1986 commented 3 years ago

I also support this feature request. However after upgrading to 2021.9.1, it looks like the state_class needs to be 'total_increasing' rather than 'measurement'.

From another entity I have in the energy dashboard: The following entities do not have the expected state class 'total_increasing'

robcoward commented 3 years ago

Agree this would be good to have the three required attributues added to the energy sensor please. I have been able to hack it for the moment by adding the following to the customize.yaml file:

sensor.aircon_daily_energy:
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy

I'm running Home Assistant 2021.9.6 and after applying the above, so far so good - my aircon power usage is now being tracked on the Energy tab :)

purcell-lab commented 3 years ago

To workaround, if you utilise the state_class: total_increasing you no longer require last_rest in customize.yaml, which I understand is the preferred modification.

sensor.panasonic_daily_energy:
   state_class: total_increasing
   device_class: energy

The long term fix is to get the state_class and device_class associated with the sensor in panasonic_cc

Ricks88 commented 3 years ago

Looking for this too!

I see some workarounds here, but where in HA/yaml doe i place this?

robcoward commented 3 years ago

Looking for this too!

I see some workarounds here, but where in HA/yaml doe i place this?

In my setup, I've added these lines to the configuration.yaml file

homeassistant:
  customize: !include customize.yaml

which tell home assistant to read in the customisations from the separate customize.yaml file in the same directory, then in that file I have:

sensor.office_aircon_daily_energy:
  state_class: total_increasing
  device_class: energy

When the comfort cloud API is actually responding, this results in a daily energy 'meter' that can then be added as an individual device on the new Energy tab, or used to graph usage. Recently, I've had to untick the energy sensors option in the integration though as it has been very unreliable.

Ricks88 commented 3 years ago

Looking for this too! I see some workarounds here, but where in HA/yaml doe i place this?

In my setup, I've added these lines to the configuration.yaml file

homeassistant:
  customize: !include customize.yaml

which tell home assistant to read in the customisations from the separate customize.yaml file in the same directory, then in that file I have:

sensor.office_aircon_daily_energy:
  state_class: total_increasing
  device_class: energy

When the comfort cloud API is actually responding, this results in a daily energy 'meter' that can then be added as an individual device on the new Energy tab, or used to graph usage. Recently, I've had to untick the energy sensors option in the integration though as it has been very unreliable.

A lot of the time it can not load the sensor at all, i also need to disable the power sensor or the whole integration wil not load.. Don't know why..

After adding this it again does not load at all.

robcoward commented 3 years ago

A lot of the time it can not load the sensor at all, i also need to disable the power sensor or the whole integration wil not load.. Don't know why..

After adding this it again does not load at all.

I've just tried again in over a week, and it actually loaded the integration with the energy sensor enabled, but more often that not in the last month, like you I've had to disable the option just to get the integration to load and allow me to show / control the actual A/C unit.

Ricks88 commented 3 years ago

A lot of the time it can not load the sensor at all, i also need to disable the power sensor or the whole integration wil not load.. Don't know why.. After adding this it again does not load at all.

I've just tried again in over a week, and it actually loaded the integration with the energy sensor enabled, but more often that not in the last month, like you I've had to disable the option just to get the integration to load and allow me to show / control the actual A/C unit.

Exactly that, but it also does not work in the original panasonic cloud phone app.. I reset the airco from the power and than it mostly works.

Ricks88 commented 3 years ago

But one restart later it does not work anymore

gulli1986 commented 3 years ago

Same here, 90% of the time the last few weeks the energy sensor was not able to load (and the integration will stop loading) so I had to disabled it. I also see that the statistics are not working in the Panasonic app and my guess is that both issues are linked. I don't know if someone has a workaround for this or knows what is happening?

sockless-coding commented 3 years ago

The biggest problem is the Panasonic Cloud, especially the energy request which can take a very long time. And by doing so it brings down the entire HA component. I'm working on a complete rewrite of the component that is not reliant on the pcomfortcloud lib... but unfortunately I haven't had much time to work on it.

Ricks88 commented 3 years ago

Thanks for the update :)

hsmade commented 2 years ago

@sockless-coding Let me know if you want help with refactoring the code. I recently bought 2 aircons, so I will probably bump into the same issues :)

hsmade commented 2 years ago

I created https://github.com/sockless-coding/panasonic_cc/pull/58 to add the state and device class.

TheDK commented 2 years ago

@sockless-coding And just to add an idea for a possibly simple solution: From what I understand the api call for the energy consumption is a) slow und b) does not work if HA is connected to a different IP than the device itself.

As the energy data is not time critical wouldn't it be possible to a) try to retrieve it less often with b) a larger time-out span? If it then comes back empty one could simply try to connect to a different IP address and see if that works.

I looked into getting the energy data with a local solution, but finding an engery meter for 5-10 kW heat pumps isn't that easy, so using the cloud would be great.

Ricks88 commented 2 years ago

any working solution yet? I can not get this to work anymore:

sensor.office_aircon_daily_energy: state_class: total_increasing device_class: energy

sockless-coding commented 2 months ago

Already been addressed in newer versions