Powercalc - Virtual power sensors

Here is my sensor.yaml

- platform: systemmonitor
  resources:
    - type: disk_use_percent
      arg: /
    - type: disk_use
      arg: /
    - type: disk_free
      arg: /
    - type: memory_use
    - type: memory_free
    - type: memory_use_percent
    - type: ipv4_address
      arg: eth0
    - type: processor_use

- platform: command_line
  name: CPU Temp
  command: "cat /sys/class/thermal/thermal_zone0/temp"
  unit_of_measurement: "°C"
  value_template: "{{ value | multiply(0.001) | round(1) }}"

- platform: command_line
  name: GPU Temp
  command: "/opt/vc/bin/vcgencmd measure_temp"
  unit_of_measurement: "°C"
  value_template: '{{ value | regex_findall_index("=([0-9]*\.[0-9]*)", 0) }}'

- platform: command_line
  name: CPU Clock
  command: "/opt/vc/bin/vcgencmd measure_clock arm"
  unit_of_measurement: "MHz"
  value_template: '{{ value | regex_findall_index("=([0-9]*)", 0) | multiply(0.000001) | round(0) }}'

- platform: dwd_weather_warnings
  region_name: 806436002

# Einzel
- platform: powercalc
  entity_id: light.homey_on_off_plug
  power_sensor_id: sensor.dirks_homey_pro_leistung

- platform: powercalc
  entity_id: light.led_kette_wz
  linear:
    min_power: 0.4
    max_power: 24

- platform: powercalc
  entity_id: light.hue_play_gradient_lightstrip_1
  linear:
    min_power: 0
    max_power: 17.1

- platform: powercalc
  entity_id: light.pc_led_kette
  linear:
    min_power: 0.4
    max_power: 3

- platform: powercalc
  entity_id: light.led_kette_rechts
  linear:
    min_power: 0.4
    max_power: 3.1

- platform: powercalc
  entity_id: light.stehlampe_wz
  linear:
    min_power: 0.6
    max_power: 13

- platform: powercalc
  entity_id: light.spule_led
  standby_power: 0.4
  fixed:
    power: 11.4 #Power when the light is on

- platform: powercalc
  entity_id: light.kuhlschrank_led
  standby_power: 0.4
  fixed:
    power: 11.4 #Power when the light is on

- platform: powercalc
  entity_id: light.nachttischlampe
  standby_power: 0.4
  fixed:
    power: 15 #Power when the light is on

- platform: powercalc
  entity_id: switch.steckdose_alexa_sz1_eingeschaltet
  power_sensor_id: sensor.steckdose_alexa_sz1_leistung

# Gruppe Schlafzimmer
- platform: powercalc
  create_group: Gruppe SZ1
  entities:
    - entity_id: switch.steckdose_alexa_sz1_eingeschaltet
    #    - entity_id: sensor.steckdose_pc_schlafzimmer_power_consumption
    #    - entity_id: sensor.steckdose_ventilator_leistung
    - entity_id: light.nachttischlampe
    - entity_id: light.schlafzimmerlampe
#    - entity_id: light.pc_led_kette
#    - entity_id: light.led_kette_rechts
#   - entity_id: light.homey_on_off_plug

# Gruppe Kueche
- platform: powercalc
  create_group: Gruppe Kuche
  entities:
    # Gruppe Kueche Spots
    - create_group: Kuche Spots
      entities:
        - create_group: Kuche Spots Innen
          entities:
            - entity_id: light.kuche_spot_2
            - entity_id: light.kuche_spot_3
        - create_group: Kuche Spots Aussen
          entities:
            - entity_id: light.kuche_spot_1
            - entity_id: light.kuche_spot_4
    # Gruppe Kueche LED Ketten
    - create_group: Kuche LED Ketten
      entities:
        - entity_id: light.kuhlschrank_led_kette
        - entity_id: light.spule_led_kette
    # Gruppe Kueche LED
    - create_group: Kuche LED
      entities:
        - entity_id: light.kuhlschrank_led
        - entity_id: light.spule_led

Thanks!

You have to put the sensor configuration for light.nachttischlampe under the group configuration, otherwise it will not be part of the group. Like this:

