Powercalc - Virtual power sensors

the way I understand is, is that HA now allows to group children into a parent (Sankey jargon) and calculate the numbers on these parents

this would imply that you should not also use the children individually, as that would double the metrics for those children (or parent depending on your pov)

HA shows missing energy on all entities you set it up for. If you include devices in a parent, but also show them individually, those missing numbers are also doubled.

The way Ive always done it (and not going to change anything in the HA Energy dashboard because of that) is that when I have devices that are plugged into a smart plug and also have their own metering, I use the smart plug.
example:

I use an Ikea Symfonisk on a smartplug (because I want to toggle power to it, and the symfonisk has no built in smart plug obviously). No device strategy required in Powercalc, just meter the consumption perfectly.
Now there is also a Philips Hue light in the Symfonisk, that has a Powercalc strategy available.
But, it is metered on the smart plug, so I exclude that light in the Powercalc calculations.

You can think of more configs like that, or, even have a smart plug on a powerbar, with more than 3 or 4 receptacles all using a metered device.

Cut it short: use the collected metering if you can, or, if you don’t want that ( take it out physically, and meter it independently )

Cut it short 2: mimic real life in powercalc/ energy dashboard, not the other way around :wink:

another good example:
Fibaro plugs, (and several others ) can meter their own device consumption. So, no need to have powercalc calculate that based on the strategies.
When grouping is done the powercalc setup, just dont add those to the device_power group:

Pro-tip: use yaml… it’s a matter of c&p in 1 yaml file to include/exclude/group devices…

1 Like

btw Bram, would this be good for a power profile:

        - entity_id: fan.luchtreiniger_hal
          <<: &ikea_fan
            standby_power: 0.2
            linear:
              attribute: percentage
              calibrate:
                - 1 -> 1.6
                - 10 -> 1.6
                - 20 -> 2.2
                - 30 -> 3.6
                - 40 -> 5.8
                - 50 -> 8.9
                - 60 -> 13
                - 70 -> 18.3
                - 80 -> 21.4
                - 90 -> 24.5
                - 100 -> 24.8

Been using it like that for a few years now and works just fine locally. Figured it could be used by others too if added as a profile into the library?

Not sure if this could be measured using the scripts, so all done manually.

Yes, seems fine to include this in the library. Can you make a PR?
I will consider integrating measuring fans into the measure tool.

uhm, I’d love too, but have not yet figured out how to add this to the model.json correctly:

            standby_power: 0.2
            linear:
              attribute: percentage
              calibrate:
                - 1 -> 1.6
                - 10 -> 1.6
                - 20 -> 2.2
                - 30 -> 3.6
                - 40 -> 5.8
                - 50 -> 8.9
                - 60 -> 13
                - 70 -> 18.3
                - 80 -> 21.4
                - 90 -> 24.5
                - 100 -> 24.8

would this be correct:

{
    "standby_power": 0.2,
    "linear": {
        "attribute": "percentage",
        "calibrate": [
            "1 -> 1.6",
            "10 -> 1.6",
            "20 -> 2.2",
            "30 -> 3.6",
            "40 -> 5.8",
            "50 -> 8.9",
            "60 -> 13",
            "70 -> 18.3",
            "80 -> 21.4",
            "90 -> 24.5",
            "100 -> 24.8"
        ]
    }
}

would result in

{
  "measure_description": "Manually measured",
  "measure_method": "manual",
  "measure_device": "Greenwave GWPN1",
  "name": "STARKVIND Air purifier table",
  "standby_power": 0.2,
    "linear": {
        "attribute": "percentage",
        "calibrate": [
            "1 -> 1.6",
            "10 -> 1.6",
            "20 -> 2.2",
            "30 -> 3.6",
            "40 -> 5.8",
            "50 -> 8.9",
            "60 -> 13",
            "70 -> 18.3",
            "80 -> 21.4",
            "90 -> 24.5",
            "100 -> 24.8"
        ]
    },
  "sensor_config": {
    "power_sensor_naming": "{} Device Power",
    "energy_sensor_naming": "{} Device Energy"
  },
  "device_type": "fan",
  "calculation_strategy": "linear",
  "author": "Mariusthvdb <[email protected]>"
}

