bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
961 stars 254 forks source link

Problem with a group of plugs: power-sensor has no entities and doesn't show a value #906

Closed DirkStorck closed 2 years ago

DirkStorck commented 2 years ago

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 grafik

and here the power-sensor grafik

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.

grafik

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!

emufan commented 2 years ago

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.

Then provide a screenshot for light group power sensor and not for energy sensor. How should this be compared otherwise?

I have groups of plugs witch have energy- and power-sensors created but only the energy-sensor shows a value

Why do you think that 0 W is not a value - e.g. when everything is off? What are the values for the entities inside the group?

float

It is a surprise that this is working at all, if you are not starting to use default for the floats, Search HA documentation for this.

bramstroker commented 2 years ago

Why are you creating all these template kW power sensors? Powercalc is expecting all the sensors in the power group to be the same unit of measurement, all in W. Otherwise it will remove the non compatible power sensor from the group. That would be the reason you see 0.

Probably you see the following error in the logs: Group member 'sensor.steckdose_kuche_power_consumption_kw' has another unit of measurement 'kW' than the group 'sensor.gruppe_kuche_plugs_gesamt' which has 'W', this is not supported yet. Removing this entity from the total sum.

Maybe I will have a look to convert units in the future, so a group can consist of power sensors from units W, kW, mW etc.

So long story short. You should just add sensor.steckdose_tv_hd_power_consumption to the group and get rid of the template sensors.

DirkStorck commented 2 years ago

Hi, thank you! I think I did this because I had to high values in the sensor.

I will try that out...

DirkStorck commented 2 years ago

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.> Then provide a screenshot for light group power sensor and not for energy sensor. How should this be compared otherwise?> I have groups of plugs witch have energy- and power-sensors created but only the energy-sensor shows a value

My bad, wrong screenshot but the light group power sensor had entries....

Why do you think that 0 W is not a value - e.g. when everything is off? What are the values for the entities inside the group?

float

Because the plugs have been switched on all the time

It is a surprise that this is working at all, if you are not starting to use default for the floats, Search HA documentation for this.

Thanks for the hint

bramstroker commented 2 years ago

@DirkStorck Just focus on the group power sensors first and make sure all the power sensors added to there are W sensors, either the ones you create with powercalc or the existing ones you include using power_sensor_id. Than check under the power group attributes if all entities are listed correctly. And also check if the sum is correct. So when you have 2 individual power sensors whith are 200 W and 300 W, the group sensor should show 500 W.

Next check if the group energy sensor is correct. By default the energy sensor should show kWh, When you use energy_sensor_unit_prefix: None than the energy sensor will show wH

DirkStorck commented 2 years ago

I have changed my configuration and have removed all template sensors and use the ones from the entity. But somehow the value for group

These are the plugs in the group witch are currently on grafik

This is what I get for the daily group grafik

And this is are the daily power sensor values grafik grafik

So if I could reset the daily power or energy sensor for any group would be great... UTILITY_METER.CALIBRATE didn't do anything

Thank you

bramstroker commented 2 years ago

You can reset the group energy and daily energy sensor using a service which powercalc provides. It's in the readme here. https://github.com/bramstroker/homeassistant-powercalc#resetting-energy-sensor

bramstroker commented 2 years ago

For the utility meters (daily, monthly etc) you have to use UTILITY_METER.CALIBRATE, not sure why that is not working for you.

DirkStorck commented 2 years ago

OK, thank you. Will try again.

bramstroker commented 2 years ago

@DirkStorck did you manage to get it to work? Can we close this issue?

DirkStorck commented 2 years ago

Hi,

didn't had the time to look further into it till now, but yes issue can be closed. Working now. Thank you!

I even found a way to reset all sensors at one time reset-values-of-utility-meter

1 - remove powercal and sensors/groups from configuration.yaml. 2 - Restarting HA 3 - Remove the sensor from HA 4 - Restarting HA 5 - Deleting that device out of the ../homeassistant/.storage/core.restore_state file and then restarting HA. 6 - Once restarted, recreate the sensor with the same name and it was reset. I had to wait a minute or two for the energy meter to increase in value so the sensor would initialize. 7 - ADD powercal and sensors/groups from configuration.yaml.

hint to 3: To delete the senors I have used this page grafik

bramstroker commented 2 years ago

thanks for posting the information. Can help others searching in the future. Closing this issue.