Skip to content

Commit

Permalink
Merge branch 'main' of github.com:thegridelectric/gw-scada-spaceheat-…
Browse files Browse the repository at this point in the history
…python
  • Loading branch information
thdfw committed Jan 4, 2025
2 parents 093cb61 + af4cae4 commit b94993c
Show file tree
Hide file tree
Showing 39 changed files with 10,405 additions and 317 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ venv
CodeGenerationTools/GridworksCore/.ssotme/**/*.zfs
CodeGenerationTools/GridworksCore/SassyMQ/
CodeGenerationTools/GridworksCore/SSoT/Airtable.xml

claude/
gw_spaceheat/scratch.ipynb
gw_spaceheat/w_isone_nh*
gw_spaceheat/dw1_isone_nh*
Expand Down Expand Up @@ -39,4 +39,4 @@ cron_last_hour.txt
cron_last_minute.txt


layouts/**
layouts/**
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ on these ideas:
- [GridWorks Types](https://gridwork-type-registry.readthedocs.io/en/latest/types.html)
- [ASLs](https://gridwork-type-registry.readthedocs.io/en/latest/asls.html)
"""
</xsl:text>

from gw.enums import MarketTypeName</xsl:text>
<xsl:for-each select="$airtable//ProtocolEnums/ProtocolEnum[(normalize-space(ProtocolName) ='scada') and not(normalize-space(EnumName)='')]">
<xsl:sort select="LocalEnumName" data-type="text"/>
<xsl:text>
Expand All @@ -56,7 +57,8 @@ from enums.</xsl:text>
<xsl:text>


__all__ = [</xsl:text>
__all__ = [
"MarketTypeName",</xsl:text>
<xsl:for-each select="$airtable//ProtocolEnums/ProtocolEnum[(normalize-space(ProtocolName) ='scada')]">
<xsl:sort select="LocalEnumName" data-type="text"/>
<xsl:variable name="gt-enum-id" select="GtEnumId"/>
Expand Down
15 changes: 14 additions & 1 deletion gw_spaceheat/actors/atn.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from data_classes.house_0_layout import House0Layout
from data_classes.house_0_names import H0CN, H0N
from enums import MarketPriceUnit, MarketQuantityUnit, MarketTypeName
from named_types import RemainingElecEvent, ScadaInit

from gwproactor import QOS, ActorInterface
from gwproactor.config import LoggerLevels
Expand Down Expand Up @@ -122,6 +123,7 @@ def __init__(
hardware_layout: House0Layout,
):
super().__init__(name=name, settings=settings, hardware_layout=hardware_layout)
self.latest_remaining_elec = None
self._web_manager.disable()
self.data = AtnData(hardware_layout)
self._links.add_mqtt_link(
Expand Down Expand Up @@ -276,6 +278,11 @@ def _derived_process_mqtt_message(
case SnapshotSpaceheat():
path_dbg |= 0x00000010
self._process_snapshot(decoded.Payload)
case ScadaInit():
self.log("Scada is on!")
if self.latest_remaining_elec is not None:
self.log("Sending energy instruction with the latest remaining electricity")
self.send_energy_instr(self.latest_remaining_elec)
case EventBase():
path_dbg |= 0x00000020
self._process_event(decoded.Payload)
Expand All @@ -291,6 +298,13 @@ def _derived_process_mqtt_message(
):
path_dbg |= 0x00000080
self._process_snapshot(decoded.Payload)
elif (
decoded.Payload.TypeName
== RemainingElecEvent.model_fields['TypeName'].default
):
path_dbg |= 0x00000120
self.log(f"Received remaining electricity {decoded.Payload.Remaining.RemainingWattHours} Wh")
self.latest_remaining_elec = decoded.Payload.Remaining.RemainingWattHours
case _:
path_dbg |= 0x00000100
self._logger.path("--Atn._derived_process_mqtt_message path:0x%08X", path_dbg)
Expand Down Expand Up @@ -352,7 +366,6 @@ def _process_layout_lite(self, layout: LayoutLite) -> None:
for x in layout.DataChannels
if "depth" in x.Name and "micro-v" not in x.Name
]
self.log(self.temperature_channel_names)

def _process_report(self, report: Report) -> None:
self.data.latest_report = report
Expand Down
3 changes: 2 additions & 1 deletion gw_spaceheat/actors/atomic_ally.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

from actors.scada_actor import ScadaActor
from actors.scada_data import ScadaData
from actors.synth_generator import RemainingElec, WeatherForecast
from actors.synth_generator import WeatherForecast
from named_types import RemainingElec


class AtomicAllyState(GwStrEnum):
Expand Down
4 changes: 2 additions & 2 deletions gw_spaceheat/actors/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PersisterSettings(BaseModel):
class AdminLinkSettings(MQTTClient):
enabled: bool = False
name: str = H0N.admin
timeout_seconds: float = 60 * 5
max_timeout_seconds: float = 60 * 60 * 24

class ScadaSettings(ProactorSettings):
"""Settings for the GridWorks scada."""
Expand All @@ -41,7 +41,7 @@ class ScadaSettings(ProactorSettings):
dd_delta_t: float = 20
is_simulated: bool = False
max_ewt_f: int = 170
oil_boiler_during_onpeak: bool = False
oil_boiler_for_onpeak_backup: bool = True

model_config = SettingsConfigDict(env_prefix="SCADA_", extra="ignore")

Expand Down
Loading

0 comments on commit b94993c

Please sign in to comment.