In the last few weeks I have been working on a custom component to get virtual power sensors for your lights or other devices. It is stable enough right now to share it on this forum and make dedicated topic for it.
The component provides multiple strategies to calculate estimated power consumption. One of the most interesting is the LUT method (using lookup tables). Some community members and me have taken measurements for all kind of different brightness/hue/saturation settings and their respective power values.
For coloured lights that are approximately 40.000 unique data points. Currently 58 light models are supported for this method (mostly Philips Hue), but this will keep extending.
Besides this you can also define the power values of a device yourself using linear mode and fixed value. With a few lines of configuration you can have a power sensor for your appliance.
You can make all kind of cool dashboards with this data, and see the power consumption of individual devices in your entire home. And optimize your power consumption.
Also you can add these inidividual sensors to the HA energy dashboard.
Let me know if this is useful in your installation. Any question, shoot.
@bramski - I saw this pop up in HACS. I’m interested. I have a lot of sensors that I have created to calculate power usage based on the state and attributes of entities. I’m probably going to install this and test it out before migrating.
For example, here is a sensor I am using to calculate the power usage of my kitchen cabinet lights. They are LIFX-Z strips. They don’t report power but I know roughly what power they use based on their brightness. It isn’t perfect but it is basically accurate.
One of the issues I ran into was that because this isn’t a real power report coming from a device, there wasn’t any variation in the power usage all day for a light that was turned on and not changed. The impact of this was that the corresponding sensor I created to track energy usage didn’t work properly for reasons I don’t fully understand but I think based on how they do the math in the integration platform, they need the data to change to calculate energy usage. That is why you see me add states("input_number.calc_switch") | float to the power value. This input_number alternates every 5 seconds or so from .0001 to 0 and back to .0001… This keeps the number changing without really impacting its value.
Have you experienced this issue with your component?
I am very interested in migrating as creating these sensors the way I am takes a lot of time.
Hi, I don’t use the integration platform myself (yet) so I don’t know if my component solves your problem.
My component works by listening to state changes of the bounded entity (for example a light), whenever this light brightness or hue changes the power sensor will change state accordingly. When the light does not change, the power sensor also doesn’t change state.
You can create your power sensor with a few lines of configuration the powercalc component, so maybe you are able to test with one sensor before migrating all your lights.
Let me know your findings.
I don’t know if it is in scope or not but it would be great if it will be also added fixed valuse for devices like sonoff basic, shelly1 and so. What do you think?
But if I understand well you will not count also power consumption of the device itself ( more or less 1w for shelly1 devices based on this video = Shelly1 power consumption - YouTube )
Great! Thank you! But my question was that maybe those info can be added in the LUT and, sometimes should be possible to combines LUTs.(when you have switches and smart lamps combined)
Example:
lamp1 with no dimmerable lights managed by shelly1 (all my ceiling lamps)
sensor:
- platform: powercalc
entity_id: light.living_room
manufacturer: shelly
model: shelly1
that will replace this
fixed:
power: 21
standby_usage: 1
lamp2 philips hue lamp mounted on a floor lamp controlled by a shelly plug S:
Hi friend, I’m testing your application and it has been very useful for my automation, but when I try to add entities that are not automatically discovered (configured directly in configuration.yaml) they don’t work, power sensors don’t show up in my home assistant , what do I do so that I can manipulate them?
2021-07-20 17:28:51 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powercalc platform for sensor
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
await asyncio.shield(task)
File "/home/homeassistant/.homeassistant/custom_components/powercalc/sensor.py", line 120, in async_setup_platform
entity_name = entity_state.name
AttributeError: 'NoneType' object has no attribute 'name'
I have 5 switch entities and 2 light entities configured manually in my configuration.yaml, but none of them the electrical consumption sensor works only in auto-discoveries, what to do?
You can create a group of sensors to sum power usage of multiple powercalc sensors into a single sensor. Have a look at this github issue for an example how to do this.
The purpose of LUT files included in the component are to lookup power consumption for different brightness levels and color temperatures of a known light. The files are created by changing the light and measuring power consumption for each brightness level. Behind a shelly switch there can be all kind of different lights/appliances which we don’t know the power consumption. This is different for each user. You have to configure those sensors manually. This is not what the build in lut mode is for.
Powercalc will create a seperate power sensor (entity) for your light named sensor.ph80_power. You can find this sensor in Configuration → Entities or with the developer tools.
When this sensor is not created you should have a look into the logs for any errors.
It’s up to you to show this sensor and your light control in lovelace UI. In the example in github I am using a light card and a gauge card (these are both build in cards in home assistant)