Powercalc - Virtual power sensors

Can you explain, what you want to say with this?

First of all: Reload UI-pagen. Often the UI shows entities from brwoser cahce, which are not available anymore.
Secondly: If they are created from integration and still bound to integration, you will not be able to delete, even if you have renamed them.

I am trying to create a virtual sensor for my thermostat and am getting an error in the log. What does mean?

sensor:

  • platform: powercalc
    entity_id: climate.kitchen_warm_floor
    fixed:
    power: 1600

Logger: custom_components.powercalc.sensors.power
Source: custom_components/powercalc/sensors/power.py:150
Integration: Powercalc (documentation, issues)
First occurred: 20:55:11 (2 occurrences)
Last logged: 20:55:11

  • climate.kitchen_warm_floor: Error setting up calculation strategy: This entity can only work with ‘states_power’ not ‘power’

Only power is only allowed for devices which have a binary state (on/off).
A climate device can have different modes (can also be different per device).
So you’ll have to use states_power: like this. Also see the readme for other examples.

- platform: powercalc
  entity_id: climate.kitchen_warm_floor
  fixed:
    states_power:
      heat: 1600
      #other states which you want to handle
1 Like

Thanks, it works!

1 Like

For the UI mode is it possible to use an existing power sensor?
ex:

state: 26.9
state_class: measurement
meter_type: 1
meter_type_name: ELECTRIC
unit_of_measurement: W
device_class: power
friendly_name: 'Living Room Light: Electric Consumption [W]'

I have tried the following in the template section of the UI:

"{{states('sensor.living_room_dimmer_switch_electric_consumption_w')}}"
{{states('sensor.living_room_dimmer_switch_electric_consumption_w')}}

It doesn’t seem to be tracking as a utility meter or reading the power sensor.

Watt is the unit of power whereas kilowatt-hour (kWh) is the unit of energy

…If I only knew how to read!!!

Currently implemented:

  • Virtual power sensor
    • Fixed
    • Linear
    • Wled
    • LUT strategy
  • Daily fixed energy sensor
  • Group sensors

From today I have 4 errors when I do a config check:

Platform error sensor.powercalc - Exception importing custom_components.powercalc.sensor
Platform error sensor.powercalc - Exception importing custom_components.powercalc.sensor
Platform error sensor.powercalc - Exception importing custom_components.powercalc.sensor
Platform error sensor.powercalc - Exception importing custom_components.powercalc.sensor

Powercalc sensors in my sensors.yaml file:

 - platform: powercalc
    entity_id: light.kastlamp
    linear:
      min_power: 0.5
      max_power: 9.5
  - platform: powercalc
    entity_id: light.staande_lamp
    linear:
      min_power: 0.5
      max_power: 9.5
  - platform: powercalc
    entity_id: light.garage_verlichting_plafond
    fixed:
      power: 38  
  - platform: powercalc
    entity_id: light.bijkeuken_verlichting
    fixed:
      power: 20

I’m on HA version 2022.7.6.
Has anyone an idea?

Which version of powercalc? When you have updated to v0.24.0 or v0.24.1, there is a know issue which is probably fixed on master branch already. Will release v0.24.2 later today.
The issue was reported here: https://github.com/bramstroker/homeassistant-powercalc/issues/902

@mhanley05 I have tried to focus on most used options in the GUI to not clutter it too much.

When your goal is to create an energy meter (kWh) and/or utility_meter for this existing power sensor, I suggest you stick to the helpers HA supplies out of the box (Settings → Devices & Services → Helpers → Create helper). Use “Integration - Riemann sum integral” for the energy sensor, “Utility meter” for the utility meters.

1 Like

I’m on v0.24.0. As I speak I can now upgrade to v0.24.1.
I wil try this, thx for the info.

It’s not fixed in v0.24.1 yet, you’ll probably hit the same issue there. Looks for most users these releases are broken. You can try installing master branch with HACS. Click redownload and enable beta releases. That will allow you to choose master.
When you can confirm that this solves the issue I will release v0.24.2. I don’t want to make another broken release, so I want some confirmations from users first that it is really solved.

@BernieV Just released v0.24.2 which should resolve the issues

Thx, problem solved with release v0.24.2!

Hi,
i have updated to v0.24.2. Everything is working fine so fare except one thing. I have groups of plugs witch have energy- and power-sensors created but only the energy-sensor shows a value

here the energy-sensor

and here the power-sensor

on the energy-sensor screenshot I can see the entities on the screenshot of the power-sensor not.

That is not the case if I look at a power-sensor of my light group for example.

Here are entities in the attribute section.

Here is my config:


- platform: template
  sensors:
    kwhprice:
      friendly_name: "Preis pro kWh"
      value_template: "0.2345"
      unit_of_measurement: "{currency}/kWh"
    strom_tarif:
      friendly_name: "Strom Tarif"
      value_template: "0.2345"
      unit_of_measurement: "EUR"

