Skip to content

Commit

Permalink
check & update state immediately upon getting energy instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamillar committed Dec 22, 2024
1 parent 883cb0b commit dd9b279
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions gw_spaceheat/actors/atomic_ally.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import asyncio
from typing import Sequence
from enum import auto
import uuid
import time
import uuid
from enum import auto
from typing import Sequence

import pytz
from data_classes.house_0_names import H0CN, H0N
from gw.enums import GwStrEnum
from gwproactor import ServicesInterface, MonitoredName
from gwproactor import MonitoredName, ServicesInterface
from gwproactor.message import PatInternalWatchdogMessage
from gwproto import Message
from actors.scada_data import ScadaData
from gwproto.enums import FsmReportType
from gwproto.named_types import (Alert, FsmAtomicReport, FsmFullReport,
MachineStates)
from named_types import EnergyInstruction, GoDormant, Ha1Params, WakeUp
from result import Ok, Result
from transitions import Machine

from gwproto.enums import FsmReportType
from gwproto.named_types import (Alert, MachineStates, FsmAtomicReport,
FsmFullReport, )
from actors.scada_actor import ScadaActor
from named_types import GoDormant, WakeUp
from actors.scada_data import ScadaData
from actors.synth_generator import RemainingElec, WeatherForecast
from data_classes.house_0_names import H0N, H0CN
from enums import MainAutoState
from named_types import EnergyInstruction, Ha1Params


class AtomicAllyState(GwStrEnum):
Expand Down Expand Up @@ -150,9 +149,8 @@ def process_message(self, message: Message) -> Result[bool, BaseException]:
match message.Payload:
case EnergyInstruction():
self.log(f"Received an EnergyInstruction for {message.Payload.AvgPowerWatts} Watts average power")
if message.Payload.AvgPowerWatts == 0:
if "HpOn" in self.state:
self.turn_off_HP()
self.check_and_update_state()

case GoDormant():
self.log("Just got message to GoDormant!")
if self.state != AtomicAllyState.Dormant.value:
Expand Down Expand Up @@ -233,6 +231,9 @@ def monitored_names(self) -> Sequence[MonitoredName]:

def check_and_update_state(self) -> None:
self.log(f"State: {self.state}")
if not self.weather:
self.log("Strange ... Do not have weather yet! Not updating state since can't check buffer state")
return
if self.state != AtomicAllyState.Dormant:
previous_state = self.state

Expand Down

0 comments on commit dd9b279

Please sign in to comment.