Allow sleeping during thunderstorms
This commit is contained in:
1 parent
95e6d5e275
commit
36dfa312ad
2 files changed
+33
-3
No files matched your search
@@ -20,6 +20,9 @@ class SleepWithBedStates:
|
||||
def idle(self):
|
||||
return None
|
||||
|
||||
def _is_thunderstorm(self):
|
||||
return self.g.get('weather') == 'thunderstorm'
|
||||
|
||||
def init(self):
|
||||
self.sleep_confirmed = False
|
||||
self.my_bed = False
|
||||
@@ -37,8 +40,9 @@ class SleepWithBedStates:
|
||||
|
||||
current_time = self.g.get('time')
|
||||
self.sleep_attempt_started_at = current_time
|
||||
if current_time is None or current_time < 12000:
|
||||
print('Aborting sleep, not night')
|
||||
if ((current_time is None or current_time < 12000) and
|
||||
not self._is_thunderstorm()):
|
||||
print('Aborting sleep, not night or thunderstorm')
|
||||
self.state = self.cleanup
|
||||
return
|
||||
|
||||
@@ -289,7 +293,7 @@ class SleepWithBedStates:
|
||||
print('Bed became occupied before use:', self.area)
|
||||
self.state = self.choose_bed
|
||||
return
|
||||
if current_time < 12550:
|
||||
if current_time < 12550 and not self._is_thunderstorm():
|
||||
if (self.sleep_attempt_started_at is not None and
|
||||
self.sleep_attempt_started_at >= 12000 and
|
||||
current_time < 12000):
|
||||
|
||||
Reference in new issue
Block a user