Powercalc - Virtual power sensors

ofc I had to find that…
wel glad I did and you could fix it:

before, b4:

after, b5:

data: folder in /custom_components/powercalc disappeared :wink:

I do believe I found different power measurements myself:

             standby_power: 0.5
             fixed:
               power: 0.8

Oh great you got it working.

For which did you have these measurements Plug s or Plus Plug S?
I see for the measurements AWM Fitzdirect was used: homeassistant-powercalc/profile_library/shelly/shelly plus plug s/model.json at 973005c3d5a1d1b43604117af179721f3c132e7c · bramstroker/homeassistant-powercalc · GitHub

Which power meter did you use? When yours is more accurate we can update the measurements in the library.

for the Plus Plug s, and non scientific… I used another Shelly. those readings were consistent over various devices though, and also consistent with the Plug s readings in the library. Those are seen here too, so I figured the Plus Plug s measurement to be correct too.

But… it might depend on other settings in the device as the Plus Plug S is also a Bt extender. depending on the configuration that could make a difference:

but I dont think we can set that in the config as its not an option we can ‘read’

As said, I also have this reading for the Shelly Plus 1PM, which isnt yet in the library

I don’t have one myself, so can’t do some testing or verify. Maybe I will purchase one.
I have a Zhurui PR10 meter which is very accurate also on low power levels, so than I also can do some verifications.

1 Like

Hi All,

Can someone explain how to use the “Calculation enabled condition”?

I am trying to get a fixed energy value when my climate device (climate.living_ac) is running.

Any experience with this?

Having some issues with the new beta, shall I raise an issue in github?

image

This error originated from a custom integration.

Logger: custom_components.powercalc.power_profile.loader.remote
Source: custom_components/powercalc/power_profile/loader/remote.py:51
integration: Powercalc (documentation, issues)
First occurred: 4:32:20 PM (1 occurrences)
Last logged: 4:32:20 PM

Failed to download library.json from github, falling back to local copy
Logger: homeassistant.setup
Source: setup.py:398
First occurred: 4:32:20 PM (1 occurrences)
Last logged: 4:32:20 PM

Error during setup of component powercalc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 398, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/powercalc/__init__.py", line 238, in async_setup
    await discovery_manager.start_discovery()
  File "/config/custom_components/powercalc/discovery.py", line 123, in start_discovery
    power_profile = await self.get_power_profile(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/discovery.py", line 144, in get_power_profile
    self.power_profiles[entity_id] = await get_power_profile(
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/factory.py", line 39, in get_power_profile
    library = await ProfileLibrary.factory(hass)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/library.py", line 64, in factory
    await library.initialize()
  File "/config/custom_components/powercalc/power_profile/library.py", line 35, in initialize
    await self._loader.initialize()
  File "/config/custom_components/powercalc/power_profile/loader/composite.py", line 14, in initialize
    [await loader.initialize() for loader in self.loaders]  # type: ignore[func-returns-value]
     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 31, in initialize
    self.library_contents = await self.load_library_json()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/powercalc/power_profile/loader/remote.py", line 52, in load_library_json
    with open(get_library_json_path()) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/config/custom_components/powercalc/../../profile_library/library.json'

There is already issue made on github:

1 Like

What is the state of your climate sensor when you want the power meter to give a reading?

Hi Branski,

The data is coming in as a digital via MQTT, so either 1 or 0.

I’m pretty sure a climate entity is not behaving like a binary sensor in HA.
Possible states of a climate entity are:

You can check in developer tools what state and attributes the entity has when you turn it on or off via MQTT.

You can use the states power option to map a certain state or attribute to a given power value.

Yes, I can get those via the climate entity. But the more reliable is the digital that I can getting directly from MQTT.

At the moment I am doing alot of “jiggery pockery” to map the MQTT to the HA Climate entities…

But that’s a different entity you are talking about than? Not the climate.living_ac entity?
Not sure what you mean by But the more reliable is the digital that I can getting directly from MQTT.. You’ll need that data in an entity to make it part of HA state machine and let powercalc bind to it.

Just wanted to let you all know I have worked on a new GUI for the library listing.
Where you can easily search for a given model to see if it is supported by powercalc.
Happy to hear any feedback.

Available here: https://powercalc.lauwbier.nl

1 Like

Is there any way I can create a sensor that can tell me what is the power consumption of my lights(smart lights) when they are off (powered but off)?

Have a look at standby_power

This is not what I wanted. I need to rephrase a bit.

I want the total energy spent in KWh (in a year/month/week etc) while the light was off/standby.

I own smart switches like this one:
https://www.aliexpress.com/item/1005006313858972.html

I know what is power consumption for each bulb I use. It’s specified by bulb manufacturer or I am able to measure it and power consumption is constant - bulb is not smart and it’s connected to socket switch, so we don’t need to measure/guess power consumption, it’s known and never changes.

Can I provide exact power consumption in your integration settings to make it calculating using that value?

Sure: Virtual power sensor (manual) — Powercalc documentation.
Than select “fixed” Fixed — Powercalc documentation

1 Like

I can’t add integration Powercalc, I’m getting error message: : “Invalid handler specified”. My HA version is 2024.3.3 - is this HA version supported?

Debug message:

Source: config_entries.py:2444
Error occurred loading flow for integration powercalc: cannot import name ‘ConfigFlowResult’ from ‘homeassistant.config_entries’ (/home/orangepi/.local/share/pipx/venvs/homeassistant/lib/python3.11/site-packages/homeassistant/config_entries.py)

Is my Python version too old, or some Python lib is missing? Currently, I have no easy way to upgrade Python on my device, because I will need to use Debian Experimental repos, which I don’t really want to do.

Latest Python version available in Debian is 3.11.8 and 3.12.1 is experimental.

Yes it’s a known issue. Also see versione 1.11.8 doenst work · Issue #2222 · bramstroker/homeassistant-powercalc · GitHub
I didn’t have time to look into making compatible with both 2024.3 and 2024.4+
In one of last Powercalc versions compatibility with 2024.3.x and lower broke.

I suggest you to upgrade to HA 2024.4 which should solve your issue.