Powercalc - Virtual power sensors

Hi, I just discovered this great integration. Have successfully set it up, but I can’t get the virtual power sensor for WLED to go. It auto-discovers my 2 WLED instances, but after configuring them, the power sensor shows up as “unavailable”. Is the WLED virtual sensor still working? I’m on the latest WLED version.

Please check the error logs for errors or enable Debug logging and check the logs for clues.
When it is still not working please create an issue on github and we will figure out the issue.

1 Like

Hi A question about PowerCalc if you don’t mind……

I have a current sensor (just in one phase) and a ‘number of phases being used’ sensor…… if 1 phase is being used I think PowerCalc will do the job nicely. But sometimes all 3 phases are used - the current is only monitored on one phase, but is the same across all three…. Can I have PowerCalc see my phase sensor says all 3 in use, and multiply the value by 3?

I would like to have a record of total kWh used (totaled) regardless of where the usage was (1 phase or sometimes all 3 phases).

I guess I could create a fake current sensor and multiple my current sensor x 1 if single phase, or x 3 if 3 phase, and pass that fake current value to PowerCalc? I am not sure how to do a fake (modified) current sensor :slight_smile:

Any thoughts appreciated….

Found the problem. I didn’t have the brightness limited enabled in WLED. When the brightness limiter is not enabled, then WLED doesn’t report an estimated current which is need by Powercalc. Maybe this hint could be added to the documentation.

1 Like

You can make a PR if you want to extend the readme with a note. the sources are in docs directory.

Hi,
I get this error in the logs

2023-03-27 14:34:48.999 DEBUG (MainThread) [custom_components.powercalc.discovery] light.schlafzimmer: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Room)
2023-03-27 14:34:49.351 ERROR (MainThread) [custom_components.powercalc.sensors.power] light.schlafzimmer: Skipping sensor setup Model not found in library (manufacturer: Signify Netherlands B.V., model: Room)
2023-03-27 14:34:49.393 ERROR (MainThread) [custom_components.powercalc.sensors.power] light.schlafzimmer: Skipping sensor setup: Model not found in library (manufacturer: Signify Netherlands B.V., model: Room)
2023-03-27 14:34:49.399 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'Gruppe Schlafzimmer Light Gesamt'

But the entities from that group do exist

- platform: powercalc
  create_group: Gruppe Schlafzimmer
  entities:
    - create_group: Gruppe Schlafzimmer Light Gesamt
      entities:
        - entity_id: light.schlafzimmer
    - create_group: Gruppe Schlafzimmer Plugs Gesamt
      entities:
        # HA Plug
        - entity_id: switch.shelly_shplg_s_c8c9a3b8fc80
          power_sensor_id: sensor.shelly_shplg_s_c8c9a3b8fc80_current_consumption
        # PC Plug
        - entity_id: switch.shelly_shplg_s_e868e7ecdcb8
          power_sensor_id: sensor.shelly_shplg_s_e868e7ecdcb8_current_consumption

You must define the individual hue entities, not a room. Powercalc has no way to figure out the underlying room entities and there model information.
It now tries to find a matching model for manufacturer: Signify Netherlands B.V., model: Room resulting in this error. As there is no model Room.

I’m no expert on 3 phase installations, but you are sure the current draw is the same accross all 3 phases? I thought each phase was assigned to different electricity groups and they have different power draw.

Anyway when this is indeed the case for you, you could simply create a template sensor. multiplying the two sensors. I don’t see any added value in using powercalc for that.
Just give it the right device_class and it should just be selectable in the energy dashboard.

Something like this, untested.

