homeassistant-powercalc: upon restart, many (light) sensors show unavailable

System Health details

no powercalc system health available, as all yaml, and no powercalc integration panel is displayed in the integrations overview

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues

Describe the issue

Scherm­afbeelding 2023-08-24 om 10 05 02 Scherm­afbeelding 2023-08-24 om 10 06 21

even though my main config is set to show 0 in those cases:

powercalc:
  enable_autodiscovery: false
  energy_sensor_naming: '{} device energy'
  power_sensor_naming: '{} device power'
  ignore_unavailable_state: true
  energy_sensor_precision: 2
  unavailable_power: 0
  create_utility_meters: true
  utility_meter_types:
    - daily
    - yearly

  sensors:

using a pure yaml config.At first I believed it to be influenced by turning on/off eg a light, but that didnt make sense, it simply should not do that. It does however, turning on several of the lights, immediately makes them have the device_energy sensors get a state.

the issue also happens for non discovered entities like:

    - entity_id: device_tracker.airport_express_water
      fixed:
        power: 4.1

but they seems to get a value after a minute. Not so for these entities in the screenshot (and a huge amount of others that didnt fit in there…) Scherm­afbeelding 2023-08-24 om 10 28 44

during this writeup, those have now also started showing their value, which is happening after 11 minutes of uptime, and reproducible.

btw, as a side question: could it be the unavailable_power: 0

throws off the utility_meter entities, and the energy panel in HA for that matter, resetting the state_class on energy sensors? Ive seen that a lot lately, and now writing this issue, suddenly realize this might be related? Would it be better to have these sensors be ‘unavailable’ and even though a bit ugly I the dashboard, not have them mess with the internal calculations?

To my understanding the unavailable_power: 0 is in fact only used on those power sensors, and should not interfere at all with energy sensors?

Reproduction steps

  1. restart

Debug logs

return to this later

Diagnostics dump or YAML config

No response

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 16 (14 by maintainers)

Most upvoted comments

@KwisatzJim This isn’t related to that setting in any way. When you change some setting in powercalc GUI configuration this will reload the config entry, and also the entitities are recreated. So the recreation of the energy sensor (integration sensor) will cause it to calculate the new kWh again, making the energy sensor available again.

This issue is really about some energy sensors getting unavailable during startup (but only during startup) and not correctly restored.

We have double checked the same issue arrises when the energy sensor (Riemann sum) is created manually using the helpers section of HA. That ruled out any issues with Powercalc way of creating the energy sensor.

So when you have the same issue at startup I suggest you to join the linked issue and provide debug logs / information there. home-assistant/core#98967

ok thank you for the clarification. I’m only recently getting started with HA and learning all I can. I’ll have a look see at linked issue you gave

Please could you add some findings as codeowner of Powercalc, so at least they understand its not me alone. Tbh, I dont understand why the other issues are closed and not revisited, as this is a completely reproducible issue.

Done