Add bimonthly period feature for utility_meter component (#39931)
This commit is contained in:
1 parent
56ba4907e1
commit
c8d5500441
3 files changed
+27
-2
No files matched your search
@@ -24,6 +24,7 @@ import homeassistant.util.dt as dt_util
|
||||
|
||||
from .const import (
|
||||
ATTR_VALUE,
|
||||
BIMONTHLY,
|
||||
CONF_METER,
|
||||
CONF_METER_NET_CONSUMPTION,
|
||||
CONF_METER_OFFSET,
|
||||
@@ -204,6 +205,12 @@ class UtilityMeterSensor(RestoreEntity):
|
||||
and now != date(now.year, now.month, 1) + self._period_offset
|
||||
):
|
||||
return
|
||||
if (
|
||||
self._period == BIMONTHLY
|
||||
and now
|
||||
!= date(now.year, (((now.month - 1) // 2) * 2 + 1), 1) + self._period_offset
|
||||
):
|
||||
return
|
||||
if (
|
||||
self._period == QUARTERLY
|
||||
and now
|
||||
@@ -241,7 +248,7 @@ class UtilityMeterSensor(RestoreEntity):
|
||||
minute=self._period_offset.seconds // 60,
|
||||
second=self._period_offset.seconds % 60,
|
||||
)
|
||||
elif self._period in [DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY]:
|
||||
elif self._period in [DAILY, WEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, YEARLY]:
|
||||
async_track_time_change(
|
||||
self.hass,
|
||||
self._async_reset_meter,
|
||||
|
||||
Reference in new issue
Block a user