# original sensors are in W but I need kW
    dirks_homey_pro_leistung_kw:
      friendly_name: "Homey on / off plug Energysensor kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.dirks_homey_pro_leistung') | float * 0.001) | round(5, 0) }}"
    steckdose_pc_schlafzimmer_power_consumption_kw:
      friendly_name: "PC Stecker kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdose_pc_schlafzimmer_power_consumption') | float * 0.001) | round(5, 0) }}"
    shelly_shplg_s_87e9c7_pc_current_consumption_kw:
      friendly_name: "PC Plug kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.shelly_shplg_s_87e9c7_pc_current_consumption') | float * 0.001) | round(5, 0) }}"
    shelly_shplg_s_ea48f8_dm920_current_consumption_kw:
      friendly_name: "DM920 Plug kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.shelly_shplg_s_ea48f8_dm920_current_consumption') | float * 0.001) | round(5, 0) }}"
    shelly_shplg_s_bc6caa_tv_current_consumption_kw:
      friendly_name: "TV Plug kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.shelly_shplg_s_bc6caa_tv_current_consumption') | float * 0.001) | round(5, 0) }}"
    steckdose_tv_hd_power_consumption_kw:
      friendly_name: "Steckdose TV HD Power Consumption kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdose_tv_hd_power_consumption') | float * 0.001) | round(5, 0) }}"
    steckdosen_tv_box_leistung_kw:
      friendly_name: "Steckdosen TV Box - Leistung kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdosen_tv_box_leistung') | float * 0.001) | round(5, 0) }}"
    steckdose_kuche_power_consumption_kw:
      friendly_name: "Steckdose KĂźche Power Consumption"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdose_kuche_power_consumption') | float * 0.001) | round(5, 0) }}"
    steckdose_alexa_sz1_leistung_kw:
      friendly_name: "Steckdose Alexa SZ1 Leistung kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdose_alexa_sz1_leistung') | float * 0.001) | round(5, 0) }}"
    steckdose_ventilator_leistung_kw:
      friendly_name: "Steckdose Verntilator Leistung kW"
      unit_of_measurement: "kW"
      value_template: "{{ ( states('sensor.steckdose_ventilator_leistung') | float * 0.001) | round(5, 0) }}"

