Add bimonthly period feature for utility_meter component (#39931)

This commit is contained in:
Hareesh M U authored and GitHub committed 2020-09-15 17:52:19 +02:00
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,