home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.9k stars 30.12k forks source link

Group Sum of 2 or more Group Sum does not add unit. #119427

Open catsmanac opened 3 months ago

catsmanac commented 3 months ago

The problem

I have a group sum sensor with 2 members, both are group sum sensors, each summing 12 Riemann Integral Sum sensors. Each Rieman Sum integral integrates 1 Solar Power sensor from the Enphase_Envoy solar system (Core integration).

Solar Power sensor 1 (W) -> Rieman sum integral (kWh) +     
Solar Power sensor 2 (W) -> Rieman sum integral (kWh) +-> Group sum N.O. (kWh) -+  (<-sensor.envoy_no_productie)
.                                                     +                         |
.                                                     +                         |
Solar Power sensor 12 (W) -> Rieman sum integral (kWh)+                         +----> Group Sum N.O. + Z.W.  (<-sensor.envoy_no_zw_productie)
                                                                                |
Solar Power sensor 13 (W) -> Rieman sum integral (kWh)+                         |
Solar Power sensor 14 (W) -> Rieman sum integral (kWh)+-> Group sum Z.W. (kWh) -+  (<-sensor.envoy_zw_productie)
.                                                     +      
.                                                     +
Solar Power sensor 24 (W) -> Rieman sum integral (kWh)+

The problem is that the top level Group sum N.O. + Z.W. does not have a unit of measurement. The history graph does not show a graph, even though the output is numeric. The sum is calculated.

After each start of HA, it requires a reload of the group to get the units to show and the history show as a trend.

The dashboard with the entities:

afbeelding

What version of Home Assistant Core has the issue?

core-2024.7.0.dev0 after merge of #119021 in Dev.

What was the last working version of Home Assistant Core?

core-2024.1.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

group

Link to integration documentation on our website

https://www.home-assistant.io/integrations/group/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-06-11 18:26:54.381 WARNING (MainThread) [homeassistant.components.group.sensor] 
Unable to use state. 
Only numerical states are supported, 
entity sensor.envoy_zw_productie with value unavailable excluded from calculation in sensor.envoy_no_zw_productie

Additional information

This was also reported in #114835, only partially fixed in #119021.

home-assistant[bot] commented 3 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (group) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `group` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign group` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


group documentation group source (message by IssueLinks)

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

catsmanac commented 3 weeks ago

Issue still exists in 2024.9.1, the top level Group sum NO+ZW does not have a unit of measurement.

afbeelding

Current work-around is to use automation triggered by HA start to reload the source config entries and 3 seconds later reload the config entry for the top level group.

alias: Reload groups at HA start
description: ""
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - metadata: {}
    data: {}
    target:
      entity_id:
        - sensor.envoy_no_dagproductie
        - sensor.envoy_no_productie
        - sensor.envoy_zw_dagproductie
        - sensor.envoy_zw_productie
        - sensor.elektriciteits_productie_dagelijks
        - sensor.elektriciteits_verbruik_dagelijks
    action: homeassistant.reload_config_entry
  - data:
      level: warning
      message: HA Started, Reloading level 1 Sum groups to apply units.
    action: system_log.write
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - metadata: {}
    data: {}
    target:
      entity_id: sensor.envoy_no_zw_productie
    action: homeassistant.reload_config_entry
  - data:
      level: warning
      message: HA Started, Reloading level 2 Sum groups to apply units.
    action: system_log.write
  - metadata: {}
    data:
      message: Reloaded group sum entities
      title: Group reload
    action: notify.persistent_notification
mode: single
awfulwoman commented 2 weeks ago

I'm also still seeing this on temperature sensors grouped via the UI. I cannot see any way of adding a unit.

Screenshot 2024-09-17 at 11 55 23
catsmanac commented 5 days ago

Issue still present in 2024.10.0b0.

When using 'combine state of several sensors' to sum the 2 'Group sum' entities the UOM is present right away.

Simplified the trigger at HA start, to only reload to top level group

alias: Reload groups at HA start
description: ""
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - metadata: {}
    data: {}
    target:
      entity_id: sensor.envoy_no_zw_productie
    action: homeassistant.reload_config_entry
  - data:
      level: warning
      message: HA Started, Reloading level 2 Sum groups to apply units.
    action: system_log.write
  - metadata: {}
    data:
      message: Reloaded group sum entities
      title: Group reload
    action: notify.persistent_notification
mode: single