Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Make group sensors more group sensor compliant #2149

Closed
3 tasks done
erkr opened this issue Mar 22, 2024 · 9 comments
Closed
3 tasks done

[FR] Make group sensors more group sensor compliant #2149

erkr opened this issue Mar 22, 2024 · 9 comments
Labels
enhancement New feature or request group

Comments

@erkr
Copy link

erkr commented Mar 22, 2024

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

Is your feature request related to a problem? Please describe.

The Powercalc group sensors currently list the embedded entities under the key entities in the attributes:

state_class: measurement
entities:
  - sensor.voordeur_power
  - sensor.tuinhuis_power
  - sensor.poort_power
  - sensor.overloop_power
is_group: true

Describe the solution you'd like

By changing that into entity_id, it will be recognised as a group sensor by e.g the auto entities card and expand() in templates:

state_class: measurement
entity_id:
  - sensor.voordeur_power
  - sensor.tuinhuis_power
  - sensor.poort_power
  - sensor.overloop_power
is_group: true

For i.e the auto entities card the whole group than can be simply added like this:

filter:
  include:
    - group: sensor.group_power

Describe alternatives you've considered

Enumerate entities list

Additional context

I guess this is a relative easy change, that makes usage in templates and cards more convenient.

@erkr erkr added the enhancement New feature or request label Mar 22, 2024
@erkr erkr changed the title Make group sensors more group sensor compliant [FR] Make group sensors more group sensor compliant Mar 22, 2024
@bramstroker
Copy link
Owner

@erkr Pretty sure I investigated this somewhere in the past. Could not find the issue/discussion again.
Anyways if I remember correctly there is another prerequisite in expand template function which I cannot comply (thought there is a check for platform group or something like that in code code).
Also for auto entities I have checked to support that.
I might revisit this though as I see why this can be very useful. Maybe there has been changes in HA where I can be able to get this working.

Also this would be a breaking change. People relying on entities in there template will need to adopt when I change this.

@bramstroker
Copy link
Owner

I did a quick test, but I cannot make this working for expand.

The culprit is here. Where HA checks specifically for group.* entities. Powercalc group sensors are part of sensor domain.
https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/template.py#L1270

@erkr
Copy link
Author

erkr commented Mar 22, 2024

Thanks for testing. Didn't know that expand() expects the group domain. Nice you recognise the added value for populating cards😊

@bramstroker
Copy link
Owner

For example how to do auto entities see here:
https://community.home-assistant.io/t/powercalc-virtual-power-sensors/318515/665?u=bramski

@bramstroker
Copy link
Owner

Thanks for testing. Didn't know that expand() expects the group domain. Nice you recognise the added value for populating cards😊

It was on the back of my mind somewhere. It's a pity, but they won't add any specific code for powercalc in core. Also, there is no possibility for custom components to provide entities in the group domain, that's something only core code can do.
So there is no solution unfortunately yet for the expand

@erkr
Copy link
Author

erkr commented Mar 22, 2024

Group support for cards would already be very nice. 😊 I realise it is actually breaking change.

@erkr
Copy link
Author

erkr commented Mar 22, 2024

To be honest, this integration is so useful, it should be part of core 🤗

@bramstroker
Copy link
Owner

Closing as it's not something I can fix. Example how to use with auto entities is shared above.

@erkr
Copy link
Author

erkr commented Mar 30, 2024

Yes that template works fine👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request group
Projects
None yet
Development

No branches or pull requests

2 participants