?

Close, you should use linear_config, there are multiple in profile library. for example homeassistant-powercalc/profile_library/apple/HomePod Mini/model.json at f33938c7d5e9a543203529100c5720107ecfe100 · bramstroker/homeassistant-powercalc · GitHub

I also need to add device_type fan, as that is not a possible device type in powercalc yet. But makes much sense to add.

Also remove power_sensor_naming override, as these are only meant for the self usage sensors.

argh, I just PR’d Create model.json for STARKVIND Air purifier table by Mariusthvdb · Pull Request #3245 · bramstroker/homeassistant-powercalc · GitHub

let me see if I can change that
done :wink:

Thanks, very clear…
Just a question. You advice me to delete from the powercalc configuration all the children devices, or i need only to not put them in the HA energy dashboard as measured individual devices?

and working nicely!

Apr-18-2025 15-24-44

thanks for updating so fast!

I really love it when we only have to do this:

        - entity_id: fan.luchtreiniger_hal
#           <<: &ikea_fan
#             standby_power: 0.2
#             linear:
#               attribute: percentage
#               calibrate:
#                 - 1 -> 1.6
#                 - 10 -> 1.6
#                 - 20 -> 2.2
#                 - 30 -> 3.6
#                 - 40 -> 5.8
#                 - 50 -> 8.9
#                 - 60 -> 13
#                 - 70 -> 18.3
#                 - 80 -> 21.4
#                 - 90 -> 24.5
#                 - 100 -> 24.8
        - entity_id: fan.luchtreiniger_woonkamer
#           <<: *ikea_fan

Powercalc is an amazing project!

2 Likes

tbh, I cant decide for you. It depends on your preferences, and for example whether you need the individual child entities elsewhere too.

Personally, I dont use the new options for the energy dashboard, as Powercalc is way more powerful/customizable (and provides entities, while the Energy dashboard only provides a Frontend as far as I understand it)

Neither me am using the HA hierarchy, so do you advice me to use the powercalc subtract group option as i think it does the same, but not so sure…

I dont use that either… I have everything metered :wink:
with smartplugs or modes in the central switchboard, or virtual using Powercalc.

the only unused power I have is made up of a few templates, that merely measure measuring inconsistencies

      - unique_id: ongemeten_energie_per_dag
        state: >
          {{states('sensor.energy_consumed_daily')|float -
            states('sensor.gemeten_energie_per_dag')|float}}
        <<: &energy_total
          unit_of_measurement: kWh
          device_class: energy
          state_class: total
        availability: >
          {{has_value('sensor.energy_consumed_daily') and
            has_value('sensor.gemeten_energie_per_dag')}}

I could check if those this can be replaced by Powercalc, but I dont think that will make a lot of difference.

Ok, interesting… but which is the difference between thew two sensors you are using? I tried to translate them and both give me the same…

believe this is getting out of Powercalc territory and more generic energy management measuring.
Essentially it is:
Smart meter provided sensors for total power consumption and return per day. They are perfect by definition

subtract what you have measured and there you have the unmeasured bit…

Thanks for the info… may i ask you about untracked sensors?
I have this entity but really don’t know from where it’s created and which integration is using it.
If i try to have infos i get this window:

It says it’s not available. but i can see it’s consuming power…

you can check that in the entities dashboard
unless it is what I explained above, created by the Energy panel itself

but questions like these should be moved elsewhere in the Community, as not Powercalc related

1 Like

the above discussion on tracked/untracked made me setup my first (…) UI configured Powercalc entities. But I dont think this works out as (I) expected.
Tracked and Untracked show huge numbers, based on the ‘netto’ entity I provided, which is the actual Smart meter reading

note Netto is currently consuming 527 watts

now see what the auto created entities do:

tracked 6383,75 W ??

and untracked -5829.51

the difference between those 2 is about the Netto reading,

but how those big numbers are collected, I dont understand

@bramski Am I right in summarizing the auto mode creation includes all device-class: power entities ?

that would mean that quite a few compound entities are also included, and in fact doubling (or more) the readings of their child entities…