- platform: powercalc
  create_group: Gruppe SZ1
  entities:
    - entity_id: light.nachttischlampe
      standby_power: 0.4
      fixed:
        power: 15 #Power when the light is on

Ah, ok thank you! As it gets created I thought it would be enough if it is in the config

Thank you! That was the difference !

grafik

But this is in the docs and in the wiki of the github page really great explained and documented. I would suggest in reading through the docs 1-2 times.

2 Likes

For the new GUI configuration which will be released in v0.24 I am searching for people who can contribute and maintain translation files in there native language. Currently we only have english translations, but there can be added more translations by just adding a json file to the repository here: homeassistant-powercalc/custom_components/powercalc/translations at dev · bramstroker/homeassistant-powercalc · GitHub.

I can do dutch myself if no one else is volunteering to do that one.

Thanks!

I’ll take German.

1 Like

Hi,

I would like to clean up my calculations. Is there a way to reset the calculation of a group of devices? I know there is that service but I get often this error

File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 711, in _handle_entity_call
    result = hass.async_run_job(partial(getattr(entity, func), **data))  # type: ignore[arg-type]
AttributeError: 'VirtualUtilityMeter' object has no attribute 'async_reset_energy'
Traceback (most recent call last):

Thank you!

You cannot use the powercalc reset service to reset utility meters. Only the energy sensors are supported.
However I think you can use the reset service from the utility meter interation: Utility Meter - Home Assistant
Let me know if this works for you, then I will have a look if I can also call this service from the powercalc service when you want to reset a group, so you only have to call 1 service.

Hi,

I have checked but I don’t have this " UTILITY_METER.RESET" service

Thanks!

Probably because of “Some of the services are only available if tariffs are configured.”. Could you create an issue on github? I will see if I can make it work somehow, but I don’t know if it is possible yet.

Yes, thank you! I will create one… what should the issue contain ?

how can I configure a tariffs ?

Thanks

Btw can you try adding the following to your configuration:

utility_meter:

I think that would make the reset service appear.

About different tariffs. read the utility meter readme. Utility Meter - Home Assistant. Powercalc exposes a setting for that utility_meter_tariffs

1 Like

I have added “utility_meter” to my config

and now I get that service but it only shows me two entities.

I know when you create a utility_meter with multiple tariffs (i.e. peak and offpeak) it will create a select entity which you can use to switch from peak to offpeak and back.
The utility meter reset service select is limited to select.* entities, so it seems it only allows to reset the meters with multiple tariffs.
I have no idea why it does not support resetting a “simple” utility meter which doesn’t have multiple tariffs.

You could create a new topic on the community forum to ask why this is not supported, or how you can reset them. Or ask on discord.
Maybe someone else chimes in on this topic who knows more about this.

Just to be sure, I also created an utility meter entity without using powercalc.

utility_meter:
  energy:
    source: sensor.spot_bar_energy
    name: My cool utility meter
    cycle: monthly

This one also doesn’t appear in the reset service selection list.

1 Like

You have to use SERVICE UTILITY_METER.CALIBRATE and set it to 0. The other one is, when you have defined tarifs.

It is mentioned in the documentation as well. reset = Reset the Utility Meter. All sensors tracking tariffs will be reset to 0.

2 Likes

Sadly I don’t have “UTILITY_METER.CALIBRATE” :roll_eyes:

Is there any other way how I can reset a whole group? Like one for “daily” or “monthly” ?

I see why you don’t have this service. Powercalc creates utility meters, but does not execute the method which registers the service. I’ll see if I can improve upon that in the future.

For now you can either create a utility meter manual using the YAML I have put above.
Or you can use the GUI to create one (Settings → Devices & Services → Helpers → Create helper)
Just create one (does not matter for which entity) and you’ll get the service.

1 Like

Try to define a utility meter via HA UI Helper and one via config-yaml, as in the example from Bram above, so both outside Powercalc. And see if the service will be enabled as well. Perhaps after a while or when one utility meter has valueas or … and the helper meter is updated or after 1-2 HA restarts.

And regarding groups. Not there isn’t, but you can call the service with more than one entity. I have put mine in one list and only paste it if I need to reset a lot of them.

2 Likes

How can I delete sensors of groups created by powercalc? I have renamed by existing ones but the old ones are still there and in the entities overview I can’t select the sensor and delete it.

Thank you!