Powercalc - Virtual power sensors

Sorry I miss spelled a word. I meant to say how do you find the on power level of a device and then to the stand-by power levels? Like how do you know what to use for each device you have to manually put in? That make more sense?

Depends on what kind of appliance you are trying to create a virtual power sensor for.
For lights etc. Powercalc provides a measure tool to create the profiles: Measure — Powercalc documentation

When you try to find the power pattern of another type of device you can just temporarily connect a smart plug to it and see in HA what the power consumption is. And then determine if you can virtualize that somehow. When the power consumption fluctuates a lot, you cannot create a virtual sensor for it. For example a refrigerator.

Or you can also use the measure tool which has an option to measure average during X amount of seconds.

  • Turn device off in HA
  • Run measure tool average 30 seconds. This is the standby power
  • Turn device on in HA
  • Run measure tool average 30 seconds. This is the on power
1 Like

Is there a way to add the usage for each color? I have a 2,5 meter led strip with 4 color lines and different consumptions. warm white is different consumption than the RGB white that can be created.

led consumption

You’ll need to use the LUT strategy, and create CSV file using the measure tool to get power levels per brightness / color / color_temperature.

Hello,
i installed PowerCalc and it detects my Ikea smart plug and Tradfri Light.
I also have a Aqara smart plug with integrated power monitoring.
I added the Aqara smart plug direct to the energy dashboard, but the standby power is not considered.

Should i remove the Aqara from the energy dashboard and let PowerCalc calculate everything?
How can i do that with PowerCalc?

Powercalc won’t replace the energy sensor your smart plugs provides. You’ll still need to use that to get the insights in the actual power usage of the connected device.
It can however add an additional sensor with indicates the self usage (standby power) of the smart plug in question.

For a lot of smart plugs files for that are already in the library.

To get support for the Aqara plug, you can make a pull request at powercalc github with a file similarly as this:

You need to provide the figures for standby_power (relay deactivated) and standby_power_on (relay activated). To get that you’ll need a manual power meter, or some other smart plug which is able to measure low power.

1 Like

How to delete a yaml-configured powercalc-group with utility-meters??

Have commented out the yaml and restarted HA, sensors still available :frowning:

Dev-tools Statistics, removed utility-meter statistics
restarted
Sensors still present
restarted
Sensors still present

Have no unique ID’s on them, do I need to re-activate config and add unique ID’s and delete from GUI, or is there something really “stupid simple” that I’ve missed ?

Did you try to refresh your browser. In such cases mist of the time it is only a browser cache problem.

1 Like

You may have to still delete the entities in HA after you comment out the info in the YAML file, I generally do. Comment → Restart HA → Search entities for Powercalc → Delete those in red.

Strange but I think you are right,
The issue was in Dev-tools - States, the sensors was still there, and the timer since last updated was adjusting to when it was commented out/restarted, but still the sensor was present there. But not present in Settings - Devices/services - entities,

So if DNS is not the issue - most likely it is Browser Cashe :wink:

Hi Bram,
This works like expected and I have the room energy sensors.
Now I want to set the room for the sensors, but these sensors have no Unique ID so I cannot set the room.

Any hints or tips to achieve it this?

Thanks,
Rien

You can set a unique_id yourself on the group, see the documentation Sensor configuration — Powercalc documentation

Here’s how I do groups (I have my config set up in packages but the concept is the same and keeps this clean and easy to manage as I use Powercalc on over 100+ devices):

configuration.yaml:

powercalc:
  create_utility_meters: true
  energy_sensor_naming: "{} Powercalc kWh"
  power_sensor_naming: "{} Powercalc [W]"
  enable_autodiscovery: false
  create_energy_sensors: true
  sensors: !include ../entities/powercalc/powercalc_groups.yaml

/entities/powercalc/powercalc_groups.yaml:

- create_group: Whole House Powercalc Grid
  unique_id: 7904f475-2678-4eb4-8efd-ec6941979c7d

  entities:
    #############################################################################
    # LAUNDRY ROOM ENTITIES
    #############################################################################
    - create_group: Laundry Room Power Group
      unique_id: ca89a9ec-c237-4ea8-b788-3807d0168c0a
      entities: !include ../powercalc_areas/laundry.yaml

In that way I create a new file for each room/group, then in each group I define my Powercalc devices, so I have one file per group and each group that points to a file is just another entry under the “entities” in the main group file, in the above example the laundry room group in /entities/powercalc_areas/laundry.yaml:

