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.13k stars 29.8k forks source link

Sensor groups sum is sometimes wrong #103154

Open seblu opened 10 months ago

seblu commented 10 months ago

The problem

Sensor groups used to sum values are computing incorrect (lower) values. This is happening sometimes when HA restart.

Here is an example of 3 outlets providing their total energy consumption and a sum sensor group. The group has been created with the helpers frontend with ignore_non_numeric set to false.

Screenshot_20231101_000139 As you see, the blues lines should not have dropped.

Here is the core.config_entries

{
  "entry_id": "63b5f8eb1ad7b8c327baf1c4847453b5",
  "version": 1,
  "domain": "group",
  "title": "Room3 Energy",
  "data": {},
  "options": {
    "group_type": "sensor",
    "name": "Room3 Energy",
    "entities": [
      "sensor.room3_outlet_ne_energy",
      "sensor.room3_outlet_swl_energy",
      "sensor.room3_outlet_swr_energy"
    ],
    "hide_members": false,
    "type": "sum",
    "ignore_non_numeric": false
  },
  "pref_disable_new_entities": false,
  "pref_disable_polling": false,
  "source": "user",
  "unique_id": null,
  "disabled_by": null
}

When the sensor group state is used by an Utility Meter, it is interpreted as a reset. Then, the meter becomes crazy.

What version of Home Assistant Core has the issue?

2023.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

group

Link to integration documentation on our website

https://www.home-assistant.io/integrations/group/#sensor-groups

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 10 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.

(message by CodeOwnersMention)


group documentation group source (message by IssueLinks)

home-assistant[bot] commented 10 months ago

Hey there @dgomes, mind taking a look at this issue as it has been labeled with an integration (utility_meter) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `utility_meter` 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 utility_meter` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


utility_meter documentation utility_meter source (message by IssueLinks)

seblu commented 10 months ago

Here is the previous graph with the addition of:

seblu commented 10 months ago

I have log lines for the 23:45 unavailability of the members of the group. There is no drop in the group sensor as the 3 sensors are all unavailable at the same time.

2023-10-31 23:45:49.922 WARNING (MainThread) [homeassistant.components.group.sensor] Unable to use state. Only numerical states are supported, entity sensor.room3_outlet_ne_energy with value unknown excluded from calculation
2023-10-31 23:45:49.922 WARNING (MainThread) [homeassistant.components.group.sensor] Unable to use state. Only numerical states are supported, entity sensor.room3_outlet_swl_energy with value unknown excluded from calculation
2023-10-31 23:45:49.922 WARNING (MainThread) [homeassistant.components.group.sensor] Unable to use state. Only numerical states are supported, entity sensor.room3_outlet_swr_energy with value unknown excluded from calculation

I did find an older example with another sensor group drop with the associated log line. This time, only one member is missing. Sorry, it's not the same sensor group and members, but I have the log lines.

2023-10-28 13:53:58.815 WARNING (MainThread) [homeassistant.components.group.sensor] Unable to use state. Only numerical states are supported, entity sensor.lounge_outlet_dishwasher_energy with value unavailable excluded from calculation

Screenshot_20231101_005711

Expected behavior from the doc:

If ignore_non_numeric is false then group state will be unavailable if one member is unavailable or does not have a numeric state.

My guess is that for some reason, the sensor group is excluding members for computing the value instead returning unavailable. This is why we are seeing a decrease, and when all the sensors are together excluded there is no drop in the sensor group.

issue-triage-workflows[bot] commented 7 months 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.

seblu commented 7 months ago

bump

Gizmo0815 commented 6 months ago

I have the same issue. I sum up the energy total of two fridges in a group helper. The group helper value (dark blue in the screenshot) ocassionally drops from the sum of both entities to the value of one entity (purple in the screenshot) and then goes back to the sum of both.

grafik

I use the group helper in my energy dashboard and this behavior results in displaying an energy consumption as high as the energy total of entity two (light blue in the screenhot) for the current day(!).

grafik

Is there an option to prevent the value of the group from decreasing?

Xygen commented 5 months ago

Same issue here. A Group Sum helper sensor seems to be reset temporarily during reboot:

image

Which results in unrealistically high consumptions in the energy dashboard:

image

Helper Sensor is "state_class: total_increasing"

image

Is there a way to fix this?

frli4797 commented 4 months ago

bump

Xygen commented 4 months ago

I'm still having this issue daily. I thought it might be the one of the Shelly Plugs became unavailable temporarily... But I don't know :(

mschaeuble commented 1 month ago

@Xygen Could you solve the problem in the meantime? I have a similar problem: My group sum sensor consisting of 3 shelly devices has irregular drops (always at 02:01 AM):

image

In the HA-logs, I could find the following entries at the time the drops occur: Error fetching shellyem3-40F52000B9A4 data: Error fetching data: DeviceConnectionError()

EDIT: It looks like my problem is related to https://github.com/home-assistant/core/issues/119994

Xygen commented 1 month ago

@Xygen Could you solve the problem in the meantime? I have a similar problem: My group sum sensor consisting of 3 shelly devices has irregular drops (always at 02:01 AM):

image

In the HA-logs, I could find the following entries at the time the drops occur: Error fetching shellyem3-40F52000B9A4 data: Error fetching data: DeviceConnectionError()

EDIT: It looks like my problem is related to #119994

Unfortunately no… I‘m still fixing it manually via dev tools on a daily basis :(