Powercalc - Virtual power sensors

Tuya. I will check tomorrow if this happens with other lights provided by this integration as well and create a bug report.
Thanks.

Yes you should definitely create a bug report at Tuya component.
Nevertheless I fixed it also in my integration, so it will never create wrong power readings , see this Pull Request.
Will be in next release v0.5.3

2 Likes

@bramski What Happend in version v0.5?
I made update and Lost kWh in grouped sensor.

Is config changed?

Not sure why this happened.
There has been some changes in naming of the power and energy sensors, maybe this is related. See #106 and #108. However when the entity_id of the power sensor would have changed in your situation than the grouped sensor should not work at all.

How is this group sensor configured?

It’s grouped according to the manual which you updated a week or two weeks ago.

- platform: template
  sensors:
    all_lights_consumption:
      friendly_name: "Total Light Consumption"
      unit_of_measurement: kWh
      value_template: >-
        {{states('sensor.garderoba_energy') | float + states('sensor.spizarnia_hue_energy') | float [...] }}
      attribute_templates:
        last_reset: "2021-08-01T00:00:00+00:00"
        state_class: measurement
        device_class: energy
        icon_template: mdi:transmission-tower

But I check template in Developers Tools → Templates, and now I have only 6 energy - before more than 20.

ENERGY SENSORS:

{% for state in states -%}
{%- if  'energy' in state.entity_id and state.attributes.device_class == "energy" -%}
  states('{{ state.entity_id }}') | float +
{% endif -%}
{%- endfor -%}

I found what might cause a problem. I’ve got a 24 powercalc (Power) sensors but only 6 energy sensors.
The reason is that energy sensors changed names. ex:
Previously I had: sensor.oswietlenie_taras_power + sensor.oswietlenie_taras_energy
Now I have: sensor.oswietlenie_taras_power + sensor.taras_light_energy

It looks that energy and power change naming is different.

@bramski Is that actually changed?

Yes it has changed that the entity_ids from power and energy sensors should both be extracted from the source entity_id in your case switch.taras_light. Previously the entity_id was constructed from the name (or friendly name), and this was actually wrong (unwanted) behaviour.

So in your case you should have:
sensor.taras_light_power and sensor.taras_light_energy. The reason why the power sensor has not changed the entity_id would be because it has a unique id assigned and already exists in your installation with sensor.oswietlenie_taras_power. The integration is than unable to change the entity_id I think.
So what you could try is to change the entity_id from sensor.oswietlenie_taras_power to sensor.taras_light_power.

This renaming of entities is only once. From now it should stay this way. Sorry for the inconvenience.

I wondering if I can change entity id of _energy sensors - it will be easier for me because it’s already in template sensor.

Or it will broke again after HA restart?

BTW. I see now that energy sensors doesn’t have a device_class = energy

state_class: measurement
last_reset: 2021-08-30T15:14:43.704624+00:00
source: sensor.taras_light_power
source_entity: switch.taras_light
source_domain: switch
friendly_name: Oświetlenie Taras energy
icon: mdi:lightning-bolt

Not sure about all the magic in HA internals. But I would say it is better to rename the power sensors as this is in line with the way powercalc would name them. Also it’s more logical when looking at your entity listing, as the energy and power sensors have the exact same entity_id as the source entity only postfixed with _power and _energy. This would prevent any unwanted side effects and other things I can’t forsee. It’s only a one time process to do it now, to also rename your template sensors.
I’m pretty confident I don’t need to do any major changes in the naming logic in the future, so it will stay this way.

OK i manually changed a _power sensor entity_id. Hope it will work correctly from now.

I saw in change log that you added a utility_meter. I didn’t check that but for a energy dashboard is better to add normal summary entity or utility_meter? Or maybe it will works with both types for entity?

Under the hood this energy sensor is just an integration sensor. I have looked into the code of this component, and it seems the device class energy will be set after the first integration is calculated. So it’s just a matter of time I think.

As far as I know you have to use the total collection energy meter (the one that never resets), in your case “Oświetlenie Taras energy”. The utility meters can be used in lovelace dashboard, or automations etc. Not sure if they already have a use in the energy dashboard.

Thanks for your all help and patience.
This integration with help of community might be one of the best extension to HA!

I saw there is a idea to simplify a process of testing and adding new models of bulbs. That might be a great opportunity to grow this integration community. I’m also slowly preparing for helping with that.

Your welcome.
Yes I did a rewrite of measure script to support more power meters and also we are working on better readme / wiki to help people getting this up and running, so more can contribute for new light models.

I’ve updated to 2021.9.0 and I have error in Energy Configuration

Unexpected state class
The following entities do not have the expected status class „total_increasing”

  • sensor.all_lights_consumption (measurement)

(translated)

1 Like

Is this sensor created by powercalc integration or is this a template sensor you created yourself? Looking at the naming I suspect the second.

As always you are right.
Im not sure if is just state_class changed from measurement to total_increasing?

Yes that’s something changed in home assistent 2021.9. You can just change the state class. Also last reset is not neccesary anymore afaik

Hi,
didn’t had the time yet to thank you for fixing adjusting it that quick!
Thanks!

1 Like

Hello,

First of all, thank you so much for this component! Putting actual numbers on energy consumption is the best way to make people realise what the situation is, and what can be done. :heart:

I’ve read the documentation and this thread entirely, but I’m afraid I missed something obvious:

Let’s say I have an appliance I know the consumption of, but which has no entity related to it in HA. My freezer for example, whose power draw I know, and whose total consumption I’d like to keep track of.

Is there a way for me to declare that “this thing called ‘a freezer’ is constantly drawing 30W”, so that in the end I can have it show up in the new Energy “individual device” monitoring?

The component supports input_boolean so create one, set it to true and then set up this in powercalc:

  - platform: powercalc
    entity_id: input_boolean.freezer  
    fixed:
      power: 30
3 Likes