# Groups
- platform: powercalc
  create_group: Gruppe Wohnung 
  entities:
    - create_group: Gruppe Wohnzimmer Gesamt
      entities:
        - create_group: Gruppe Wohnzimmer Licht Gesamt
          entities:
            - entity_id: light.wohnzimmerlampe
            - entity_id: light.tv_led_kette
              power_sensor_id: sensor.tv_led_kette_energysensor
            - entity_id: light.led_kette_wz
              linear:
                min_power: 0.4
                max_power: 24
            - entity_id: light.hue_play_gradient_lightstrip_1
              linear:
                min_power: 0
                max_power: 17.1
            - entity_id: light.stehlampe_wz
              linear:
                min_power: 0.6
                max_power: 13
        - create_group: Gruppe Wohnzimmer Plugs Gesamt
          entities:
            - entity_id: switch.steckdosen_tv_box_eingeschaltet
              power_sensor_id: sensor.steckdosen_tv_box_leistung_kw
              energy_sensor_unit_prefix: none
            - entity_id: switch.steckdose_tv_hd
              power_sensor_id: sensor.steckdose_tv_hd_power_consumption_kw
              energy_sensor_unit_prefix: none
              # TV Plug
            - entity_id: switch.shelly_shplg_s_bc6caa_tv
              power_sensor_id: sensor.shelly_shplg_s_bc6caa_tv_current_consumption_kw
              energy_sensor_unit_prefix: none
              name: "TV Plug"
              # DM920 Plug
            - entity_id: switch.shelly_shplg_s_ea48f8_dm920
              power_sensor_id: sensor.shelly_shplg_s_ea48f8_dm920_current_consumption_kw
              energy_sensor_unit_prefix: none
              name: "DM920 Plug"
    # Gruppe Schlafzimmer
    - create_group: Gruppe Schlafzimmer Gesamt
      entities:
        - create_group: Gruppe Schlafzimmer Licht Gesamt
          entities:
            - entity_id: light.schlafzimmerlampe
            - entity_id: light.nachttischlampe
              standby_power: 0.4
              fixed:
                power: 15
            - entity_id: light.pc_led_kette
              linear:
                min_power: 0.4
                max_power: 3
            - entity_id: light.led_kette_rechts
              linear:
                min_power: 0.4
                max_power: 3.1
        - create_group: Gruppe Schlafzimmer Plugs Gesamt
          entities:
            - entity_id: switch.steckdose_alexa_sz1_eingeschaltet
              power_sensor_id: sensor.steckdose_alexa_sz1_leistung_kw
              energy_sensor_unit_prefix: none
            - entity_id: switch.steckdose_pc_schlafzimmer
              power_sensor_id: sensor.steckdose_pc_schlafzimmer_power_consumption_kw
              energy_sensor_unit_prefix: none
              #PC Plug
            - entity_id: switch.shelly_shplg_s_87e9c7_pc
              power_sensor_id: sensor.shelly_shplg_s_87e9c7_pc_current_consumption_kw
              energy_sensor_unit_prefix: none
              name: "PC Plug"
            - entity_id: switch.steckdose_ventilator_eingeschaltet
              power_sensor_id: sensor.steckdose_ventilator_leistung_kw
              energy_sensor_unit_prefix: none
            - entity_id: light.homey_on_off_plug
              power_sensor_id: sensor.dirks_homey_pro_leistung_kw
              energy_sensor_unit_prefix: none
    # Gruppe Kueche
    - create_group: Gruppe KĂźche Gesamt
      entities:
        - create_group: Gruppe KĂźche Licht Gesamt
          entities:
            # Gruppe Kueche Spots
            - create_group: Gruppe KĂźche Spots Gesamt
              entities:
                - create_group: Gruppe KĂźche Spots Innen Gesamt
                  entities:
                    - entity_id: light.kuche_spot_2
                    - entity_id: light.kuche_spot_3
                - create_group: Gruppe KĂźche Spots Aussen Gesamt
                  entities:
                    - entity_id: light.kuche_spot_1
                    - entity_id: light.kuche_spot_4
            # Gruppe Kueche LED Ketten
            - create_group: Gruppe KĂźche LED Ketten Gesamt
              entities:
                - entity_id: light.kuhlschrank_led_kette
                - entity_id: light.spule_led_kette
            # Gruppe Kueche LED
            - create_group: Gruppe KĂźche LED Gesamt
              entities:
                - entity_id: light.kuhlschrank_led
                  standby_power: 0.4
                  fixed:
                    power: 11.4 #Power when the light is on
                - entity_id: light.spule_led
                  standby_power: 0.4
                  fixed:
                    power: 11.4 #Power when the light is on
        - create_group: Gruppe KĂźche Plugs Gesamt
          entities:
            - entity_id: switch.steckdose_kuche
              power_sensor_id: sensor.steckdose_kuche_power_consumption_kw
              energy_sensor_unit_prefix: none
        # Gruppe Flur
    - create_group: Gruppe Flur Gesamt
      entities:
        - entity_id: light.flurlampe

Thank you!

Could you please create an issue on github?

1 Like

Here is the issue: https://github.com/bramstroker/homeassistant-powercalc/issues/906

Thank you!

Hi,

I have two shelly plugs in my room. Is it normal that powercal uses the “total consumption” of that device? The problem is that than the energysensor of that group uses the readings from past days even those from last month

The month has just started I have already 13,55 kWh ?!?

grafik

here are the readings from one plug

grafik

here is my config of that room

  create_group: Gruppe Wohnung Eppstein
  entities:
    - create_group: Gruppe Wohnzimmer Gesamt
      entities:
        - create_group: Gruppe Wohnzimmer Licht Gesamt
          entities:
            - entity_id: light.wohnzimmerlampe
            - entity_id: light.tv_led_kette
              power_sensor_id: sensor.tv_led_kette_energysensor
            - entity_id: light.led_kette_wz
              linear:
                min_power: 0.4
                max_power: 24
            - entity_id: light.hue_play_gradient_lightstrip_1
              linear:
                min_power: 0
                max_power: 17.1
            - entity_id: light.stehlampe_wz
              linear:
                min_power: 0.6
                max_power: 13
        - create_group: Gruppe Wohnzimmer Plugs Gesamt
          entities:
            - entity_id: switch.steckdosen_tv_box_eingeschaltet
              power_sensor_id: sensor.steckdosen_tv_box_leistung
            # TV Plug
            - entity_id: switch.shelly_shplg_s_bc6caa_tv
              power_sensor_id: sensor.shelly_shplg_s_bc6caa_tv_current_consumption
              # DM920 Plug
            - entity_id: switch.shelly_shplg_s_ea48f8_dm920
              power_sensor_id: sensor.shelly_shplg_s_ea48f8_dm920_current_consumption

Thank you! :slight_smile:

This is expected behaviour. The grouped energy sensor just sums all the energy sensors together. When you have a “real” existing energy sensor which is part of the group and that already has an value (from the past) you need to have a look if you can reset is somehow. I am pretty sure the shelly plugs allow the kWh meter to be reset from the Shelly App. But I am not at home atm so cannot check.

1 Like

Thanks for the information. Will have a look into that :slight_smile:

Looks like there is sadly no way to reset only the power consumption… only a factory reset :frowning:

Than I have to live with that