Powercalc - Virtual power sensors

Fantastic module.

One thing I’d to see. Is a sensor for the combined watt usage of the light /mediaplayer by type. So is might be used to calculate the total watt and kWh of all your lights.

Thanks. Please see post Powercalc - Virtual power sensors - #17 by bramski. I think this is what you need. You can do this with the group platform and template sensor. I will also add a chapter to the readme with an example.

1 Like

You are right, only thing wrong with the fantastic template is “_power” as there are several other devices that use that term also. can you make it user definable, i’d like it to be “_powercalc” ?

as of right now, I have to make a template with 40 lines, or rename some 25 existing sensors. both takes time, and are not dynamic :frowning:

I am not sure about your question. You mean the naming of the power sensors created by the powercalc integration? When there is already a _power sensor for a device it would not make sense to setup a virtual power sensor using powercalc right?

Thats also the way I do it today.

I get this error:

2021-08-05 20:37:18 ERROR (MainThread) [custom_components.powercalc.sensor] Skipping sensor setup light.tv_room_1: ('No lookup file found for mode', 'color_temp')

2021-08-05 20:37:18 ERROR (MainThread) [custom_components.powercalc.sensor] Skipping sensor setup light.tv_room_2: ('No lookup file found for mode', 'color_temp')

The strange part, is it’s only 2 bulbs that gives this error. can you see any error?

my config

sensor:
#ikea LM11000
  - platform: powercalc
    entity_id: light.dining_skaenk
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.dimmable_light_25
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.kitchen_table_kitchen
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.kitchen_table_window
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.spisestue_1
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.spisestue_2
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.spisestue_3
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.dimmable_light_24
    manufacturer: ikea
    model: LED1623G12    
  - platform: powercalc
    entity_id: light.dimmable_light_43
    manufacturer: ikea
    model: LED1623G12    

#ikea_gu10    
  - platform: powercalc
    entity_id: light.bathroom_door
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.bathroom_shower
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.bathroom_wc
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.bathroom_window    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.kitchen_counter_1
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.kitchen_counter_2
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.kitchen_counter_3    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.kitchen_counter_4    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.kitchen_counter_5    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.master_bedroom_1    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.master_bedroom_2    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.master_bedroom_3    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.master_bedroom_4    
    manufacturer: ikea
    model: LED1650R5    
  - platform: powercalc
    entity_id: light.dimmable_light_38
    manufacturer: ikea
    model: LED1650R5    



#Ikea float (FAKE)
  - platform: powercalc
    entity_id: light.color_temperature_light_35
    manufacturer: ikea
    model: LED1536G5   
  - platform: powercalc
    entity_id: light.color_temperature_light_36
    manufacturer: ikea
    model: LED1536G5   

#Ikea 806LM (fake ikea type)
  - platform: powercalc
    entity_id: light.tv_room_1
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.tv_room_2
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.stue_have_ac
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.stue_have_door
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.stue_stander
    manufacturer: ikea
    model: LED1623G12
  - platform: powercalc
    entity_id: light.stue_ved_orn
    manufacturer: ikea
    model: LED1623G12

#hue_LWB010
  - platform: powercalc
    entity_id: light.mellemgang_syd
    manufacturer: signify
    model: LWB010
  - platform: powercalc
    entity_id: light.mellemgang_nord   
    manufacturer: signify
    model: LWB010
  - platform: powercalc
    entity_id: light.living_room_table
    manufacturer: signify
    model: LWB010



#sonos
  - platform: powercalc
    entity_id: media_player.downstairs_tv
    fixed:
      states_power:
        playing: 8.3
        paused: 4.4
        idle: 4.4
  - platform: powercalc
    entity_id: media_player.kitchen
    fixed:
      states_power:
        playing: 8.3
        paused: 4.4
        idle: 4.4        
  - platform: powercalc
    entity_id: media_player.spisestue
    fixed:
      states_power:
        playing: 8.3
        paused: 4.4
        idle: 4.4

