Skip to content

Commit 0cfae4d

Browse files
committed
various string fixes and improvements
1 parent d9b3319 commit 0cfae4d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

apps/automoli/automoli.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
SENSORS_OPTIONAL = ["humidity", "illuminance"]
5252

5353
RANDOMIZE_SEC = 5
54+
SECONDS_PER_MIN: int = 60
5455

5556

5657
# version checks
@@ -269,7 +270,7 @@ async def switch_daytime(self, kwargs: Dict[str, Any]) -> None:
269270
self.lg(
270271
f"set {hl(self.room.capitalize())} to {hl(daytime['daytime'])} → "
271272
f"{'scene' if is_scene else 'brightness'}: {hl(light_setting)}"
272-
f"{'' if is_scene else '%'}, delay: {hl(delay)}sec",
273+
f"{'' if is_scene else '%'}, delay: {hl(natural_time(delay))}",
273274
icon=DAYTIME_SWITCH_ICON,
274275
)
275276

@@ -381,7 +382,7 @@ async def lights_on(self) -> None:
381382
f"{hl(self.room.capitalize())} turned {hl(f'on')} → "
382383
f"{'hue' if self.active['is_hue_group'] else 'ha'} scene: "
383384
f"{hl(light_setting.replace('scene.', ''))}"
384-
f" | delay: {hl(self.active['delay'])}sec",
385+
f" | delay: {hl(natural_time(int(self.active['delay'])))}",
385386
icon=ON_ICON,
386387
)
387388

@@ -407,7 +408,7 @@ async def lights_on(self) -> None:
407408
self.lg(
408409
f"{hl(self.room.capitalize())} turned {hl(f'on')} → "
409410
f"brightness: {hl(self.active['light_setting'])}%"
410-
f" | delay: {hl(self.active['delay'])}sec",
411+
f" | delay: {hl(natural_time(int(self.active['delay'])))}",
411412
icon=ON_ICON,
412413
)
413414

@@ -435,7 +436,7 @@ async def lights_off(self, kwargs: Dict[str, Any]) -> None:
435436
await self.refresh_timer()
436437
self.lg(
437438
f"🛁 no motion in {hl(self.room.capitalize())} since "
438-
f"{hl(self.active['delay'])}sec → "
439+
f"{hl(natural_time(int(self.active['delay'])))} → "
439440
f"but {hl(current_humidity)}%RH > "
440441
f"{hl(humidity_threshold)}%RH"
441442
)
@@ -449,7 +450,7 @@ async def lights_off(self, kwargs: Dict[str, Any]) -> None:
449450
await self.call_service("homeassistant/turn_off", entity_id=entity)
450451
self.lg(
451452
f"no motion in {hl(self.room.capitalize())} since "
452-
f"{hl(self.active['delay'])}sec → turned {hl(f'off')}",
453+
f"{hl(natural_time(int(self.active['delay'])))} → turned {hl(f'off')}",
453454
icon=OFF_ICON,
454455
)
455456

@@ -544,7 +545,7 @@ def show_info(self, config: Optional[Dict[str, Any]] = None) -> None:
544545
room = f" · {hl(self.config['room'].capitalize())}"
545546

546547
self.lg("")
547-
self.lg(f"{hl(APP_NAME)}{room}", icon=self.icon)
548+
self.lg(f"{hl(APP_NAME)} v{hl(__version__)}{room}", icon=self.icon)
548549
self.lg("")
549550

550551
listeners = self.config.pop("listeners", None)

0 commit comments

Comments
 (0)