Powercalc - Virtual power sensors

You should check the error logs for clues. Also enable debug logging when still not working.
One thing I notice is you are using utility_meter_offset which is not supported by powercalc (yet).
See here for possible options. Global configuration — Powercalc documentation
When you really need it you’ll need to create the utility meters yourself using the HA helpers section, or create a feature request on the powercalc github. I’ll see if I can add support for that.

Awesome integration - love it! I’ve been using this for a while now and I thought I should try to contribute a couple of lights that I use in my house that are currently unsupported. I’m using a Shelly 1PM for measurements.
I followed the instructions at homeassistant-powercalc/utils/measure at master · bramstroker/homeassistant-powercalc · GitHub to run the measure script in Docker on my Windows machine. That works. However, it takes a silly amount of time to measure a single light (Calex Smart Halo Ceiling Light 292mm) for color temperature only: 12+ hrs. I noticed that the measurements show that the power usage of my light fixture is pretty much independent of the color temperature. So I’d like to tweak the script to take bigger color temperature steps. I tried to install the script native, but I must have missed something. I get:
python3: can't open file 'measure.py': [Errno 2] No such file or directory

I was hoping to find more information at this wiki link that’s referenced in the readme (Home · bramstroker/homeassistant-powercalc Wiki · GitHub), could that link be outdated with the move to readthedocs?

You are sure you are running the script from the correct directory? Looking at the error message it just says the file does not exist.

Anyways, did you change any settings or do you use the default setting? Might be a problem with your smart plug not updating frequently enough causing powercalc to retry each setting a few time.
Normally it should take approx. 2 hours. Not 12 hours.

I love this integration.

Has anyone made a virtual meter for washers and dryers that report states but not actual consumption like Samsung ones? Im guessing you could map the wattage using those variables (like spinning, soaking etc)

See Record / playback energy usage pattern · bramstroker/homeassistant-powercalc · Discussion #1123 · GitHub.
The idea is to record the kWh for a certain washing program one time and just increase the energy sensor with that amount when you see the the program is finished.
You can do that with an automation and a service I added powercalc.daily_energy_increase.
The exact implementation of the automation would depend on your washing machine.

thanks, but i was hoping to track it more while its being used, and not the total amount. but that could be very useful for the total usage.

You can try to map it out, but I don’t think it’s predictable enough. To integrate to kWh correctly without to much deviation the power value in Watt must really be as close to reality as possible.

Here are the power readings of one of my cycles. as you see the power fluctuates a lot especially at the end of the cycle. Even when I can map the beginning of the cycle (this high spikes) and the middle section to some states of my washing machine. The end result would still be off a bit and not really worth the effort.

Here is a screen with the known states (washing, rinse, spin), As you can see it’s not mappable.

yeah, ill buy two extension cords so i can use power sensors on the sockets instead. thx for explaining

Hey. Great plugin!
Has anyone ever tried this with HassWP? Does it work?
I’m having some dificulties adding a simple socket with a powermeter function to get daily energy usage.
I’m only able to add it as a Virtual Power (manual) but the watts keep adding up fast even when Idle is set to 0.
What am I missing?

I have just checked the latest beta and there are massive improvements in this regard.

Now there is a separate page for each integration. In the main integration overview page you see all entities/devices. Clicking the cog will bring you to a separate page where you can configure each separate powercalc config entry.

Integration specific page:

Huge thanks to the HA core devs for this awesome improvement.

2 Likes

I have been using Powercalc for a while now and love it. I have an issue that has come up though with one of my groups. starting on 5/27 the group’s energy sensor has stopped incrementing. The power sensor is still working as expected but the energy sensor has remained flat. Here is my history for the last few weeks:

Does anybody have any suggestions on where to start troubleshooting it at?

There were are lot of changes in the calculation of energy group sensors. Should be all improvements, but in your case seems your energy sensors are somehow misbehaving. Hard to say what goes wrong exactly without any additional information.
Which version of powercalc are you running exactly?

First thing you can do is have a look into the underlying individual energy sensors. Are they increasing correctly as they should?

You can also enable debug logging for powercalc which should give insights into the calculation of the group energy sensor. Whenever one of the individual energy sensors changes state you should see some debug lines in the logs Recalculate and delta for entity which should provide more information as to what exactly goes wrong.

When you can’t work things out with the above suggestions I would suggest to create an issue on github, than we will hopefully be able to fix the issue.

Might also have a look into this issue, Is there a max entities for aggregated groups · Issue #1673 · bramstroker/homeassistant-powercalc · GitHub. Which seems similar to the issue you have. But should be fixed in latest version.