I had hoped we could ‘exclude’ those, but checking the UI option that is not available:

which means I have to ‘include’ all the others which is way more work…

we ‘should’ either have a tag in the yaml to include the entities in the tracked/untracked, or preferably a simple selector in the UI to select entities to exclude from the tracked/untracked systematics. List all ‘power’ entities and add a checkbox?

Would you consider a FR for that?

check several ‘challenges’

the same Solar panels, but different entities, all class power…

also I have many of these current (actueel) and daystart entities, which now are all added to the tracked/untracked entities:

or compounds, already created by Powercalc, and should Not be included, because their children already are…:

Alternative method:

In stead of selecting all individuals, I now tried to include only the grouped entities by Powercalc, which is an easier listing

I can now relate the tracked power to be the return to grid power (well, almost, there must be an entity missing in the group somewhere…or a bit of lag), and the untracked power is showing that

I guess this would be reason to change the request above:

add a flag in the powercalc config to include the grouped entities in the tracked/untracked…


powercalc:
  include_grouped_in_tracked_untracked: true # either set globally

  disable_extended_attributes: true
  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:

    - create_group: Alle schakelaars samen
      include_grouped_in_tracked_untracked: true # or set at group level

      unique_id: powercalc_group_alle_schakelaars_samen
      energy_sensor_naming: '{} totaal'
      power_sensor_naming: '{} actueel'
      utility_meter_types:
        - daily

      entities:
# Shelly
etc etc

The “compound” entities (powercalc groups) should not be included in the tracked power entity when using auto mode.
When it is this is a bug.

I agree it would be nice to exclude specific entities when using auto mode, that would be a possible FR.

You can include specific groups when using manual mode, which you already did now.

I don’t want to add flag for the tracked/untracked sensor in other places than the actual tracked/untracked configuration, as that will make things very complicated in the code.

How can we check that? I only suspected that, because of the extremely high wattage. Has to bee doubling of some sort.

but there is only UI config? If there would be yaml to that would fix it immediately as it would be a simple anchor to copy/paste all relevant entities

I’m struggling to add the energy from a utility meter into a group. I have the following yaml group:

    - create_group: Outside Sockets PC
      entities:
        - power_sensor_id: sensor.circuits_up_4_6_power_a
          energy_sensor_id: sensor.water_heater_circuit_energy
        - power_sensor_id: sensor.circuits_up_10_12_power_a
          energy_sensor_id: sensor.roof_utilities_circuit_energy

And I have a utility meter: sensor.irrigation_energy

I tried adding this to my group:

        - energy_sensor_id: sensor.irrigation_energy

But that throws this error(probably because it doesn’t have an associated power sensor):

Logger: custom_components.powercalc.sensor
Source: custom_components/powercalc/sensor.py:700
integration: Powercalc (documentation, issues)
First occurred: 9:49:05 AM (1 occurrences)
Last logged: 9:49:05 AM

Group state might be misbehaving because there was an error with an entity

Traceback (most recent call last): File “/config/custom_components/powercalc/sensor.py”, line 700, in handle_nested_entity child_entities = await create_sensors( ^^^^^^^^^^^^^^^^^^^^^ …<6 lines>… ) ^ File “/config/custom_components/powercalc/sensor.py”, line 634, in create_sensors return await setup_individual_sensors(hass, config, global_config, config_entry, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/config/custom_components/powercalc/sensor.py”, line 667, in setup_individual_sensors merged_sensor_config = get_merged_sensor_configuration(global_config, config) File “/config/custom_components/powercalc/common.py”, line 148, in get_merged_sensor_configuration raise SensorConfigurationError( “You must supply an entity_id in the configuration, see the README”, ) custom_components.powercalc.errors.SensorConfigurationError: You must supply an entity_id in the configuration, see the README

I am able to sum the sensors in the GUI like this (couldn’t figure out how in yaml):

The problem is that even though this would work going forward, I lose a year’s worth of useful statistics from ‘Outside Sockets PC Energy’ if I now include this new entity in my energy dashboard.

I would greatly appreciate any help I can get with this!!