tweaked logs

This commit is contained in:
John Lancaster
2024-01-22 07:58:45 -06:00
parent e973205b06
commit 53cb116372

View File

@@ -5,7 +5,6 @@ from pathlib import Path
from typing import Dict, List from typing import Dict, List
import appdaemon.utils as utils import appdaemon.utils as utils
import astral
import yaml import yaml
from appdaemon.entity import Entity from appdaemon.entity import Entity
from appdaemon.plugins.hass.hassapi import Hass from appdaemon.plugins.hass.hassapi import Hass
@@ -24,7 +23,6 @@ def str_to_timedelta(input_str: str) -> timedelta:
@dataclass @dataclass
class RoomState: class RoomState:
scene: Dict[str, Dict[str, str | int]] scene: Dict[str, Dict[str, str | int]]
# off_duration: timedelta = field(default_factory=timedelta)
off_duration: timedelta = None off_duration: timedelta = None
time: time = None time: time = None
time_fmt: List[str] = field(default_factory=lambda : ['%H:%M:%S', '%I:%M:%S %p'], repr=False) time_fmt: List[str] = field(default_factory=lambda : ['%H:%M:%S', '%I:%M:%S %p'], repr=False)
@@ -114,10 +112,6 @@ class RoomController(Hass, Mqtt):
await self.refresh_state_times() await self.refresh_state_times()
await self.run_daily(callback=self.refresh_state_times, start='00:00:00') await self.run_daily(callback=self.refresh_state_times, start='00:00:00')
# if (ha_button := self.args.get('ha_button')):
# self.log(f'Setting up input button: {self.friendly_name(ha_button)}')
# self.listen_state(callback=self.activate_any_on, entity_id=ha_button)
async def gather_app_entities(self) -> List[str]: async def gather_app_entities(self) -> List[str]:
"""Returns a list of all the entities involved in any of the states """Returns a list of all the entities involved in any of the states
""" """
@@ -143,7 +137,7 @@ class RoomController(Hass, Mqtt):
async def refresh_state_times(self, *args, **kwargs): async def refresh_state_times(self, *args, **kwargs):
"""Resets the `self.states` attribute to a newly parsed version of the states. """Resets the `self.states` attribute to a newly parsed version of the states.
Parsed states have an absolute time for a certain day. Parsed states have an absolute time for the current day.
""" """
# re-parse the state strings into times for the current day # re-parse the state strings into times for the current day
self._room_config = RoomConfig.from_app_config(self.args) self._room_config = RoomConfig.from_app_config(self.args)
@@ -161,7 +155,7 @@ class RoomController(Hass, Mqtt):
assert isinstance(state.time, time), f'Invalid time: {state.time}' assert isinstance(state.time, time), f'Invalid time: {state.time}'
for state in self.states: for state in self.states:
self.log(f'State: {state.time.strftime("%I:%M:%S %p")} {str(state.scene)[:50]}...') self.log(f'State: {state.time.strftime("%I:%M:%S %p")} {state.scene}')
self.states = sorted(self.states, key=lambda s: s.time, reverse=True) self.states = sorted(self.states, key=lambda s: s.time, reverse=True)