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
72.56k stars 30.35k forks source link

Service "utility_meter.reset" affects all meters #114864

Closed KlausH1967 closed 6 months ago

KlausH1967 commented 6 months ago

The problem

Since the update (today 9:20AM) to version 2024.4.0, all existing utility_meter are reset by service "utility_mete.reset", although they are limited to to entities.

"Netzbezug täglich" should be reseted only at midnight "Stromzähler Einspeisung Strompreis Einspeisung variabel" should be reseted every 5min by automation. grafik

What version of Home Assistant Core has the issue?

core-2024.4.0

What was the last working version of Home Assistant Core?

core-2024.3.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

config_entry-hassio-a193d703a0861247209340eec8be0d51(1).json

Example YAML snippet

alias: Stromkosten berechnen
sequence:
  - service: input_number.set_value
    metadata: {}
    data:
      value: |-
        {{ states('input_number.stromkosten_bezug') | float + 
          (states('sensor.strompreis_bezug_variabel') | float(0) *
           states('sensor.stromzahler_bezug_strompreis_bezug_variabel') | float(0) 
          )
        }}
    target:
      entity_id: input_number.stromkosten_bezug
    enabled: true
  - service: input_number.set_value
    metadata: {}
    data:
      value: |-
        {{ states('input_number.stromkosten_einspeisung') | float +  
          (states('sensor.strompreis_einspeisung_variabel') | float(0) *
           states('sensor.stromzahler_einspeisung_strompreis_einspeisung_variabel') |float(0) 
          )
        }}
    target:
      entity_id: input_number.stromkosten_einspeisung
    enabled: true
  - service: utility_meter.reset
    target:
      entity_id:
        - select.stromzahler_bezug
        - select.stromzahler_einspeisung
    data: {}
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 6 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. - `@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)


utility_meter documentation utility_meter source (message by IssueLinks)

dgomes commented 6 months ago

Probably related to #102884

@gibwar would you have a look ?

dgomes commented 6 months ago

@KlausH1967 the file attached does not have any information about how your utility_meters are configured... could you provide that information ?

KlausH1967 commented 6 months ago

Hello, this is what I found in core.config_entry:

{
        "entry_id": "d25c4a2ccf40cb8b70da3a7b90a9e2e0",
        "version": 2,
        "minor_version": 1,
        "domain": "utility_meter",
        "title": "Stromzähler Bezug",
        "data": {},
        "options": {
          "name": "Stromzähler Bezug",
          "source": "sensor.hausanschluss_energie_bezug",
          "cycle": "none",
          "offset": 0.0,
          "tariffs": [
            "Strompreis Bezug variabel"
          ],
          "net_consumption": false,
          "delta_values": false,
          "periodically_resetting": false,
          "always_available": false
        },
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": null,
        "disabled_by": null
      },

Hope this is helpful for you Klaus

dgomes commented 6 months ago

Could you please enable debug for the utility_meter and run your automation (checking for Reset debug messages on all utility_meters)

wernervanblom commented 6 months ago

Same issue here. Nothing fancy nor complicated in my utility meters. I used the UI to create them. Simple meters linked to energy entities. Values reports accurate with no issues. Cycles works 100% (resetting themselves daily, weekly monthly etc as configured through the UI)

However... when I call the utility_meter.reset service for a specific utility meter, they all reset. Even my irrigation meter. This is from NODE RED.

I then tried to mimic the issue from within the HA Services tab under delevoper tools. After selecting "utility meter: reset" from the services list, I get the message "no matching entities found" under devices AND under entities (so none of my meters are listed under targets). The "utility meter: calibrate" service however picks up my meters and show them correctly.

Core 2024.4.1 Supervisor 2024.03.1 Operating System 12.1 Frontend 20240404.1

dgomes commented 6 months ago

Could use debug messages during the reset :/

gibwar commented 6 months ago

I then tried to mimic the issue from within the HA Services tab under delevoper tools. After selecting "utility meter: reset" from the services list, I get the message "no matching entities found" under devices AND under entities (so none of my meters are listed under targets). The "utility meter: calibrate" service however picks up my meters and show them correctly.

This is expected, you can see the referenced conversations on #102884 on how to handle the UI side. If you go to advanced mode you can enter the entity in directly to have it work. (Long story short, the selector options can't constrain to what we need so to reduce confusion it's hidden in regular mode)

dgomes commented 6 months ago

@gibwar it's not expected that reseting 1 utility_meter you end up reseting ALL utility_meters....

gibwar commented 6 months ago

@gibwar it's not expected that reseting 1 utility_meter you end up reseting ALL utility_meters....

You're definitely correct there! I was trying to refer to not being able to use the UI pickers to pick individual ones to reset. I'm still getting my environment back up and running to I can help diagnose this issue. I didn't run in to it locally last time I worked on it (months and months ago).

gibwar commented 6 months ago

I think I might have an idea on what the problem is with the condition check. Let me try a few things and if the initial tests pass (and I can replicate it) I'll push up a PR later today.

gibwar commented 6 months ago

PR to fix the issue: #115170.