bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
906 stars 247 forks source link

Groups don't create daily/weekly/monthly energysensors with create_utility_meters: true #296

Closed NCC1941 closed 2 years ago

NCC1941 commented 2 years ago

Not sure if this is intended behavior or not (or if I've misconfigured something - I'm new to all of this), but I've noticed that powercalc groups don't seem to get the daily/weekly/monthly energy sensors that individual devices get.

My config:

 powercalc:
   scan_interval: 00:01:00 #Each minute
   power_sensor_naming: "{} Powersensor"
   energy_sensor_naming: "{} Energysensor"
   create_utility_meters: true

  - platform: powercalc # Bedroom Lights Power Usage Estimation
    create_group: Bedroom Lights
    entities: 
      - entity_id: light.bedroom_ceiling_light_1
        linear:
          min_power: 0.5
          max_power: 9
        standby_usage: 0.3
      - entity_id: light.bedroom_ceiling_light_2
        linear:
          min_power: 0.5
          max_power: 9
        standby_usage: 0.3

This results in all of the expected powersensors, as well as the following expected energy sensors:

sensor.bedroom_ceiling_light_1_energysensor
sensor.bedroom_ceiling_light_1_energysensor_daily
sensor.bedroom_ceiling_light_1_energysensor_weekly
sensor.bedroom_ceiling_light_1_energysensor_monthly

sensor.bedroom_ceiling_light_2_energysensor
sensor.bedroom_ceiling_light_2_energysensor_daily
sensor.bedroom_ceiling_light_2_energysensor_weekly
sensor.bedroom_ceiling_light_2_energysensor_monthly

sensor.bedroom_lights_energysensor

But the following energysensors are not created:

sensor.bedroom_lights_energysensor_daily
sensor.bedroom_lights_energysensor_weekly
sensor.bedroom_lights_energysensor_monthly

This behavior is consistent across all of the groups I've set up, not just the Bedroom Lights group I used as an example here.

bramstroker commented 2 years ago

This was indeed a bug.

Will be fixed with #298. Doing some final testing now. Also allows you to disable utility meter creation per group. For example:

- platform: powercalc # Bedroom Lights Power Usage Estimation
    create_group: Bedroom Lights
    create_utility_meters: false
    entities: 
      - entity_id: light.bedroom_ceiling_light_1
        linear:
          min_power: 0.5
          max_power: 9
        standby_usage: 0.3
      - entity_id: light.bedroom_ceiling_light_2
        linear:
          min_power: 0.5
          max_power: 9
        standby_usage: 0.3
bramstroker commented 2 years ago

PR has been merged into master. Are you able to test by installing the master branch?

NCC1941 commented 2 years ago

So, I saw that 0.90 was added just a few minutes ago, with this fix, so I installed that via HACS.

...Everything is broken. My HAOS VM install took several minutes to boot (not sure if that's related or how it impacted things - there's nothing in the logs about it that I can find), and almost nothing related to energysensors is working.

The main (not time-resetting) energysensors are broken for every individual device ("This entity is currently unavailable and is an orphan to a removed, changed or dysfunctional integration or device."), and the daily/weekly/monthly energysensors for all individual devices are gone - they just don't exist anymore. This is true even for devices that weren't and aren't in groups.

The group energy sensors that already existed still exist and aren't showing as orphaned, but their state is "Unknown" and they don't seem to still be counting up. Group Daily/Weekly/Monthly energysensors now exist, but are showing 0 and aren't counting up.

All of the powersensors still work.

NCC1941 commented 2 years ago

I've just reverted back to 0.88 (the version I was on prior to 0.90) and everything is fixed. No group daily/weekly/monthly sensors, of course, but everything that worked before is working again.

bramstroker commented 2 years ago

@NCC1941 Yes I see, it's also broken for me it seems. I'm on it.

bramstroker commented 2 years ago

Found the issue. Fix is in master. Could you try again? When everything is working for you as well I'll quickly release 0.9.1.

NCC1941 commented 2 years ago

At a glance, it doesn't seem broken! All of the sensors are present.

I'll report back in a bit, when I can tell for sure whether or not they're all counting up properly.

bramstroker commented 2 years ago

Ok that's good news. Let me know if you experience any issues.

NCC1941 commented 2 years ago

It took a bit to see the group sensors counting up since I'm mostly monitoring small groups of light bulbs (had to wait for a 10Wh increment), but I do now have movement in the energysensors for a few of my larger groups. I'm pretty sure it's all working as it should be.

Thank you!

bramstroker commented 2 years ago

Thanks for verifying. Just released 0.9.1