#----------------------------------------------------------------------------
# WASHING MACHINE (using outlet provided power readings)
#----------------------------------------------------------------------------
- entity_id: switch.washing_machine_switch
  fixed:
    power: >-
      {% set power = float(states('sensor.washing_machine_active_power'), 0) %}
      {{ power if power > 0.01 else 0 }}

I use this method across my entire HA system but it’s particularly useful for Powercalc to keep groups well defined and make it super easy for me to add/remove/adjust each entity that is in that room. I then add those groups to the energy dashboard with the “Whole House Powercalc Grid” as my energy grid and I get my full grid power and then below show each room.

I use Powercalc extensively and last month I was within 20kWh of my energy bill.

1 Like

Thanks this is what I need.

I had performance issues with HA since I created the powercalc sensor group. After some troubleshooting it’s directly related to to powercalc group definition.
This is my configuration:

powercalc:
  create_domain_groups:
    - light
    - media_player
  sensors:
    - create_group: Kantoor
      unique_id: KantoorUsage
      include:
        area: Kantoor

The doamin groups I had for a while, so these are not the issue. But when I add sensor section, I have severe performance issues (I had to reboot every hour)

I found this error in the logging:

The recorder backlog queue reached the maximum size of 97768 events; usually, the system is CPU bound, I/O bound, or the database is corrupt due to a disk problem; The recorder will stop recording events to avoid running out of memory

So it seems that this new powercalc sensor is flooding the recorder

I run HA on a Odroid N2 with SSD with plenty of CPU, Memory and disksize, so it’s not hardware related.

I hope someone can point me in the right direction to solve this?

Hi Rien,
Unfortunate you have performance issues.
State changes of the group sensors should be limited to only once every 30 seconds. To prevent the state machine from overflowing.
Maybe you could enable debug logging for powercalc, hopefully that can provide some starting points to investigate.
Maybe when you have access to the DB you can also have a look into the states table to see if there are too many states written there.

See image below, I could not make een small movie but the “Kantoor Power” is continuous increasing several times per second and it is not representing the total of the 4 sensors above it.
Scherm­afbeelding 2023-11-18 om 13.42.01

That’s very odd, Only kWh (energy) sensor should increase. The grouped power sensor created by Powercalc should just sum the individual power W values.

Could you please check the attributes of that entity in developer tools?
It should list the entities the power sensor exists of. Curious which entities make up your group.

Btw you can also disable that entities being written to that states, so it will cause less data written to the recorder:

Set the following:

powercalc:
    disable_extended_attributes: true

https://homeassistant-powercalc.readthedocs.io/en/latest/configuration/global-configuration.html

But for now it’s useful this information is available to further analyse your issue.

Also please enable debug logging for Powercalc, that would really provide much insights in what is the culprit.

Hi

Are utility meters expected to be created (when the option is toggled) for Groups?

I’m trying to create groups of existing (real) power sensors, flick the “create utility meters” option, but the group is created with a single entity (the sum of the entities in the group) instead of the 4 (that one + the daily, weekly and monhtly meters).

For individual sensors (also using underlaying real sensors) the utility meters are created as expected.

Hi. I am trying to create a PowerCalc sensor which gives the SOLAR Wh of electricity which is supplied to my hot water cylinder (HWC). The HWC has a solar diverter (with SSR) so the Wh is not simply the rating of the element… I think I need something like this in the configuration.yaml:

- entity_id: sensor.dummy
        name: 'HWC Solar Wh'
        fixed:
          power: "{{states('my_calculated_solar_watts')}}"

I am happy with the below logic to calculate ‘my_calculated_solar_watts’ (the watts from solar) - the problem is where to put the below code, and also is the formatting correct? Can I somehow include the below calculations within the above? Or where can I do these calculations?
sensor.phase_1 and sensor.hwc_watts are existing HA sensors…
As you can see, a bit of logic is required to give me the watts that has come from solar…

          if (states('sensor.phase_1') <= 0){                     //all hwc is SOLAR!
            return (states('sensor.hwc_watts') | float(0))
          }    
          else{
            if (states('sensor.phase_1') - states('sensor.hwc_watts') >= 0){   //No solar used
               return (0)
            }
            else{                                                          
               if (states('sensor.hwc_watts') > 5){            //return the solar proportion
                  return ((ABS(states('sensor.phase_1') - states('sensor.hwc_watts') / states('sensor.hwc_watts'))) *  states('sensor.hwc_watts') | float (0))
               }
               else{
                  return (0)
               }               
            }
          }

Thank you for any help!