bramstroker / homeassistant-powercalc

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

Energy sensor have mixed kWh or Wh as unit #2372

Closed erkr closed 2 weeks ago

erkr commented 2 weeks ago

System Health details

Na

Checklist

Describe the issue

For some reason the energy sensors gevraagd by Powercalc are a mix of Wh and kWh. I think they all should be kWh, but the mix causes issues when automatically populating graphs. Here are the sensors Powercalc generated for me: image

I thought I was clever chasing the entity units, but that gets lost after a restart Doing something wrong? The device class is also weird, most are total, one is total increasing?!

I hope you have a suggestion how to tackle this

Reproduction steps

1. 2. 3. ...

Debug logs

Na

Diagnostics dump or YAML config

Na

bramstroker commented 2 weeks ago

What's the unit of the source power sensor for Beestenboel and Keuken for example? How did you setup powercalc configuration for these? Which kind of powercalc sensor (group, virtual power, real power etc)?

erkr commented 2 weeks ago

Those are all grouped plain lights. Example:

    - create_group: keuken lights
      unique_id: powercalc_group_keuken_lights
      create_energy_sensor: true
      force_calculate_group_energy: true
      entities:
      - entity_id: light.plafonniere
        standby_power: 0.4
        fixed:
          power: 16.5      
      - entity_id: light.eettafel
        standby_power: 0.4
        linear: 
          min_power: 2.0
          max_power: 15.0
      - entity_id: light.aanrecht
        standby_power: 0.4
        linear: 
          min_power: 5.0
          max_power: 15.0
      - entity_id: light.rasp
      - entity_id: light.draak
      - entity_id: light.keukenkast
        standby_power: 0.4
        linear: 
          min_power: 5.0
          max_power: 15.0
      - entity_id: light.hue_bloom_1
      - entity_id: light.hue_lightstrip_1

What they have in common is that I use the forced group calculation

erkr commented 2 weeks ago

All these lights are grouped again in all lights, using the normal grouping without the force option:

  - create_group: all lights
    unique_id: powercalc_group_all_lights
    create_energy_sensor: true
    force_calculate_group_energy: false
    entities:

That one is in kWh!

bramstroker commented 2 weeks ago

What they have in common is that I use the forced group calculation

That's exactly what I wanted to ask. (was editing your own question lol, had a hard and long day at work, really tired ;-)) Will have a look in a few days.

bramstroker commented 2 weeks ago

Could you also share the attributes from developer tools for the power sensors, especially the unit of measurement? So for sensor.all_lights_power, sensor.beestenboel_power, sensor.keuken_lights_power

erkr commented 2 weeks ago

Of course 😊 Keuken lights power:

state_class: measurement
entities:
  - sensor.plafonniere_power
  - sensor.hue_lightstrip_1_power
  - sensor.aanrecht_power
  - sensor.draak_power
  - sensor.rasp_power
  - sensor.keukenkast_power
  - sensor.hue_bloom_1_power
  - sensor.eettafel_power
is_group: true
unit_of_measurement: W
device_class: power
friendly_name: keuken lights power

Beestenboel:

state_class: measurement
entities:
  - sensor.innr_sp_120_38ea6103_electrical_measurement
  - sensor.ikea_of_sweden_tradfri_control_outlet_eefa8dfe_on_off_device_power
  - sensor.innr_sp_120_38ea6103_on_off_device_power
  - sensor.ikea_of_sweden_tradfri_control_outlet_c44e05fe_on_off_device_power
is_group: true
unit_of_measurement: W
device_class: power
friendly_name: beestenboel lights power

All lights:

state_class: measurement
entities:
  - sensor.vitrinekast_power
  - sensor.hue_bloom_1_2_power
  - sensor.schutting_power
  - sensor.olie_lamp_power
  - sensor.innr_sp_120_38ea6103_on_off_device_power
  - sensor.black_light_power
  - sensor.kast_power
  - sensor.licht_bollen_snoer_power
  - sensor.hue_bloom_1_power
  - sensor.vogie_power
  - sensor.schemer_lamp_power
  - sensor.voordeur_power
  - sensor.poort_power
  - sensor.plafonniere_power
  - sensor.tuinhuis_power
  - sensor.overloop_power
  - sensor.fietsenhok_power
  - sensor.serre_dak_power
  - sensor.tv_lamp_power
  - sensor.zithoek_power
  - sensor.leeslamp_power
  - sensor.bureau_power
  - sensor.bureau_koof_power
  - sensor.tuintafel_power
  - sensor.eettafel_power
  - sensor.slaapkamer_2_power
  - sensor.salon_tafel_power
  - sensor.hue_ambiance_spot_1_power
  - sensor.kerst_lampjes_device_power
  - sensor.hue_lightstrip_1_power
  - sensor.ikea_of_sweden_tradfri_control_outlet_eefa8dfe_on_off_device_power
  - sensor.innr_sp_120_38ea6103_electrical_measurement
  - sensor.draak_power
  - sensor.ikea_of_sweden_tradfri_control_outlet_c44e05fe_on_off_device_power
  - sensor.wand_power
  - sensor.rasp_power
  - sensor.keukenkast_power
  - sensor.slaapkamer_1_power
  - sensor.aanrecht_power
  - sensor.zout_lamp_power
is_group: true
unit_of_measurement: W
device_class: power
friendly_name: all lights power
erkr commented 2 weeks ago

And the generated energy sensors. All lights:


state_class: total
entities:
  - sensor.woonkamer_lights_energy
  - sensor.automatic_lights_energy
  - sensor.slaapkamer_lights_energy
  - sensor.keuken_lights_energy
  - sensor.misc_lights_energy
  - sensor.beestenboel_lights_energy
  - sensor.serre_lights_energy
is_group: true
unit_of_measurement: kWh
device_class: energy
friendly_name: all lights energy

Keuken:

state_class: total_increasing
unit_of_measurement: Wh
device_class: energy
icon: mdi:lightning-bolt
friendly_name: Keuken
bramstroker commented 2 weeks ago

Thanks for the info, will have a look somewhere next days. Might have an idea why.

bramstroker commented 2 weeks ago

Should be fixed with #2376. Just release v1.13.2

erkr commented 2 weeks ago

Yes you fixed!!!! I have only have some statistics to fix😉 image