Powercalc - Virtual power sensors

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

auto entities looks at entity_id attribute of the group entity, powercalc defined the child entities in entities attribute, so that’s why the group filter not works. I don’t want to change that as lot of users may already depend on that. So there must be a very good reason to do so.

I understand & respect that, but maybe there is a way powercalc could (optional) create another entity eg a a ‘real’ group next to the ‘powercalc’ group? That way you maintain existing functionality but at the same time facilitate new functionality. ‘Real’ groups (and their benefits) are use-full in many cases. posted it on your github.

Alternatively I found this. Need to investigate

Only an idea, but I don’t use these auto-entities: why not add the second as well, so you don’t have to remove the existing.

Ok. Seems there is a way around this.

You can actually create dynamic groups (I did not know of) by calling group.set service like the example below. This will create a ‘real’ group called (in this case) group.test_powercalc which then behaves like a normal group and therefore can also be used by -for instance- auto entities to filter on.

I think these are non-persistent and will need to be called at startup.

service: group.set
data:
  object_id: test_powercalc
  entities: >-
     {{state_attr("sensor.other_measured_devices_power", "entities") }}
1 Like

It is not good practice for integrations to put much data in the attributes as this needs to be written on every state change, and also quickly adds to the database size.
So I want to adhere to that as much as possible.

1 Like