core
core copied to clipboard
Unable to reset manual utility meter helpers with no tariff
The problem
When using a utility_meter helper set up with a "Meter reset cycle" of "No cycle" it is impossible to properly reset the meter to 0 and utilize the "last reset" and "last period" attributes on the helper.
What version of Home Assistant Core has the issue?
core-2023.7.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
utility_meter
Link to integration documentation on our website
https://www.home-assistant.io/integrations/utility_meter/
Diagnostics information
I'm using the utility_meter
helper integration to track filter usage on various components based on run time. Using a template sensor to extract an attribute to track with the history stats counter has been working great. When I went to go replace the filter and reset the utility meter I ran in to two problems:
- The UI to manually reset the utility meter only shows select entities.
- Even when forced with a specific entity ID manually the reset still does not work.
I suspect the issue may be related to this prior PR, #69612 as there is mention of working with backwards compatibility for 2022.7.
The "Utility Meter: Calibrate" service call with the entity of sensor.hvac_filter_usage
works as expected, it is just the "Utility Meter: Reset" service call that fails.
Example YAML snippet
Service call:
service: utility_meter.reset
target:
entity_id: sensor.hvac_filter_usage
Anything in the logs that might be useful for us?
I turned on debug logging for the above service call and see
2023-07-19 15:00:38.043 DEBUG (MainThread) [homeassistant.components.utility_meter] resetting meter utility_meter.hvac_filter_usage
but I expected to see a followup log entry from the sensor itself using this format `Reset utility meter <%s>` but did not see anything in the log.
Additional information
To fix the service call UI
ie: change https://github.com/home-assistant/core/blob/dev/homeassistant/components/utility_meter/services.yaml#L5-L6 to
reset:
target:
entity:
(or if it can support it)
reset:
target:
entity:
- domain: select
- domain: sensor
integration: utility_meter
I think the way to fix it is to update the services.yaml
file to allow all sensors (since I don't think you can combine filters) from the utility meter integration and to allow checking for itself in the reset logic as a valid value for the tariff check. I haven't made a PR with these changes as I am not fully sure the intent of this code.
To fix the actual reset call (even if unsupported in the UI)
change https://github.com/home-assistant/core/blob/dev/homeassistant/components/utility_meter/sensor.py#L539-L543 to
async def async_reset_meter(self, entity_id):
"""Reset meter."""
if self._tariff_entity != entity_id or self.entity_id != entity_id:
return
_LOGGER.debug("Reset utility meter <%s>", self.entity_id)
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)
Any updates on this? Still an issue in 2023.9.2.
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.
Not fixed, Bot.
Another vote here for changing the utility meter reset behaviour. I have a convoluted set of template sensors and automations trying to work around this issue right now.
for those waiting for this to be approved/integrated, the calibrate service can also be used to set the utility meter back to 0 as a workaround.
It should be in the 2024.4 release from what I gather. While the calibrate service can change the value the "last reset" and "last period" values won't be properly set. :D