Skip to content

Commit

Permalink
onpeak-backup node sends messages to relays correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamillar committed Jan 4, 2025
1 parent e4d9bfe commit 2d14fab
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions gw_spaceheat/actors/home_alone.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,12 @@ def trigger_house_cold_onpeak_event(self) -> None:
- reports top state change
"""
if not self.house_is_cold_onpeak():
self.log("Not triggering HouseColdOnpeak top event - house is not cold onpeak!")
if not self.top_state == HomeAloneTopState.Normal:
self.log("Not triggering HouseColdOnpeak top event - not in top state Normal!")
# if not self.house_is_cold_onpeak():
# self.log("Not triggering HouseColdOnpeak top event - house is not cold onpeak!")
# return
# if not self.top_state == HomeAloneTopState.Normal:
# self.log("Not triggering HouseColdOnpeak top event - not in top state Normal!")
# return
# implement the change in command tree. Boss: h.n -> h.onpeak-backup
self.set_onpeak_backup_command_tree()
# and let the normal homealone know its dormant until further notice
Expand Down Expand Up @@ -481,7 +483,10 @@ def leaving_onpeak_backup_actuator_actions(self) -> None:
SendTimeUnixMs=int(time.time() * 1000),
TriggerId=str(uuid.uuid4()),
)
self._send_to(self.hp_failsafe_relay, event)
self.services.send(Message(Src=self.onpeak_backup_node.name,
Dst=self.hp_failsafe_relay.name,
Payload=event))

self.log(
f"{self.onpeak_backup_node.handle} sending SwitchToTankAquastat to Hp Failsafe {H0N.hp_failsafe_relay}"
)
Expand All @@ -497,7 +502,10 @@ def leaving_onpeak_backup_actuator_actions(self) -> None:
SendTimeUnixMs=int(time.time() * 1000),
TriggerId=str(uuid.uuid4()),
)
self._send_to(self.aquastat_control_relay, event)
self.services.send(Message(Src=self.onpeak_backup_node.name,
Dst=self.hp_failsafe_relay.name,
Payload=event))

self.log(
f"{self.node.handle} sending SwitchToScada to Boiler Ctrl {H0N.aquastat_ctrl_relay}"
)
Expand All @@ -513,6 +521,8 @@ def onpeak_backup_actuator_actions(self) -> None:
- turn on heat pump
Expects set_onpeak_backup_command_tree already called, with self.onpeak_backup_node as boss
WEAKNESS: SENDS MESSAGES TO RELAY ONLY VIA INTERNAL python QUEUE. WILL FAIL
IF HOME ALONE IS PUT IN A DIFFERENT PROCESS THAN THE ACTUATORS
"""

if self.settings.oil_boiler_for_onpeak_backup:
Expand All @@ -528,7 +538,14 @@ def onpeak_backup_actuator_actions(self) -> None:
SendTimeUnixMs=int(time.time() * 1000),
TriggerId=str(uuid.uuid4()),
)
self._send_to(self.hp_failsafe_relay, event)
# CANNOT USE _send_to because that sends a message from the actor's node
# and this message needs to come from onpeak_backup_node
# NOTE: THIS ASSUMES THE RELAY IS IN THE SAME CODEBASE AS
# HOMEALONE.
self.services.send(Message(Src=self.onpeak_backup_node.name,
Dst=self.hp_failsafe_relay.name,
Payload=event))

self.log(
f"{self.onpeak_backup_node.handle} sending SwitchToTankAquastat to Hp Failsafe {H0N.hp_failsafe_relay}"
)
Expand All @@ -544,9 +561,11 @@ def onpeak_backup_actuator_actions(self) -> None:
SendTimeUnixMs=int(time.time() * 1000),
TriggerId=str(uuid.uuid4()),
)
self._send_to(self.aquastat_control_relay, event)
self.services.send(Message(Src=self.onpeak_backup_node.name,
Dst=self.hp_failsafe_relay.name,
Payload=event))
self.log(
f"{self.node.handle} sending SwitchToScada to Boiler Ctrl {H0N.aquastat_ctrl_relay}"
f"{self.onpeak_backup_node.handle} sending SwitchToScada to Boiler Ctrl {H0N.aquastat_ctrl_relay}"
)
except ValidationError as e:
self.log(f"Tried to switch AquastatCtrl relay to Boiler but didn't have the rights: {e}")
Expand Down

0 comments on commit 2d14fab

Please sign in to comment.