Skip to content

Commit

Permalink
fixed "off" coding config; throttling adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Dec 11, 2020
1 parent 2ab9d7d commit 4ede90e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
20 changes: 11 additions & 9 deletions custom_components/lunos/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ def __init__(self, hass, conf, name, relay_w1, relay_w2, default_speed: str = DE

self.hass = hass
self._name = name
#self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, name, hass=hass)
self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, name, hass=hass)
super().__init__()

#LOG.info(f"Creating FanEntity hass={hass} {self.hass}")

self._speed = None
self._default_speed = default_speed

Expand Down Expand Up @@ -166,17 +164,21 @@ def _relay_state_changed(self, event):
LOG.info(f"{entity} changed from {from_state} to {to_state}, updating '{self._name}'")
self.schedule_update_ha_state()


def update_attributes(self):
""" Calculate the current CFM based on the current fan speed as well as the
number of fans configured by the user. """
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]

# load the behaviors of the fan for the current speed setting
behavior = controller_config['behavior'].get(self._speed)
behavior_config = controller_config.get('behavior')
if not behavior_config:
LOG.error(f"Missing behavior config for coding {coding}: {controller_config}")
behavior = behavior_config.get(self._speed, {})

# determine the air flow rates based on fan behavior at the current speed
cfm = cmh = None
Expand Down Expand Up @@ -288,8 +290,8 @@ async def async_update(self):

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

# update the speed state, if a change has been detected
await self._throttle_state_changes(SPEED_CHANGE_DELAY_SECONDS)
# throttle to allow switch changes to converge
await self._throttle_state_changes(1.0)
current_speed = self._determine_current_speed()

if current_speed != self._speed:
Expand Down Expand Up @@ -342,7 +344,7 @@ async def async_clear_filter_reminder(self):
def supports_summer_ventilation(self):
coding = self._attributes[CONF_CONTROLLER_CODING]
controller_config = LUNOS_CODING_CONFIG[coding]
return controller_config['supports_summer_vent'] == True
return controller_config['supports_summer_vent']

# flipping W2 within 3 seconds instructs the LUNOS controller to turn on summer ventilation mode
async def async_turn_on_summer_ventilation(self):
Expand All @@ -353,7 +355,7 @@ async def async_turn_on_summer_ventilation(self):
LOG.info(f"Enabling summer ventilation mode for LUNOS '{self._name}'")
await self.toggle_relay_to_set_lunos_mode(self._relay_w2)

self._attributes[ATTR_VENTILATION_MODE] = VENTILATION_SUMMER
self._attributes[ATTR_VENTILATION_MODE] = VENTILATION_SUMMER

async def async_turn_off_summer_ventilation(self):
if not self.supports_summer_ventilation():
Expand Down
30 changes: 15 additions & 15 deletions custom_components/lunos/lunos-codings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ e2:
supports_filter_reminder: true
heat_recovery_efficiency: 0.906
behavior:
off:
"off":
cmh: 0
cfm: 0
dB: 0
Expand All @@ -31,7 +31,7 @@ e2-4speed:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
cmh: 15
low:
cmh: 20
Expand All @@ -50,7 +50,7 @@ e2-short:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -73,7 +73,7 @@ e2-usa:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -99,7 +99,7 @@ e2-usa-v2:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -126,7 +126,7 @@ e2-short-usa:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior: # STRANGE: different sources specific different CFM
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -152,7 +152,7 @@ e2-nz:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -179,7 +179,7 @@ e2-60:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior: # STRANGE: different sources specific different CFM
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -200,7 +200,7 @@ ego:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cfm: 0
watts: 0
Expand All @@ -224,7 +224,7 @@ ego-4speed:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
cmh: 5
dB: 0
low:
Expand All @@ -247,7 +247,7 @@ ego-exhaust-4speed:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
cmh: 5
dB: 0
low:
Expand All @@ -270,7 +270,7 @@ ego-exhaust:
supports_summer_vent: true
summer_vent_cycle_seconds: 3600
behavior:
off:
"off":
dB: 0
cmh: 0
watts: 0
Expand All @@ -291,7 +291,7 @@ ra-15-60:
turbo_mode: true # flip W2 on/off < 3 seconds = 60 m3/h
exhaust_only: true # not a HRV
behavior:
off:
"off":
dB: 0
cmh: 0
watts: 0
Expand All @@ -317,7 +317,7 @@ ra-15-60-high:
supports_filter_reminder: true
exhaust_only: true # not a HRV
behavior:
off:
"off":
dB: 0
cmh: 0
watts: 0
Expand All @@ -337,7 +337,7 @@ ra-15-60-4speed:
supports_filter_reminder: true
exhaust_only: true # not a HRV
behavior:
off:
"off":
cmh: 15
watts: 0.6
dB: 19.5
Expand Down

0 comments on commit 4ede90e

Please sign in to comment.