Skip to content

Commit

Permalink
updated logging levels
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Dec 11, 2020
1 parent 4ede90e commit 57887ad
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions custom_components/lunos/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(self, hass, conf, name, relay_w1, relay_w2, default_speed: str = DE

self._speed = None
self._default_speed = default_speed
self._last_state_change = None

# specify W1/W2 relays to use
self._relay_w1 = relay_w1
Expand Down Expand Up @@ -134,7 +135,6 @@ def __init__(self, hass, conf, name, relay_w1, relay_w2, default_speed: str = DE
self._update_speed( self._determine_current_speed() )

LOG.info(f"Created LUNOS fan controller '{self._name}' (W1={relay_w1}; W2={relay_w2}; default_speed={default_speed})")
LOG.info(f"LUNOS Entity: {self.entity_id}")

async def async_added_to_hass(self) -> None:
""" Once entity has been added to HASS, subscribe to state changes. """
Expand Down Expand Up @@ -170,7 +170,6 @@ def update_attributes(self):
if self._speed is not None:
coding = self._attributes[CONF_CONTROLLER_CODING]
controller_config = LUNOS_CODING_CONFIG[coding]
LOG.info(f"coding = {coding}; config = {controller_config}")

fan_multiplier = self._fan_count / controller_config[CONF_DEFAULT_FAN_COUNT]

Expand Down Expand Up @@ -237,12 +236,12 @@ def _determine_current_speed(self):
""" Probe the two relays to determine current state and find the matching speed switch state """
w1 = self.hass.states.get(self._relay_w1)
if not w1:
LOG.error(f"W1 entity {self._relay_w1} not found, cannot determine LUNOS fan speed.")
LOG.warning(f"W1 entity {self._relay_w1} not found, cannot determine LUNOS fan speed.")
return

w2 = self.hass.states.get(self._relay_w2)
if not w2:
LOG.error(f"W2 entity {self._relay_w2} not found, cannot determine LUNOS fan speed.")
LOG.warning(f"W2 entity {self._relay_w2} not found, cannot determine LUNOS fan speed.")
return

# determine the current speed based on relay W1/W2 state
Expand All @@ -263,14 +262,14 @@ async def _throttle_state_changes(self, required_delay):
time_passed = time.time() - self._last_state_change
if time_passed < required_delay:
delay = max(0, required_delay - time_passed)
LOG.error(f"To avoid LUNOS '{self._name}' controller race conditions, sleeping {delay} seconds")
LOG.warning(f"To avoid LUNOS '{self._name}' controller race conditions, sleeping {delay} seconds")
await asyncio.sleep(delay)

async def async_set_speed(self, speed: str) -> None:
""" Set the fan speed """
switch_states = SPEED_SWITCH_STATES[speed]
if not switch_states:
LOG.error(f"LUNOS fan '{self._name}' DOES NOT support speed '{speed}'; ignoring speed change.")
LOG.warning(f"LUNOS fan '{self._name}' DOES NOT support speed '{speed}'; ignoring speed change.")
return

# flipping W1 or W2 within 3 seconds instructs the LUNOS controller to either clear the
Expand All @@ -288,8 +287,6 @@ async def async_set_speed(self, speed: str) -> None:
async def async_update(self):
"""Attempt to retrieve current state of the fan by inspecting the switch state."""

LOG.info(f"{self.entity_id} async_update()")

# throttle to allow switch changes to converge
await self._throttle_state_changes(1.0)
current_speed = self._determine_current_speed()
Expand Down Expand Up @@ -349,7 +346,7 @@ def supports_summer_ventilation(self):
# flipping W2 within 3 seconds instructs the LUNOS controller to turn on summer ventilation mode
async def async_turn_on_summer_ventilation(self):
if not self.supports_summer_ventilation():
LOG.info(f"LUNOS controller '{self._name}' DOES NOT support summer ventilation")
LOG.warning(f"LUNOS controller '{self._name}' DOES NOT support summer ventilation")
return

LOG.info(f"Enabling summer ventilation mode for LUNOS '{self._name}'")
Expand Down

0 comments on commit 57887ad

Please sign in to comment.