Fix utility meter reset without tarrifs (#102884)
* Fix utility meter reset without tarrifs 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. With these changes the service call can now directly reset a meter in such a configuration and the UI selector has been updated to include utility meters in the selection list. Fixes #96920 * Undo UI target selection modes As requested to not cause confusion by being able to reset individual meters when using multiple tariffs. * Adjust logic to only reset standalone sensors The original logic would allow resetting meters with multiple tariffs which was an unintended side effect.
This commit is contained in:
parent
c37f1c67f1
commit
52fe0a5e96
2 changed files with 93 additions and 1 deletions
|
@ -570,7 +570,7 @@ class UtilityMeterSensor(RestoreSensor):
|
|||
|
||||
async def async_reset_meter(self, entity_id):
|
||||
"""Reset meter."""
|
||||
if self._tariff_entity != entity_id:
|
||||
if self._tariff is not None and self._tariff_entity != entity_id:
|
||||
return
|
||||
_LOGGER.debug("Reset utility meter <%s>", self.entity_id)
|
||||
self._last_reset = dt_util.utcnow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue