Powercalc - Virtual power sensors

Are you able to test this on your instance as well, by removing device_tracker from manifest.json and restarting HA?

Yes started up okā€¦although I did just realise I am not currently using the device_tracker option as I put a power meter on that device.

Hey! First of all thank you, awesome plugin!

Iā€™m trying to do something but it seems I donā€™t know how!

I have my Smart TV which is connected to the Home Assistant and also i have the Soundbar which is not smart so i have nothing related to it in the home assistant. But the soundbar itā€™s always the same state as the TV.

So I have added a sensor for the TV:

- platform: powercalc
  entity_id: media_player.upstairs_living_tv
  standby_power: 0.5
  fixed:
    power: 100
    states_power:
      source|Live TV: 110
      source|XBOX: 140

And then I wanted to create a new sensor for the Soundbar which uses the state of the same entity_id (the tv) but unfortunately i canā€™t do this.

This is how i tried to do it:

- platform: powercalc
  name: Upstairs Living Soundbar
  unique_id: upstairs_living_soundbar
  entity_id: media_player.upstairs_living_tv
  standby_power: 3.5
  fixed:
    power: 20

Itā€™s there any way I could create this sensor based on the state of TV?

Thank you!

Currently only a single powercalc configuration is allowed per entity_id.

For now you could solve this by introducing a template sensor sensor.upstairs_living_soundbar which just returns the state of media_player.upstairs_living_tv. And than use this template sensor as an input for Upstairs Living Soundbar.
Another approach would be to just add 3.5 to the TV consumption.

I understand your usecase and would be useful if this was supported by powercalc without the need of an extra entity. Could you create a feature request on the github issue tracker for this? I am not sure if I will be able to do it because there is a reason I put this limitation in place.

Perfect! Donā€™t know why I didnā€™t think of that :slight_smile:! Thank you

In the end, maybe is having the same question, i did it like this:

Create a Template Sensor with the same state as the TV

template:
  - sensor:
      - name: Upstairs Living Soundbar
        unique_id: upstairs_living_soundbar
        state: "{{ states('media_player.upstairs_living_tv') }}"   

Then add a powercalc sensor for that entity

- platform: powercalc
  entity_id: sensor.upstairs_living_soundbar
  standby_power: 3.5
  fixed:
    power: 20   
2 Likes

I canā€™t seem to get a group sensor working.

I have the following under sensors:

  - platform: powercalc
    create_group: all kitchen lights
    entities:
      - entity_id: light.kitchen

light.kitchen is a group created by Hue.

I have auto discovery enabled in global config, so i donā€™t have defined entities for each light:

powercalc:
  enable_autodiscovery: true
  scan_interval: 00:01:00 #Each minute
  create_energy_sensors: true
  create_utility_meters: true
  utility_meter_types:
    - hourly
    - daily
    - weekly
    - monthly
    - yearly

Could this be causing the issue?

My understanding is that i should get a sensor.all_kitchen_lights_power ?

Edit: Iā€™ve just tried with an entity for one of the lights rather than a group of lights and that appeared to work fine.

The create_group purpose is to create an aggregate power and energy sensor for all underlying individual entities. As you already discovered entity_id always must be an individual light.
With the include functionality you have an option to automatically include all entities of a light group, but I am not sure if this is working for Hue groups already. Could be that it only works for native HA light groups. I am unable to test this atm, but will have a look into that because that seems useful to me.

Thanks for the quick reply.

I could probably get away with include area, i can see include group would require setting up a group config which would probably add more lines to the config than just adding the individual light entities.

Just wanted to let you know I added a new function to powercalc which will make your life easier.

Now itā€™s possible with a one liner to create a group sensor for all powercalc entities of a given domain, for example ā€œlightā€.

You can do that as follows:

powercalc:
  create_domain_groups:
    - light

This will create a sensor ā€œAll light powerā€, and also energy and utility_meters.

Has been released in latests beta v0.19.0-beta.2.

Btw. this will add ALL lights to the group sensor. When you want more granular control you need to use the existing way to create groups.

2 Likes

Hi bramski, thanks for this, it was exactly what I have been looking for!

I have just updated to v0.19.0-beta.2 and added that to my config and it has created the new group total entity.

I canā€™t seem to use the group on the energy dashboard since it doesnā€™t seem to have a corresponding ā€œstatisticā€. All the other ā€œenergyā€ entities added by powercalc have statistics.

You have to wait a bit to have statistics gathered. Should appear after an hour or something like that. Does it work now?

Unfortunately not, all other powercalc energy entities have statistics, but not the powercalc.all_light_energy one.

Hmm ok. Could you create an issue on github please? Will have a look into this next weekend.

1 Like

@Fillius I have create the github issue Fix grouped domain sensor in energy dashboard by bramstroker Ā· Pull Request #621 Ā· bramstroker/homeassistant-powercalc Ā· GitHub. Was able to reproduce this issue and have a potential fix. I am testing this currently, need to wait a bit to check if its working.
Keep your eye on the v0.19 beta releases.

1 Like

Thatā€™s perfect thanks, I hadnā€™t had chance to get on my desktop to create it yet.

Iā€™ll keep an eye out.

Iā€™ve just updated to beta 7 and itā€™s now fixed and working. The statistic exists and can be added to the energy dashboard.

Thanks for looking at this.

I have no questions, problems or requests. I just wanted to thank you for this awesome component. Itā€™s a leap forward to monitoring my energy consumption. Would love to see it incorporated into the main home assistant repository.
Edit: nevermind the core integration, saw your comment and completely understand!

2 Likes

Thanks for your kind words. I have no plans to get this incorporated in the HA repository as this would take a great amount of effort, and also I want to keep the component fast moving.

Just wanted to let you guys know we have hit the 100 supported lights mark, which is a huge milestone for the project.
I want to thank all contributers for their efforts. Keep them coming.

6 Likes

This integration is absolutely fantastic, Iā€™ve got a load of Hue lights and itā€™s autodiscovered almost all of them and data is coming into HA. Perfect!

Iā€™ve been checking out the documentation and trying to use a combination of nesting and HA Light Groups to create my power/energy config. Just wondered if this was supposed to be possible as when I add the following to my sensor config the integration breaks.


sensor:
  - platform: powercalc
    create_group: All Lights Energy
    entities:
     - create_group: Downstairs Lights Energy
       entities:
         - create_group: Living Room Lights Energy
           include:
             group: light.hue_living_room_lights
         - create_group: Kitchen Lights Energy
           include:
             group: light.kitchen_lights
     - create_group: Upstairs Lights Energy
       entities:
         - create_group: Bedroom Lights Energy
           include:
             group: light.bedroom
         - create_group: Bedroom2 Lights Energy
           include:
             group: light.bedroom2

Hopefully itā€™s just me screwing up the code but this would be super helpful in my setup.
Cheers
Spence