Add quarterly cycle for utility_meter component (#29534)
* Add quarterly tariff period to utility_meter Many tariff cycles in Australia are 3 monthly (quarterly). Add quarterly tariff cycle handling to the utility_meter component. * Add quarterly tariff period to utility_meter Many tariff cycles in Australia are 3 monthly (quarterly). Add quarterly tariff cycle handling to the utility_meter component. * Change date for test for utility_meter * Add quarterly tariff period to utility_meter Many tariff cycles in Australia are 3 monthly (quarterly). Add quarterly tariff cycle handling to the utility_meter component.
This commit is contained in:
1 parent
94b6cbc571
commit
de0db1601b
3 files changed
+17
-2
No files matched your search
@@ -25,6 +25,7 @@ from .const import (
|
||||
DAILY,
|
||||
WEEKLY,
|
||||
MONTHLY,
|
||||
QUARTERLY,
|
||||
YEARLY,
|
||||
CONF_SOURCE_SENSOR,
|
||||
CONF_METER_TYPE,
|
||||
@@ -184,6 +185,12 @@ class UtilityMeterSensor(RestoreEntity):
|
||||
and now != date(now.year, now.month, 1) + self._period_offset
|
||||
):
|
||||
return
|
||||
if (
|
||||
self._period == QUARTERLY
|
||||
and now
|
||||
!= date(now.year, (((now.month - 1) // 3) * 3 + 1), 1) + self._period_offset
|
||||
):
|
||||
return
|
||||
if self._period == YEARLY and now != date(now.year, 1, 1) + self._period_offset:
|
||||
return
|
||||
await self.async_reset_meter(self._tariff_entity)
|
||||
@@ -209,7 +216,7 @@ class UtilityMeterSensor(RestoreEntity):
|
||||
minute=self._period_offset.seconds // 60,
|
||||
second=self._period_offset.seconds % 60,
|
||||
)
|
||||
elif self._period in [DAILY, WEEKLY, MONTHLY, YEARLY]:
|
||||
elif self._period in [DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY]:
|
||||
async_track_time_change(
|
||||
self.hass,
|
||||
self._async_reset_meter,
|
||||
|
||||
Reference in new issue
Block a user