Thanks for the quick response, I am running version 1.6.5.

I have had the log running for a bit and believe I have found the section you are talking about.
https://pastebin.com/J0sBrkAM

Looking at it I think line 6 is where things get interesting. If this does give you some useful information, I can create an issue on github.

The problem is here:

2023-06-07 14:20:00.884 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.living_room_energy: New value: 72.5434
2023-06-07 14:20:00.885 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.living_room_energy: Recalculate, current value: 71.2217

The last is a new recalculation cycle of the group energy sensor.
It starts with 71.2217 there and next it looks at all the individual energy sensors to determine how much needs to be added to the group energy sensor
However it should start this cycle with 72.5434 which is where the last recalculation finished.

I will have a look in the upcoming days to see where the culprit is.

Could you please create an issue on github and also include the output of config/.storage/powercalc_groups?

1 Like

Hi @bramski - I’m two days into HA and I love this powercalc but I can’t find a basic guide where I don’t get an error. I’ve installed HA with docker on my diskstation, so that’s my first nightmare.

I’m trying to edit this configuration.yaml but I’m not sure if I’ve understood properly. When you say Virtual power sensors — Powercalc documentation do you mean the actual config/configuration.yaml or is there one I’m missing from the custom_components/powercalc dir?

I’ve got this from a legend on a fb group:

powercalc:
enable_autodiscovery: true
create_utility_meters: true
utility_meter_types:
- daily
- weekly
- platform: powercalc
entity_id: climate.hot_tub_heater
name: Hot Tub Heater
fixed:
states_power:
hvac_action|idle: 0
hvac_action|cooling: 0
hvac_action|heating: 2000
- platform: powercalc
entity_id: fan.hot_tub_pump_1
name: Hot Tub Pump
fixed:
states_power:
preset_mode|OFF: 0
preset_mode|LO: 400
preset_mode|HI: 2000
hottub_running_cost:
friendly_name: 'Hot Tub Cost'
value_template : "{{ '{:.2f}'.format((states ('sensor.electric_tariff_rate') | float) * ((states ('sensor.hot_tub_pump_energy_daily') | float ) + (states ('sensor.hot_tub_heater_energy_daily') | float ))) | round(2) }}"
unit_of_measurement: "£"
unique_id: hottubcost

but I get errors if I copy it into my configuration.yaml and if I copy it into a yaml/json beautifier. Is there a handy way to check formatting? Also, the location of the configuartion.yaml file - am I being dumb? Even when I click reply, this site can’t ‘fix code’ for me…so I’m a bit lost.

Except the global configuration you can create all the sensors with the GUI.

For YAML it is really important to get the indenting / spacing right, so when you are not proficiant into that I would highly suggest to just use the GUI.

You can put the following in config/configuration.yaml to start with. That enables powercalc and you can restart after that.

powercalc:
  enable_autodiscovery: true
  create_utility_meters: true
  utility_meter_types:
    - daily
    - weekly

Mind the spacing. it’s important.

After restarting maybe powercalc finds some devices on your system for which powercalc has built-in profiles for. That will be auto discovered and you can just click to accept adding the entities to your system.

Next, to add the custom virtual sensors to your system. go to “Settings → Devices & Services”, click “Add integration”, select “Powercalc”.
And follow the steps in the wizard.
For your first example you select “fixed” for strategy.

Hope this helps a bit.

1 Like

Awesome, thanks. I wasn’t sure how to add all that through the GUI - but did it and the power consumption is coming through no problem now. Thanks for the help - and for creating powercalc…it’s genius!

Thanks! Glad you got it working. Have fun with exploring HA.

Hi all,
Added some brand new strategy for you all to play with.
https://homeassistant-powercalc.readthedocs.io/en/latest/strategies/playbook.html

This allows you to record and replay power usage over time.
Can be useful to pre record a washing machine program and replay in HA when the washing machine enters that state.
But there are numerous other use cases thinkable.

Release in v1.7.0-beta.1.

Please let me known any feedback.

3 Likes

Hi! @bramski

I added powercalc intregrated with the configuration:

powercalc:
  enable_autodiscovery: false
  power_sensor_naming: "{} Power"
  create_energy_sensors: true
  energy_sensor_naming: "{} Energy"
  create_utility_meters: false

But it added Device Power and Device Energy sensors to all my Shelly devices (but they already have their own Power and Energy sensors), and it added a Power sensor to my Google speakers, even though auto discovery is off. If I create a configuration for the speakers in powercalc integration, I get two Power sensors, with entity_id one …power the other …power_2.
Why is this the case?