template:
  sensor:
    - name: 'Total kWh all phases'
      state: >
        {{ ( states('sensor.total_kwh') | float(0) * 
             states('sensor.num_phases') | float(0) }}
      state_class:  measurement
      device_class: energy
      unit_of_measurement: 'kWh'

Hi Bram

Thank you… I am looking for the energy (kWh) consumed by my EV charger - I am only monitoring the primary phase - which works in single phase charge mode. But when I change to 3 phase charge mode, I need to multiply by 3. And in 3 phase mode all 3 phases are matched :slight_smile:

Thank you for the template sensor - I will use that to calculate total current . But I am sure I will need PowerCalc to take the total current and convert into total kWh consumed…

Ah I see. Don’t know what I was thinking yesterday, but obviously my approach won’t work as it would multiply the total kWh by the num phases used at a given moment.

You can do as follows with powercalc.
Also see Fixed strategy options

sensor:
  - platform: powercalc
    entity_id: sensor.dummy
    name: 'Total power all phases'
    fixed:
      power: "{{ states('sensor.total_power') | float(0) * states('sensor.num_phases') | float(0) }}"
1 Like

Is there a way to add an autodetected entity into a group? I autodetected a Google Home Mini but now I find no way to add it to my group “All Speakers”, and keep getting the error media_player.mini: This entity has already configured a power sensor. When you want to configure it twice make sure to give it a unique_id. Even tried adding the generated power and energy sensors to it.

- create_group: All Speakers
  entities:
    - entity_id: media_player.mini
      name: Mini
      power_sensor_id: sensor.mini_power
      energy_sensor_id: sensor.mini_energy
    - entity_id: media_player.some_other_player_here...

The grouping feature in powercalc is amazing so I assume I am just missing something here

Try omiting the entity_id and name, only referencing the already created power sensors.

- create_group: All Speakers
  entities:
    - power_sensor_id: sensor.mini_power
      energy_sensor_id: sensor.mini_energy
    - entity_id: media_player.some_other_player_here...

Hope this helps.

1 Like

That worked flawlessly, thank you!

1 Like

Hi All,

What’s the easiest way to show the power usage per room. Do I have to create groups or is there a more dynamic way based on the room a device is in?

Thanks,

Rien

See following resources for all possibilities:

So you might also use area:

sensor:
  - platform: powercalc
    create_group: Outdoor
    include:
      area: outdoor
1 Like

Thanks, That suits my needs.

1 Like

By accident i found out, that the “hide_members: true” Switch doesn’t work as i expected - there still are Sensors created for every Member of the given Light-Group.
E.g. In the (Helpers) Light Group light.grp_kitchen_table are those Devices:
light.gu10_01
light.gu10_02
light.gu10_03
light.gu10_04

Where i expected, to only get a Sensor sensor.kitchen_table_lights_energy, additionally sensors for each individual Device get created:
light.gu10_01_energy
light.gu10_02_energy
light.gu10_03_energy
light.gu10_04_energy

Is that, because it is a (Helpers-)Group included, not the individual entities? If so - is that a Bug, or did i forget an important switch?
In Global Configuration, i set enable_autodiscovery: false - it shouldnt be created because of autodiscovery in my Understanding.

Would be awesome if somebody was facing the same behavior and has the magic Hint i missed. In the End i really just need one Sensor for the whole Group :slight_smile:

It is expected that entities are still created for individual devices even if you have hide_members set to true.
This only sets all the member sensors as hidden so they don’t appear in the entity listing in the GUI.
When the entities are not hidden from the UI then it’s a bug, and I suggest to create an issue on github in that case. We will work it out.

1 Like

My Bad. I read it already, but misinterpreted it anyway. So sorry. Thanks for clarifiing! :+1:

1 Like

What would be wrong with this code?

---
powercalc:
  enable_autodiscovery: false
  disable_extended_attributes: true
  energy_sensor_precision: 2
  create_utility_meters: true
  ignore_unavailable_state: true
  energy_sensor_naming: "{} kWh"
  energy_sensor_friendly_naming: "{} Energia consumida"
  utility_meter_types:
    - daily
    - monthly
  utility_meter_offset:
    days: 15
    hours: 10
    minutes: 0

sensor:
  - platform: powercalc
    create_group: Total Devices
    entities:

      - create_group: All Devices
        entities:
          - create_group: Devices Varanda
            include:
              area: varanda
          - create_group: Devices Varanda
            include:
              area: quarto
          - create_group: Devices Cozinha
            include:
              area: cozinha

It’s not creating the entities in HA.