Powercalc - Virtual power sensors

Hi friend, I’m testing your application and it has been very useful for my automation, but when I try to add entities that are not automatically discovered (configured directly in configuration.yaml) they don’t work, power sensors don’t show up in my home assistant , what do I do so that I can manipulate them?

You should check the logs for errors. And maybe enable debug logging (see last chapter in readme). Hope this will give any clues what the problem is.

This is an example of a part of my configuration and my problem

switch in configuration.yaml:

  - platform: mqtt
    name: Central Cozinha
    state_topic: "mr2/status"
    command_topic: "mr2/cmd"
    payload_on: "1"
    payload_off: "0"
    state_on: "1"
    state_off: "0"

sensor in configuration.yaml:

  - platform: powercalc
    entity_id: switch.central_cozinha
    standby_usage: 0.6
    fixed:
      power: 36.9


log:

2021-07-20 17:28:51 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powercalc platform for sensor
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/home/homeassistant/.homeassistant/custom_components/powercalc/sensor.py", line 120, in async_setup_platform
    entity_name = entity_state.name
AttributeError: 'NoneType' object has no attribute 'name'

I have 5 switch entities and 2 light entities configured manually in my configuration.yaml, but none of them the electrical consumption sensor works only in auto-discoveries, what to do?

1 Like

Could you please create an issue in github? I need to make some code changes to support these entities. Will have a look into this next weekend.

2 Likes

thank you very much for your attention, i just created an issue there

1 Like

You can create a group of sensors to sum power usage of multiple powercalc sensors into a single sensor. Have a look at this github issue for an example how to do this.
The purpose of LUT files included in the component are to lookup power consumption for different brightness levels and color temperatures of a known light. The files are created by changing the light and measuring power consumption for each brightness level. Behind a shelly switch there can be all kind of different lights/appliances which we don’t know the power consumption. This is different for each user. You have to configure those sensors manually. This is not what the build in lut mode is for.

1 Like

Hi
Thanks for you plugin.
I’m eager to try using it in home assistant, but a very simple question:
How do you get the Watt display beneath the bulb?

I have added

sensor:
  - platform: powercalc
    entity_id: light.ph80

to my configuration.yaml
but from there, I’m not able to figure out, what the next step is

Cheers
Lars

Powercalc will create a seperate power sensor (entity) for your light named sensor.ph80_power. You can find this sensor in ConfigurationEntities or with the developer tools.
When this sensor is not created you should have a look into the logs for any errors.

It’s up to you to show this sensor and your light control in lovelace UI. In the example in github I am using a light card and a gauge card (these are both build in cards in home assistant)

For example:

type: vertical-stack
cards:
  - type: light
    entity: light.ph80
  - type: gauge
    entity: sensor.ph80_power

Hi,
Thanks for your answer
My problem is, I’m not getting the sensor.ph80_power entity created
I’ll try to figure it out

Cheers
Lars

Have a look at the logs. You can also enable debug logging, see the readme. Also check if your light is in the supported models list.

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.