#badevarelse spejl
  - platform: powercalc
    entity_id: light.bedevaerelse_spejl_2
    fixed:
      power: 75

  - platform: template
    sensors:
      total_bulb_power:
        unique_id: sensor_sum_bulb_power
        device_class: power
        unit_of_measurement: W
        value_template: >-
            {{ ( 
            (states('input_number.fake_power') | float) + 
            (states('sensor.badevaerelse_brus_power') | float) +
            (states('sensor.badevaerelse_dor_power') | float) +
            (states('sensor.badevaerelse_vindue_power') | float) +
            (states('sensor.badevaerelse_wc_power') | float) +
            (states('sensor.kokken_bord_1_power') | float) +
            (states('sensor.kokken_bord_2_power') | float) +
            (states('sensor.kokken_bord_3_power') | float) +
            (states('sensor.kokken_bord_4_power') | float) +
            (states('sensor.kokken_bord_5_power') | float) +
            (states('sensor.sovevaerelse_1_power') | float) +
            (states('sensor.sovevaerelse_2_power') | float) +
            (states('sensor.sovevaerelse_3_power') | float) +
            (states('sensor.sovevaerelse_4_power') | float) +
            (states('sensor.badevaerelse_spejl_power') | float) +
            (states('sensor.bedroom_door_power') | float) +
            (states('sensor.bedroom_window_power') | float) +
            (states('sensor.entre_paere_power') | float) +
            (states('sensor.gang_nord_power') | float) +
            (states('sensor.gang_syd_power') | float) +
            (states('sensor.kokken_spisebord_kokken_power') | float) +
            (states('sensor.kokken_spisebord_vindue_power') | float) +
            (states('sensor.lys_sofabord_power') | float) +
            (states('sensor.spisestue_1_power') | float) +
            (states('sensor.spisestue_2_power') | float) +
            (states('sensor.spisestue_3_power') | float) +
            (states('sensor.spisestue_spot_power') | float) +
            (states('sensor.stue_have_ac_power') | float) +
            (states('sensor.stue_have_door_power') | float) +
            (states('sensor.stue_stander_power') | float) +
            (states('sensor.stue_ved_orn_power') | float) +
            (states('sensor.trappe_opgang_power') | float) +
            (states('sensor.wc_paere_power') | float) +
            (states('sensor.spisestue_skaenk_power') | float)
            )| round(2) }}          



  - platform: integration
    source: sensor.total_bulb_power
    name: bulb_load
    unit_prefix: k
    round: 2
    unit: kWh

utility_meter:
    bulb_daily_load:
        source: sensor.bulb_load
        cycle: daily
        tariffs:
          - peak        


Hmm for that particular light model only brightness mode lookup file is available. You have set this light in color_temp mode which causes this problem. Could you please create an issue on github, than we can ask the author of this lookup file if he can provide measurements for color_temp mode

1 Like

Hi @bramski, I wanted to ask how to get the technical names of the bulbs? I saw in the Github repo that other bulbs besides Philips Hue are now supported. Among others also some Ikea lights, whose name looks more like a technical name.

However, when I try to detect the lamps automatically (I use the original Hue component) I get rather prose names and it does not find matching LUT files.
For example, the log output for my Ikea lights looks like this:

2021-08-11 19:01:33 DEBUG (MainThread) [custom_components.powercalc.sensor] Auto discovered Hue model for entity light.kuche_herd: (manufacturer=IKEA of Sweden, model=)
2021-08-11 19:01:33 INFO (MainThread) [custom_components.powercalc.sensor] Model not found in library light.kuche_herd: ('Model not supported', '')

2021-08-11 19:01:33 DEBUG (MainThread) [custom_components.powercalc.sensor] Auto discovered Hue model for entity light.treppenhaus_wandlampe_1: (manufacturer=IKEA of Sweden, model=TRADFRI bulb GU10 WS 400lm)
2021-08-11 19:01:33 INFO (MainThread) [custom_components.powercalc.sensor] Model not found in library light.treppenhaus_wandlampe_1: ('Model not supported', 'TRADFRI bulb GU10 WS 400lm')

