At 9pm the constraint went active. But it seems the end time is continuously updated to the same time it started.
2019-01-15 18:19:14 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] State entities are OFF.
2019-01-15 18:19:14 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] Turning off entities, cancelling timer
2019-01-15 18:19:14 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] Turning off light.master_vanity
2019-01-15 18:19:14 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] Entering idle
2019-01-15 18:19:14 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] Resetting state
2019-01-15 18:21:54 DEBUG (SyncWorker_15) [custom_components.lightingsm.motion_master_bathroom] Sensor state change: off
2019-01-15 18:21:54 DEBUG (SyncWorker_15) [custom_components.lightingsm.motion_master_bathroom] state: idle
2019-01-15 21:00:00 DEBUG (SyncWorker_6) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:00 DEBUG (SyncWorker_6) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:00 DEBUG (SyncWorker_6) [custom_components.lightingsm.motion_master_bathroom] Exiting idle
2019-01-15 21:00:01 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:01 DEBUG (SyncWorker_9) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:02 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:02 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:03 DEBUG (SyncWorker_3) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:03 DEBUG (SyncWorker_3) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:04 DEBUG (SyncWorker_12) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:04 DEBUG (SyncWorker_12) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:05 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:05 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:06 DEBUG (SyncWorker_3) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:06 DEBUG (SyncWorker_3) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:07 DEBUG (SyncWorker_18) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:07 DEBUG (SyncWorker_18) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:08 DEBUG (SyncWorker_7) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:08 DEBUG (SyncWorker_7) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:09 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:09 DEBUG (SyncWorker_14) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:10 DEBUG (SyncWorker_5) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
2019-01-15 21:00:10 DEBUG (SyncWorker_5) [custom_components.lightingsm.motion_master_bathroom] END TIME CALLBACK. New callback set to 2019-01-15 21:00:00
2019-01-15 21:00:11 DEBUG (SyncWorker_11) [custom_components.lightingsm.motion_master_bathroom] Result of parsing: {'datetime': datetime.datetime(2019, 1, 15, 21, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>), 'sun': None, 'offset': 0}
I added a code patch from what you added in 2.4.3 as follows to see if it solves it by incrementing the date:
def end_time_callback(self, evt):
"""
Called when `end_time` is reached, will change state to `constrained` and schedule `start_time` callback.
"""
# must be reparsed to get up to date sunset/sunrise times
parsed_end = self.parse_datetime(self.end_time)
now = self.make_naive(dt.now())
if parsed_end <= now:
parsed_end += timedelta(1) # (1)
self.log.debug("END TIME CALLBACK. New callback set to %s", parsed_end)
self.end_time_event_hook = event.async_track_point_in_time(
self.hass, self.end_time_callback, parsed_end)
self.update(end_time=parsed_end)
# must be down here to make sure new callback is set regardless of exceptions
self.constrain()
def start_time_callback(self, evt):
"""
Called when `start_time` is reached, will change state to `idle` and schedule `end_time` callback.
"""
# must be reparsed to get up to date sunset/sunrise times
parsed_start = self.parse_datetime(self.start_time)
now = self.make_naive(dt.now())
if parsed_start <= now:
parsed_start += timedelta(1) # start time is tomorrow!
self.log.debug("START TIME CALLBACK."
" New callback set to %s", parsed_start)
self.start_time_event_hook = event.async_track_point_in_time(
self.hass, self.start_time_callback, parsed_start)
self.update(start_time=parsed_start)
self.enable()