Powercalc - Virtual power sensors

This setting calculation_enabled_condition only works for virtual power sensors, not for the daily fixed energy. I will also not add that.

Unfortunately I forgot/ignored to rename of uniq_id, so the new power sensor took on the old _energy id, thereby overwriting the historical kWh. I can crecalulate that, so no harm done there.
However, when I intended to use the service powercalc.increase_daily_energy it is not available in HA development view, only a powercalc.calibrate_utility_meter which is not documented - can I use that to set the intended/re-calculated kWh value of the new enegery sensor, so that I have the accumulated consumption?

I have added my Hue-lights through Zigbee2Mqtt. I can see the unavailable state within that add-on but i do not know how i can use this status for PowerCalc (the lights are never unavailable although they are unavailable in Z2M.

I am not using Zigbee myself so don’t know this addon. Powercalc just looks at the entities in HA. So when you have a light entity light.livingroom and it is unavailable in HA than the powercalc sensor should also be unavailable by default.

First of all the powercalc.increase_daily_energy service was only implemented a few days ago and is not released yet. But this will also only work with the daily energy sensors, not with the “standard” energy sensors.
You can create a feature request on github for that. I’ll see if I can implement something similar for the standard energy sensors.
Or you have to live with the fact you don’t have the historic stats anymore.

@bramski first of all thank you for all the work on this custom integration and everyone adding measuring values. The created sensors are perfect for low cost power measuring.

But I do have a request for the integration from a management perspective. Currently in the integrations dashboard PowerCalc is shown as a tile with directly all the sensors. Since I have a large amount of sensors I was wondering if this cannot be showned like the Shelly or ZHA integrations

image

It would be much easier to navigate through a devices or entities screen

No I can’t unfortunately, each powercalc entity needs it’s own configuration persisted. This is called a config entry, and these are represented like this in the list. This is how HA presents it and there is no way for me to customize that.
Each config entry provides devices and/or entities. In case of powercalc each config entry has one power, an energy sensor, and maybe utility meters.
It’s definitely a UX issue which can be made a lot better. When you have more than a few it becomes a nightmare to maintain. I have this same issue on my installtion with my shelly’s and ESP homes where I have more than 20 of each. Can’t find what I want and there is no way to search. There was a WTH post which suggested to have the option to display it in a list, same as entities, devices, helpers etc. WTH Can't view integrations as a list instead of cards?
I suggest you all to vote on that or provide feedback if you have a better idea.
Also see FR: Improvement to Integration 0-level UI · Issue #1403 · bramstroker/homeassistant-powercalc · GitHub

2 Likes

Thanks for the reply. Just placed a vote and hopefully this will be fixed in the future. For know I am mostly glad the integration is created and with a standard naming scheme and search management can be optimized.

1 Like

Hi
just added a new heater (icehouse heater) to a group, and it is not showing up in the auto-view you so brilliantly pointed me towards :slight_smile:

Added last sensor (fixed - heater on a ikea-plug)

Restart - and it is adding a sensor (as expected):

and the sensor is listed in the attributes of the group (as exepected):

Output of the card (sum is ringt, but missing that one line for the icehouse heater.:

the actual card-code:

- type: custom:fold-entity-row
        head: sensor.pwrctrl_use_heating_power
        entities:
          - type: custom:auto-entities
            card:
              type: entities
            filter:
              template: >
                {{state_attr("sensor.pwrctrl_use_heating_power", "entities") }}
            sort:
              method: state
              reverse: true
              numeric: true

Can you look into this? I think the 'showing group-data is a powerfull feature to your solution, so it should work with all type of sensors included in a group.
Possible workarounds (have not tried them yet)

  • to create the sensor outside of the group? - would that make a difference??
  • other??

Hi
I was actually looking for something super simple, but this is waaaay better :slight_smile:
Thank you, let me try it :slight_smile:

I’m trying to clean up the interface and experimenting with the Lovelace-fold-entity-row

One of the objectives is to filter anything that has 0

However that addition of state under include does not yield any results. Tried variations but it either shows nothing or all sensors (incl 0). Also tried >1 in case there was some small value.

Any suggestions? It might be caused by how the entities are pulled from the ‘grouped’ sensor? Can it somehow be included in the template under filter?

type: custom:fold-entity-row
head:
  type: custom:mushroom-light-card
  entity: sensor.other_measured_devices_power
  name: All other measured devices
  icon: mdi:power-plug
entities:
  - type: custom:auto-entities
    filter:
      template: |
        {{state_attr("sensor.other_measured_devices_power", "entities") }}
      include:
        state: "> 0"
    card:
      type: custom:layout-card
    sort:
      method: state
      reverse: true
      numeric: true

I don’t know, I don’t see why this wouldn’t work.
When you evaluate this in developer tools {{state_attr("sensor.pwrctrl_use_heating_power", "entities") }} is it also returning the sensor.icehouse_heater_power entity_id?
I suggest you are better of asking this on auto entities topic or issue tracker, as this is not really specifically powercalc related.

Looking at auto entities documentation. It includes both filter.template and include entities, and than excludes any entities indicated with exclude.
So you should probably use exclude.

Something like this:

filter:
  template: |
    {{state_attr("sensor.other_measured_devices_power", "entities") }}
  exclude:
    state: "= 0"

Unfortunately that does work. I have now tried many things and I can get it to work with non powercalc ‘groups’. Are you sure it’s not related to @Mariusthvdb his post here? Concerning entity_id

from dev tools.

then the card;

I agree, it is not a powercalc-bug, but I got this idea from you, and I think it will be brilliant for everyone using powercalc-groups, so I took a shot and hoped you had a solution :slight_smile:
(Hoping it was something basic I’d missed)

I’ll do some more testing, and report to Auto Entities topic if I can’t figure it out :+1:

That should be unrelated, it’s only a suggested other way to include entities in the auto entities list, but you don’t have any issues with that. I did have a look into that 2 weeks ago but I cannot change that in powercalc btw because things are hardcoded in HA core.

Anyway back to the topic of excluding 0 watt entities.
I tested this on my installation and it’s working fine. Previously I had 8 entities having 0 watt, after changing the configuration all the 0 watt entities disappeared.

type: custom:fold-entity-row
head: sensor.alle_verlichting_power
entities:
  - type: custom:auto-entities
    card:
      type: entities
    filter:
      template: |
        {{state_attr("sensor.alle_verlichting_power", "entities") }}
      exclude:
        - state: unavailable
        - state: '= 0'
    sort:
      method: state
      reverse: true
      numeric: true

Not sure why this is not working on your installation. I suggest to create an issue on auto entities github when you can’t get the exclude to work properly.

I didnt think of sorting away lights that were off (using less than 1 watt) it made my list a lot cleaner, thank you, dudes!

      - type: custom:fold-entity-row
        padding: -5
        head:
          entity: sensor.kjent_stromforbruk
          name: Sanntidsforbruk
          tap_action:
            action: fire-dom-event
            fold_row: true
        entities:
          - type: custom:auto-entities
            card:
              type: entities
              style: |
                ha-card{
                  box-shadow: none;
                  background: none;
                  padding: 0px;

                }
            filter:
              include:
                - name: '*[Ss]anntid*'
                  options:
                    type: custom:template-entity-row
                    state: '{{states(''this.entity_id'') | int}} W'
                    name: >-
                      {{state_attr('this.entity_id','friendly_name').split('Sanntid')[0]}}
              exclude:
                - entity_id: sensor.eva_meter_reader_smartenergymetering
                - entity_id: sensor.billader_power
                - state: '< 0.9'
            sort:
              method: state
              reverse: true
              numeric: true

Your example also works with me. Thanks! Helps me to build up from there.

Still would love to get some ‘mushroom’ style also in the underlying layer. Anybody have any idea how to pull that off?

type: custom:fold-entity-row
head:
  type: custom:mushroom-light-card
  entity: sensor.other_measured_devices_power
  icon: mdi:dishwasher
  style: |
    ha-card {
       box-shadow: none;
    }
entities:
  - type: custom:auto-entities
    card:
      type: entities
    filter:
      template: |
        {{state_attr("sensor.other_measured_devices_power", "entities") }}
      exclude:
        - state: unavailable
        - state: '= 0'
    sort:
      method: state
      reverse: true
      numeric: true

Gives:

In the option-section you can paste the card you want it to be, example from my media-player card:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - domain: media_player
      state: playing
      options:
        type: custom:mushroom-media-player-card
        use_media_info: false
        show_volume_level: true
        icon_type: entity-picture
        volume_controls:
          - volume_set
          - volume_buttons
          - volume_mute
        collapsible_controls: false
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
            }

I’m using Powercalc for quite some time already and it works fine. But recently I got strange error; one of my sensors stopped to be created.

  # Garden Lights
  - platform: powercalc
    entity_id: light.shelly_garden_lights
    name: Garden Light
    unique_id: garden_light_power
    fixed:
      power: 120
    standby_power: 1

I have several sensors configured exactly the same way and all of them work as expected.
Recently shelly unit controlling garden lights failed and I replaced it with the new one. After some initial issues to restore device’s and entities’ names to original state everything works fine, but this particular Powercalc sensor.
Related entity (light.shelly_garden_lights) exists and properly changes its state. I do not see any errors from Powercalc in log. What could be wrong here?

Thanks but the issue seems to be that if you define the filter as ‘template’ you cannot use the options within that. You can only use the options under ‘include’ (like in your example).

So trying to re-create an include that gives me the same result as the template. Not easy…

So below is already better but the combination of attribute filter ‘power’ combines with integration ‘powercalc’ does only show a small set of the power sensors. Further testing shows it’s the integration: powercalc filter that does not return all powercalc sensors (if I remove other filters).

It seems that sensors created lik below do not get tagged with integration ‘powercalc’ only the ones that are created virtually.

Another drawback is that the powercalc groups do not play nice in auto-entities. You would expect group: sensor.all_powercalc_power to work as a group filter (like it does for instance for lights or media players, but auto-entities does not play nice. @bramski Is there anything you can do about this or is this 100% on auto-entity side?

Not tagges with powercalc as integration
    - create_group: Other measured devices
      entities:
        - entity_id: switch.zigbeeplug_tv_power
          power_sensor_id: sensor.zigbeeplug_tv_power
        - entity_id: switch.zigbeeplug_aquarium
          power_sensor_id: sensor.zigbeeplug_aquarium_power
          name: CV Ketel

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - attributes:
        device_class: power
      integration: powercalc
      options:
        type: custom:mushroom-entity-card
        entities:
          - this.entity_id
  exclude:
    - state: unavailable
    - state: '= 0'
sort:
  method: state
  reverse: true
  numeric: true