Powercalc - Virtual power sensors

Hi,
I’m triying to add a multi switch strategy to mesure the power usage of my central boiler (it has 3 Electric resistance heating), I control it with a 4 way switch (ZG-005-RF), the first switch for the on/off heating and the others for each resistances.
When I try to add the multi switch, no power entities are created, but when I try to add a fixed one, it works without problem with each switch.

In configuration.yaml, when I add:

powercalc:
  sensors:
    - name: "Conso Chaudiere"
      multi_switch:
        entities:
          - switch.centrale_chaudiere_commutateur_2
          - switch.centrale_chaudiere_commutateur_3
          - switch.centrale_chaudiere_commutateur_4
        power_off: 0.25
        power: 1700

The power entities are created and works good, but how can i add the trigger with my on/off switch ?

Anything in the logs?

when I try to create multi switch via GUI, I got this :

Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.powercalc.sensors.power
Source: custom_components/powercalc/sensors/power.py:222
intégration: Powercalc (documentation, problèmes)
S'est produit pour la première fois: 18:27:38 (1 occurrences)
Dernier enregistrement: 18:27:38

switch.centrale_chaudiere_commutateur: Skipping sensor setup: Model not found in library (manufacturer: _TZ3000_u3oupgdy, model: TS0004)
Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.powercalc.sensors.power
Source: custom_components/powercalc/sensors/power.py:194
intégration: Powercalc (documentation, problèmes)
S'est produit pour la première fois: 18:27:38 (1 occurrences)
Dernier enregistrement: 18:27:38

switch.centrale_chaudiere_commutateur: Skipping sensor setup: Model not found in library (manufacturer: _TZ3000_u3oupgdy, model: TS0004)
Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.powercalc.sensor
Source: custom_components/powercalc/sensor.py:373
intégration: Powercalc (documentation, problèmes)
S'est produit pour la première fois: 18:27:38 (1 occurrences)
Dernier enregistrement: 18:27:38

No energy sensor created for config_entry 01JAQYFMEJ2QS9GPMDXAKB55EB

could you please create an issue on github and include diagnostics? Click three dots on the config entry and “Dowload diagnostics”.

Done, but I’m not sure if I did it right ^^

I have used a fixed power entity to handle a group of 20 alexa echos for some time. I set this to be 45 watts, and this has always been fine. Now though I have created a template that counts the actual number of echo’s that are online (so that I can unplug some and they automatically stop being counted). I multiply this count by a factor to come up with a total power draw of the online echo devices. I would like to feed the fixed power now based on a value in that template - but I think maybe I’m going about this incorrectly.

        
#   Alexa & Google smart speakers & devices (20 - always on previously) - total fixed energy per day      
      - name: All Alexa & Google Smart speakers
        daily_fixed_energy:
#          value: 45
          value: "{{state_attr('sensor.alexa_echo_online_count','total_echo_power_draw')}}"
          unit_of_measurement: W
          update_frequency: 60

 

What I’m finding is that powercalc continues to use the 45 watt number, even though the current number from the template is 42.

Am I going about this incorrectly?

I see, I don’t think template is re-evaluated for daily fixed mode.
I suggest you to change it to virtual power sensor with fixed mode:
https://docs.powercalc.nl/strategies/fixed/

      - name: All Alexa & Google Smart speakers
        entity_id: sensor.dummy
        fixed:
          value: "{{state_attr('sensor.alexa_echo_online_count','total_echo_power_draw')}}"

This power sensor should react real time to any change in the template.

1 Like

Thank you for this. It worked with one minor change - “value” isn’t allowed under “fixed” - it needs to be “power”.

It seems to work - although an Alexa challenge arose when I went to test - it appears that when you unplug an alexa echo device it remains in “standby” mode for a while (I don’t know how long). Devices that have been unplugged for a few weeks or more all show as unavailable. Going into the Alexa app and trying to do something with the device makes Alexa want to “set it up” - so Alexa recognizes the device isn’t responding - but if I back out of the setup, it still retains the status of “Standby”.

Giving this a full end-to-end test will apparently take some time.

"Nothing is ever easy " (me, 2024) :slight_smile:

Addendum - I tested this the other way around - I took one of my off-line devices and plugged it back in. After asking it a question it went into standby mode. The additional power draw was reflected through the entire chain - so the approach above worked for me. (not if only I could get Alexa to update it’s status information faster…)

Glad you got it working!
My bad I provided you wrong example, but you figured it out :wink:

But only because you gave me the link to the documentation - otherwise I’d still be scratching my head :slight_smile:

thanks again
Ken

Is there anyway to support this Aqara Ceiling Light? I have two of these but I do not have any way to measure the wattage.

I’m using HA 2024.11.3 and Powercalc 1.15.4.
I have a lot of errors in home-assistant.log like these

ERROR (MainThread) [custom_components.powercalc.power_profile.loader.local] Manufacturer does not exist in custom library: lidl
ERROR (MainThread) [custom_components.powercalc.power_profile.loader.local] Manufacturer does not exist in custom library: ikea

I’ve never seen them before
Do you have any suggestions?
Thank you

Please see: Frequently asked questions - Powercalc documentation

Could you try with latest v1.16.0-beta.1? Think that should be fixed in that version.

With v1.16-beta.1 there are no more the previous errors but now there is

ERROR (MainThread) [custom_components.powercalc.power_profile.factory] Problem loading model: Manufacturer WLED not found

It’s a known issue already reported, and probably last thing which needs to be resolved in the beta.

Will have a look upcoming saturday.

You can revert to stable v1.15.5, the error you mentioned before does not break anything functionality wise. It’s just that there is an error logged which shouldn’t be an error.

I have a few powerCalc generated energy sensors that were working fine until recently. Since a few days (probably after the latest updates of PowerCalc and HA Core), I notice sudden jumps in the energy sensor values when the device is turned on. For example, a geyser that has a fixed power of 2000W when “on” and 0 W when “off” registers an energy jump of about 12 kWh the instant it is turned on. After that, it proceeds to increase linearly with time, as expected. So the energy graph shows an unexpected sudden large step at the instant of turning on the appliance. Thereafter, it slopes upwards. Anyone else facing this issue? What may be the reason for this anomaly?

This is the configuration of on of the devices that has the issue:

  {"created_at":"2024-12-09T16:19:30.308830+00:00","data":{"_energy_entity":"sensor.common_geyser_energy","_power_entity":"sensor.common_geyser_powersensor","create_energy_sensor":true,"create_utility_meters":true,"energy_integration_method":"trapezoidal","energy_sensor_unit_prefix":"k","entity_id":"switch.common_bathroom_common_geyser_switch","fixed":{"power":2000.0},"ignore_unavailable_state":true,"mode":"fixed","name":"Common Geyser","sensor_type":"virtual_power","standby_power":0.0,"unavailable_power":0.0,"utility_meter_net_consumption":false,"utility_meter_offset":0.0,"utility_meter_tariffs":[],"utility_meter_types":["daily","weekly","monthly"]},"disabled_by":null,"discovery_keys":{},"domain":"powercalc","entry_id":"01JEP3FYW46XWNCYFXHEDE5AFV","minor_version":1,"modified_at":"2024-12-09T16:19:30.315976+00:00","options":{},"pref_disable_new_entities":false,"pref_disable_polling":false,"source":"user","title":"Common Geyser","unique_id":"50e7d7d2-dd25-40f0-afc2-d6310a20ce76","version":4},

Try/use left.

I would always use left in general. Don’t see any reason to use trapezoidal in HA. As every function in HA is not constantly and state driven, where trapezoidal would be beneficial.

Yes! “Left” seems to solve the issue.
I only applied “Trapezoidal” for entities that have a constant power draw, like resistive loads such as geysers. THe thinking was that the calculation (integral) is more efficient (since it is just the area of a rectangle …).

So is this a bug in the Trapezoidal calculation?

No, it is how Trapezoidal is working.

But as said it is more for real constantly functions in analog world or is you have only a function and not a new state every state change.Or in cases, where you have only states per hour and not per state change. Or if you have sensors wich are near constantly. The it is more accurate than left.

For 99% of HA entities you have a new state every some seconds, left is the better choice. And esp. for on/off entities it is the only choice.