2021-08-11 19:01:33 DEBUG (MainThread) [custom_components.powercalc.sensor] Auto discovered Hue model for entity light.wohnzimmer_weihnachtsstern: (manufacturer=IKEA of Sweden, model=TRADFRI bulb E14 WS opal 600lm)
2021-08-11 19:01:33 INFO (MainThread) [custom_components.powercalc.sensor] Model not found in library light.wohnzimmer_weihnachtsstern: ('Model not supported', 'TRADFRI bulb E14 WS opal 600lm')

I also have two different lamps from another manufacturer whose designation is exactly the same and also seems a bit strange to me:

2021-08-11 19:01:33 DEBUG (MainThread) [custom_components.powercalc.sensor] Auto discovered Hue model for entity light.kuche_esstisch: (manufacturer=ZigBee/CCT, model=CCT Light)
2021-08-11 19:01:33 INFO (MainThread) [custom_components.powercalc.sensor] Model not found in library light.kuche_esstisch: ('Model not supported', 'CCT Light')

2021-08-11 19:01:33 DEBUG (MainThread) [custom_components.powercalc.sensor] Auto discovered Hue model for entity light.wohnzimmer_stehlampe_rechts: (manufacturer=ZigBee/CCT, model=CCT Light)
2021-08-11 19:01:33 INFO (MainThread) [custom_components.powercalc.sensor] Model not found in library light.wohnzimmer_stehlampe_rechts: ('Model not supported', 'CCT Light')

Hi Simon,

Good question. Please check the conversation in this github issue. Here is the mapping in the codebase homeassistant-powercalc/const.py at 9a7a12cb1c22a5379d3eaac7478ab834736c27e2 · bramstroker/homeassistant-powercalc · GitHub.
The two Ikea lights you mentioned are not supported yet. To get them supported you’ll need to make the LUT file, lookup the Ikea modelID on the bulb and add a entry to the mapping in const.py. Would be awesome if you are able to do it.

For the other two bulbs which are detected by the Hue bridge with some generic zigbee identifier you can use the configuration to manually specify the manufacturer and model.
Asume the manufacturer is innr and the model id you find is 12345678
Than you can add the LUT files to data/innr/12345678 and use the following configuration.

sensor:
  - platform: powercalc
    entity_id: light.livingroom_floorlamp
    manufacturer: innr
    model: 12345678

This will lookup innr 12345678 regardless of the manufacturer and model detected by the Hue bridge.

Hope this helps.

Thanks for the input @bramski. That helps a lot. In fact, there are even three Ikea lamps. But one is only displayed as ' ' model :smiley:
The GU10 lamps I can unfortunately not measure, because I currently have only fixed sockets for which I can not put an electricity meter. But I’ll see what can be done with the other two Ikea lamps :wink:

By the way, maybe @Michael_Dahl used the wrong LUT information and also has the ‘TRADFRI bulb GU10 WS 400lm’ lamps instead of the specified ‘TRADFRI bulb GU10 W 400lm’ lamps?

Yes that would probably be the issue for @Michael_Dahl. These lights are almost the same, but the WS light supports both brightness and color_temp, and the W light only brightness.
So the LUT files in the repository are probably correct.

I’ve set a few bulbs.
I wish to make one sensor which will sum all lights and add it to new Energy Dash board.

I made a group of of powercalc sensors:

all_light_power:
    name: All lights power
    entities:
      - sensor.bulb_1_power
      - sensor.bulb_2_power
      - sensor.bulb_3_power

I made template sensor for sum up all powercal sensor

- platform: template
  sensors:
    all_light_power:
      friendly_name: All light power
      unit_of_measurement: W
      icon_template: mdi:transmission-tower
      value_template: >
        {{ expand('group.all_light_power') 
        | rejectattr('state', 'in', ['unavailable', 'unknown'])
        | map(attribute='state') | map('float') | sum | round(2) }}

use integration to make sum sensor

- platform: integration
  source: sensor.all_lights_power
  name: Total Light Consumption
  unit_prefix: k
  round: 2

But integration sensor return 0Wh and I am not able to add it to Energy Dashboard.

