I don’t think this is supported by HA yet. Powercalc does not provide pricing. I think there was a topic about it in WTH to also have pricing for individual entities.
Or you might build something yourself with some template sensors.
Should be auto discovered. You can enable debug logging which should give some clues as to what model is detected by powercalc. Maybe this somehow does not match the model in the database.
This is showed in the log:
2023-02-03 08:07:50.377 DEBUG (MainThread) [custom_components.powercalc.discovery] light.spots_achtertuin: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue smart plug (LOM007))
But what I noticed is that there is not a second line in the log like this:
2023-02-03 08:07:50.314 DEBUG (MainThread) [custom_components.powercalc.discovery] light.luifel_garage_deur: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue color spot (LCT003))
2023-02-03 08:07:50.316 DEBUG (MainThread) [custom_components.powercalc.discovery] light.luifel_garage_deur: Already setup with discovery, skipping new discovery
2023-02-03 08:07:50.366 DEBUG (MainThread) [custom_components.powercalc.discovery] switch.tv_woonkamer_power_plug: Auto discovered model (manufacturer=Shelly, model=Shelly Plug S)
2023-02-03 08:07:50.367 DEBUG (MainThread) [custom_components.powercalc.discovery] switch.tv_woonkamer_power_plug: Already setup with discovery, skipping new discovery
Do I need to manually add it?
Strange, could you go forward and create an issue on github? Please include the full logs after startup with debug enabled.
I recently added a couple Emporia Vue Gen 2 energy monitors to my main panel and subpanel. Even with all of current sensors installed, I have ~20 circuits which are unmonitored. So, I’m initially using them to find the power curves for each of my loads (e.g. dimmable lights via Excel and trendlines, electronics, and basically anything else that has a state monitored/controlled via HA). Thanks to your integration, I’ll be able to monitor them as well as my higher load and non-HA monitored circuits with the Vue. Thank you.
Now that I have the power curve equations, I’m starting to create the Powercalc sensors. After making a few in the UI and getting a good sensor template and overall configuration with the necessary parameters, I’d like to switch to yaml to more quickly configure the remaining sensors.
Where can I find the yaml created by the UI, so I can copy/paste that into my configuration.yaml?
I could go all yaml, but I’ll probably use a mix of UI and yaml Powercalc sensors. Does Powercalc allow for a mixed configuration like this?
You can’t, it’s a completely separate setup routine in fact in HA. UI entries don’t have a corresponding YAML configuration.
Sure you can mix both, no problem.
Thank you for this great integration, it has proved to be very helpful in tracking the energy usage.
I had several light groups defined in configuration.yaml and they had worked well for few months. But now when I migrated HA and some other stuff (HA from Docker to HAOS VM, zigbee2mqtt to Docker) to new platform, I noticed that the powercalc grouped entities had stopped working. I’m not sure what had changed in the migration (nothing should’ve as such), but with debugging I was able to trace the problem to “could not resolve any entities in group…” error and then I noticed also one line saying that a particular light was missing (but only for one light, in the indoor group). Light was not missing as a zigbee entity but the debug log was pointing to its original id from the time I linked it. I then removed the light from under Powercalc in UI (in integrations screen), and indoor group started working. From additional “could not resolve…” messages I deducted that something was wrong with light in one other group (on lowest level of nested groups for outdoor lights), even though I was not able to see any similar error that would have pointed to old id as with the indoor light. Anyhow, removing every light related to this sub group in Powercalc integration via UI finally led to victory. All working again.
Is there some obvious error in what I did? Should I have removed the instances I had in UI under Integrations / Powercalc to begin with so that they are not in two places? I still have some of the lights left there, the ones that did not cause any errors. So I wonder why (only) some of them started behaving badly at this point. They are zigbee bulbs and coming to HA via mqtt (zigbee2mqtt + mqtt server running on another VM) and I guess I might have changed the name in zigbee2mqtt after linking them while they were already auto dicovered in HA. So the name changed at the very beginning (few months ago). And now some of the error messages I saw in debug log hinted that there could’ve been a reference in powercalc to the original name while in yaml I was using the current names. But as said, everyhing worked until few days ago when I did the migration. So - all good for now but to avoid this hassle in future, looking for advice where I did wrong and how to prevent this from happening in future?
Btw, I should mention I did not find a way to reload the powercalc groups without a HA restart, took a bit of time with several restarts. Is there some better way to do this?
Thanks a lot for the integration which makes tracking electricity consumption much easier!
Quick question: how can I use Powercalc for net meter? i.e. change the state_class to total (instead of total_increasing)?
Thanks!
Could you elaborate more about your question? Which sensor do you want powercalc to create (with with source / input)? Which sensor do you see as total_increasing
now?
Hard to say what went wrong during that migration. There are so many variables in play and the entity management in HA and powercalc setup is rather complex. So a lot of places where things can go wrong.
So I can’t give you any advice in this regard without any clear errors / reproduction steps.
But looking at your story you got things working now correctly right?
Sorry for not being clear. I am looking for net metering within Powercalc. For example the battery for the house is charging (positive power values) and discharging (negative power values). The power sensor created with Powercalc shows the negative values when discharging but the energy sensor and utility meters are only increasing when charging (never decreasing when discharging).
Is there an option to define a sensor as net meter? Or do I need to create 2 sensors (1 for charging and 1 for discharging) and then do the netting with a template sensor?
The other relevant use case would be for grid net consumption.
Thanks
yaml code:
powercalc:
enable_autodiscovery: false
force_update_frequency: 00:01:00 #Each minute
create_energy_sensors: true
create_utility_meters: true
energy_integration_method: left
utility_meter_types:
- daily
- weekly
- monthly
- yearly
sensor:
- platform: powercalc
name: PowCalc Battery
daily_fixed_energy:
value: "{{states('sensor.powerwall_battery_now') | float(0) * (-1000) }}"
unit_of_measurement: W
Screen shots below:
I understand what you mean. Powercalc does not provide anything for this, so I suggest to do it yourself using template sensors.
Powercalc main purpose is to provide virtual power sensors, and I have extended it with some possibilities to automatically create energy sensors, utility meters and group sensors. But it won’t be a fully fledged energy management system, there you would need to use the HA standard tooling for.
Understood. Ease of use with Powercalc is still much better as I don’t have to manually configure various energy and utility meters for my own dashboards
Yes, thanks - I got it working. I was mainly wondering if I did something wrong in the initial setup that led to this. Also, am I correct that I cannot reload powercalc groups in any other way than restarting HA?
Btw, I should mention I did not find a way to reload the powercalc groups without a HA restart, took a bit of time with several restarts. Is there some better way to do this?
Awesome Project! Following it for a couple of Month i’m now about to give it a shot
For easier Management, i have all my lights, even if its only one, organised in light groups. They all start with
light.grp_*
so for example light.grp_kitchen_table
adresses the two corresponding Lightbulbs.
Reading the Documentation, i found that you can create Powercalc-Groups, and assign HomeAssistant-Groups to those. But that would mean i have to create and maintain all Powercalc-Groups manually, basically mirroring the already existing Lightgroups.
What would be the easiest Way to dynamically create Powercalc-Sensors for every light.grp_* Entity, hiding its Members?
Yes you can dynamically create groups using the following configuration:
sensor:
- platform: powercalc
create_group: Kitchen table lights
hide_members: true
include:
group: light.grp_kitchen_table
You’ll need to define the configuration for each group, but you only have to do that one time.
You can generate configuration using the template tooling from HA. Iterate through all the lights starting with grp_
and output powercalc configuration using some variables / concatination.
But this might be more work than to just use some text editor and define these groups manually.
Great!
I was hoping for a more dynamic way to dynamically create those, though Something like
include:
group: light.grp_*
leading to dynamically created sensors:
light.grp_kitchen_table
----> sensor.grp_kitchen_table_power
----> sensor.grp_kitchen_table_energy
light.grp_kitchen_oven
----> sensor.grp_kitchen_oven_power
----> sensor.grp_kitchen_oven_energy
light.grp_livingroom_ambient
----> sensor.grp_livingroom_ambient_power
----> sensor.grp_livingroom_ambient_energy
and so on… This Way this would be a true “On Time Set & Forget”, and if i ever add a light.grp_, its sensors get added automatically as well.
But never mind, doing that manually will do the Job as well
As you are the Dev of that great Piece of Code, let me thank you for your Project - which is really a awesome one!
Could someone help me out with setting up config below?
I have been reading all documentation, but still it isn’t working
I created a template sensor. This one is working and gives an output in Watt.
template:
- sensor:
- name: "enyaqpowerhome"
unique_id: enyaq_power_home
unit_of_measurement: "W"
device_class: power
state: >
{% if is_state('device_tracker.car_position',"home") -%}
{{ states('sensor.car_charging_power') }}
{%- else -%}
{{0.0|float}}
{%- endif %}
And now I wish to use powercalc to integrate and get the energy (kWh):
powercalc:
force_update_frequency: 00:01:00
enable_autodiscovery: false
sensor:
- platform: powercalc
entity_id: sensor.enyaqpowerhome
name: EnyaqTotalChargingPowercalc
power_sensor_id: sensor.enyaqpowerhome
The current output is “unknown”. Also the debugging in the log file, isn’t giving any errors …
Thx!
Hi,
I have setup an new home assistant and use the following configuration.
configuration.yaml
.
.
powercalc: !include config-yamls/powercalc/powercalc.yaml
sensor powercalc_groups: !include config-yamls/powercalc/powercalc_groups.yaml
.
.
powercalc.yaml
force_update_frequency: 00:01:00 #Each minute
power_sensor_naming: "{} Powersensor"
energy_sensor_naming: "{} Energysensor"
create_utility_meters: true
enable_autodiscovery: true
utility_meter_types:
- daily
- monthly
- yearly
create_domain_groups:
- light
powercalc_groups.yaml
- platform: powercalc
create_group: Gruppe Schlafzimmer
entities:
- create_group: Gruppe Schlafzimmer Light Gesamt
entities:
- entity_id: light.schlafzimmer
- create_group: Gruppe Schlafzimmer Plugs Gesamt
entities:
# HA Plug
- entity_id: switch.shelly_shplg_s_c8c9a3b8fc80
power_sensor_id: sensor.shelly_shplg_s_c8c9a3b8fc80_current_consumption
# PC Plug
- entity_id: switch.shelly_shplg_s_e868e7ecdcb8
power_sensor_id: sensor.shelly_shplg_s_e868e7ecdcb8_current_consumption
Basically the same setup that I use in my other home assistant. The only problem is, that none of these sensors get created
I don’t see any obvious misconfiguration.
When you have issues with powercalc entities not being created please check the logs for errors.
If no error are to be seen in the logs please enable Debug logging and check for clues there.