Powercalc - Virtual power sensors

Sure this is one of the things powercalc can do.

You only need the following configuration:

  platform: powercalc
  entity_id: switch.room_heater
    power: 1000

Powercalc will create a power sensor, which will show 1000 or 0 watt depending if the device is on or off.
Will also create a kWh sensor (which is just a riemann sum sensor)
And also utility meters will be created (daily, weekly, monthly)

1 Like

Thanks :grinning: Very usefull power consumpion calculator . How can i change 1,000.0 W to 1000 W ?

Screen Shot 2021-11-11 at 23.58.47

I see you got it working ;-). Not sure how you can change the thousands separator, this is not something powercalc does but more a frontend formatting thing of Home Assistant. Maybe someone else knows how to do it.

My guess is that is based on your homeassistant language but as bramski says that is only how it is shown the thousand separator isn’t in the data from powercalc.

1 Like

Try “Number Format” in User Settings. However Swiss standard is not represented, maybe yours…

best f


Have a question about other people’s experience.

Once I found this integration fell in love with it and spent days measuring various devices around my house!!

Recently I noticed my backup’s started taking forever and then I blew the limit on my Google Drive where the back up’s sync to. My database has ballooned over the past 3 months, whilst I’ve got the headroom on my hardware was curious.

Ran a quick query on the database and identified the biggest offenders were the sensors from PowerCalc (which when you think about it makes sense):

COUNT(*) AS cnt,
COUNT(*) * 100 / (SELECT COUNT(*) FROM states) AS cnt_pct,
SUM(LENGTH(attributes)) AS bytes,
SUM(LENGTH(attributes)) * 100 / (SELECT SUM(LENGTH(attributes)) FROM states) AS bytes_pct,
FROM states
GROUP BY entity_id

source: How to keep your recorder database size under control

So I’ve been trying to get my head around what I want this data for. I use the current power in Lovelace next to the individual device – so I don’t need this in the recorder and could exclude it? I have my device group data in the energy dashboard, again I don’t think I need this in the recorder to source it there?

I was about to start a bit of testing around this, but any thoughts appreciated….

The second point of pondering is long term statistics, and I can’t find the answer – if I excluded these from the recorder would I still build the LTS data?

Of course I can reduce the duration of data retention to mitigate this, there are feature requests kicking around to allow this to be defined by entity which could help. As I say, just some thoughts and any feedback or similar experiences would be welcome

There are few areas You touch in this post. And I am not sure is it the best place to talk about databases. I am sure that powercalc data is not very different from other.
But quick 5 cents:

  1. order in area what to record is cruicial. Most probably You do not need long history of most entities.
  2. IMO dividing data for short and long term is helpful as well. I store 1 day in relative database MariadB and longer in influx which need less space and works better for long time data
  3. Now we have statistics as well which consume less space

@QbaF thanks for the comments…

Firstly, this was not a criticism of PowerCalc - I simply posted here because the increase in my database size seemed to be attributable to this awesome integration.

For the time being I purged the database and reduced my retention period to shave down some Gb’s off the size. The challenge wasn’t directly with all the data I had, it was the back ups were taking a while!!

I’ve pondered Influx for a while, might be time to dive down that rabbit hole :slight_smile:

I did not say or even feel that You are criticizing Powercalc:) Just would like to say that most probably there is a better place which gathers more people engaged in that problem.
And I need to clear my databases as well, so will be happy to know that kind of place. It looks like bigger, unsolved problem of HA users. One of HA founders has dB with size in TB:)

1 Like

I have completed working on estimating power consumption of WLED controlled light strips.
Looking for other users which also have WLED lights and are able to test this functionality.


I’ve just installed the powercalc through hacs. Then I added the following configuration:

- platform: powercalc
  entity_id: light.aquarium
    voltage: 5

Finally, I received the following:

Invalid config for [sensor.powercalc]: [wled] is an invalid option for [sensor.powercalc]. Check: sensor.powercalc->wled. (See ?, line ?).

Could you please tell me what I am doing wrong?

Hi, this feature is new and has not been released yet. Will be in upcoming version v0.13. Will release this next week. You could also install the master branch. Click “Re download” in HACS and than select master branch.


I did this. Then restarted HA. Then added configuration for several WLED entities and restarted the HA.
Finally, I received the following error:

Logger: homeassistant.setup
Source: setup.py:316
First occurred: 10:27:09 (3 occurrences)
Last logged: 10:27:09

Unable to prepare setup for platform powercalc.sensor: Unable to set up component.
Logger: homeassistant.setup
Source: custom_components/powercalc/model_discovery.py:34
Integration: powercalc (documentation, issues)
First occurred: 10:27:09 (1 occurrences)
Last logged: 10:27:09

Error during setup of component powercalc
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/setup.py", line 254, in _async_setup_component
    result = await task
  File "/home/homeassistant/.homeassistant/custom_components/powercalc/__init__.py", line 94, in async_setup
    await autodiscover_entities(config, domain_config, hass)
  File "/home/homeassistant/.homeassistant/custom_components/powercalc/__init__.py", line 118, in autodiscover_entities
    light_model = await get_light_model(hass, source_entity.entity_entry, {})
  File "/home/homeassistant/.homeassistant/custom_components/powercalc/model_discovery.py", line 34, in get_light_model
    manufacturer = config.get(CONF_MANUFACTURER)
AttributeError: 'RegistryEntry' object has no attribute 'get'

Is there anything that I should do in another way?

@sani Could you please create an issue on github? Issues · bramstroker/homeassistant-powercalc · GitHub. Could you also mention your HA version?
I will have a look soon.
Also just released v0.13.0-beta.1 which has the WLED functionality and compatibility for upcoming HA 2021.12.x version.

I created the issue. Here is it: Setup error with WLED configuration usage · Issue #396 · bramstroker/homeassistant-powercalc · GitHub

1 Like

@bramski I think there is an issue in version v0.13.0 and v.0.13.1 where power sensors stop working when “create_energy_sensors” is set to false. I have this set in global settings and after update from v.0.12.1 all of my power sensors stopped working except the one with “create_energy_sensor: true”.
Also when I set “create_energy_sensors: true” everything starts to work again but I would like to have it set to false as I already have my own energy sensors. Can you please look into this? Thanks for your amazing work!

Thanks for reporting. Could you please create an issue on github? Will have a look soon.

Probably a stupid problem with an obvious solution I just can’t see. Auto detection fails for all my Hue lights as it can’t find the model name which I assume is supposed to correlate with what’s listed in the signify folder. Or is what’s listed as “model” below expected behavior?

A couple of examples:

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc.model_discovery] light.kjokken_tak: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue ambiance spot)

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc] light.kjokken_tak: Model not found in library, skipping auto configuration

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc.model_discovery] light.kjokken_overskap: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue lightstrip plus)

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc] light.kjokken_overskap: Model not found in library, skipping auto configuration

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc.model_discovery] light.soverom_tak_2: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue color spot)

2021-12-16 21:40:15 DEBUG (MainThread) [custom_components.powercalc] light.soverom_tak_2: Model not found in library, skipping auto configuration

Which version of Home Assistant are you using? I guess it’s 2012.11.x. If so, could you try upgrading to 2012.12? You are correct, the model should match the directory name i.e. LCT012

Supervisor was already 12.2, but Core was at 11.5. Seems to be solved by updating core to 12.2. Thanks!

(Mostly have LTW013, GU10 white ambiance, which isn’t listed. Just copied and renamed the folder of the identical version with colors as I suppose the consumption should be pretty identical. Everything seems to now populate automatically.)