Maybe typo, sensor is sensor.all_light_power and integration is using sensor.all_lights_power ?

- platform: template
  sensors:
    all_light_power:
      friendly_name: All light power
      unit_of_measurement: W
      icon_template: mdi:transmission-tower
      value_template: >
        {{ expand('group.all_light_power') 
        | rejectattr('state', 'in', ['unavailable', 'unknown'])
        | map(attribute='state') | map('float') | sum | round(2) }}
- platform: integration
  source: sensor.all_lights_power
  name: Total Light Consumption
  unit_prefix: k
  round: 2

Ohh you’ve got a good eye :wink:

If fixed a typo and still Total Consumption is null

I got it working here, try converting to kW as your consumption shows Wh
(using new template format)
I’m going to keep this, thanks for the idea

  - name: "Lights Power"
    unit_of_measurement: kW
    device_class: power
    state: >
      {{ ((expand('group.lights_power') 
      | rejectattr('state', 'in', ['unavailable', 'unknown'])
      | map(attribute='state') | map('float') | sum) * 0.001) }}
- platform: integration
  source: sensor.lights_power
  name: Total Lights Energy
  round: 2

I’ve got en error while I try to change template

Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: unexpected ')') for dictionary value @ data['sensors']['all_light_power']['value_template']. Got "{{ expand('group.all_light_power') | rejectattr('state', 'in', ['unavailable', 'unknown']) | map(attribute='state') | map('float') | sum) * 0.001) }}\n". (See ?, line ?). 

From:

- platform: template
  sensors:
    all_light_power:
      friendly_name: All light power
      unit_of_measurement: W
      icon_template: mdi:transmission-tower
      value_template: >
        {{ expand('group.all_light_power') 
        | rejectattr('state', 'in', ['unavailable', 'unknown'])
        | map(attribute='state') | map('float') | sum | round(2) }}

to this:

- platform: template
  sensors:
    all_light_power:
      friendly_name: All light power
      unit_of_measurement: kW
      device_class: power
      icon_template: mdi:transmission-tower
      value_template: >
        {{ expand('group.all_light_power') 
        | rejectattr('state', 'in', ['unavailable', 'unknown'])
        | map(attribute='state') | map('float') | sum) * 0.001) }}

PS. I removed ) from )* 0.001)

Not sure why ?

- platform: template
  sensors:
    all_light_power:
      friendly_name: All light power
      unit_of_measurement: kW
      device_class: power
      icon_template: mdi:transmission-tower
      value_template: >
        {{ ((expand('group.all_light_power') 
        | rejectattr('state', 'in', ['unavailable', 'unknown'])
        | map(attribute='state') | map('float') | sum) * 0.001) }}

This looks interesting.

I’ve had a very detailed page for tracking smart plugs with energy monitoring. So this’ll be interesting to add lights that i can’t easily monitor energy on.

Your issue is: “integration”, only updates when there is a change.

I have an “input_number” added to my group, and an automation that every changes the value from 0.01 and back to 0.00, that way I’m forcing an update, also for “off” lights

Is it possible to manually add standby_usage to LUT method?
For about 20 bulbs (ikea/hue) only LWT010 shows standby usage 0,39W.

I wish to sum all Zigbee lights also in standby

Hey, Great looking integration.

I have just been trying it. I have 2 of the exact same Hue Bulbs on the ceiling in our conservatory named:

light.conservatory_ceiling_1
light.conservatory_ceiling_2
light.conservatory_ceiling_3

I have managed to add the first one, But when I try added the 2nd and 3rd I get the following error, But they are all the same model bulb

This error originated from a custom integration.

Logger: custom_components.powercalc.sensor
Source: custom_components/powercalc/sensor.py:142
Integration: Power consumption (documentation, issues)
First occurred: 23:16:43 (2 occurrences)
Last logged: 23:16:43

Skipping sensor setup light.conservatory_ceiling_2: ('No lookup file found for mode', 'hs')
Skipping sensor setup light.conservatory_ceiling_3: ('No lookup file found for mode', 'hs')

Any help appreciated.

Thanks