Skip to content

Commit

Permalink
Moving ScadaInit from SynthGenerator to AA
Browse files Browse the repository at this point in the history
  • Loading branch information
thdfw committed Jan 6, 2025
1 parent 95f00e4 commit fc83be1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion gw_spaceheat/actors/atomic_ally.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from actors.scada_actor import ScadaActor
from actors.scada_data import ScadaData
from actors.synth_generator import WeatherForecast
from named_types import RemainingElec
from named_types import RemainingElec, ScadaInit


class AtomicAllyState(GwStrEnum):
Expand Down Expand Up @@ -315,6 +315,7 @@ def check_and_update_state(self) -> None:

async def main(self):
await asyncio.sleep(2)
self._send_to(self.primary_scada, ScadaInit(FromGNodeAlias=self.layout.atn_g_node_alias))
# SynthGenerator gets weather ASAP on boot, including various fallbacks
# if the request does not work. So wait a bit if
if self.weather is None:
Expand Down
5 changes: 1 addition & 4 deletions gw_spaceheat/actors/scada.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,7 @@ def update_env_variable(self, variable, new_value) -> None:
with open(dotenv_filepath, 'w') as file:
line_exists = False
for line in lines:
if (line.startswith(f"{variable}=")
or line.startswith(f"{variable}= ")
or line.startswith(f"{variable} =")
or line.startswith(f"{variable} = ")):
if line.strip().startswith(f"{variable}="):
file.write(f"{variable}={new_value}\n")
line_exists = True
else:
Expand Down
3 changes: 1 addition & 2 deletions gw_spaceheat/actors/synth_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from actors.scada_actor import ScadaActor
from data_classes.house_0_names import H0CN
from named_types import EnergyInstruction, Ha1Params, RemainingElec, ScadaInit
from named_types import EnergyInstruction, Ha1Params, RemainingElec
from pydantic import Field

# -------------- TODO: move to named_types -------------
Expand Down Expand Up @@ -130,7 +130,6 @@ async def main(self):
async def main_loop(self, session: aiohttp.ClientSession) -> None:
await self.get_weather(session)
await asyncio.sleep(2)
self._send_to(self.primary_scada, ScadaInit(FromGNodeAlias=self.layout.atn_g_node_alias))
while not self._stop_requested:
self._send(PatInternalWatchdogMessage(src=self.name))

Expand Down

0 comments on commit fc83be1

Please sign in to comment.