11from pyomnilogic_local ._base import OmniEquipment
22from pyomnilogic_local .api .api import OmniLogicAPI
33from pyomnilogic_local .chlorinator import Chlorinator
4+ from pyomnilogic_local .collections import EquipmentDict
45from pyomnilogic_local .colorlogiclight import _LOGGER , ColorLogicLight
56from pyomnilogic_local .csad import CSAD
67from pyomnilogic_local .filter import Filter
1516class Bow (OmniEquipment [MSPBoW , TelemetryBoW ]):
1617 """Represents a bow in the OmniLogic system."""
1718
18- filters : list [Filter ] = []
19+ filters : EquipmentDict [Filter ] = EquipmentDict ()
1920 heater : Heater | None = None
20- relays : list [Relay ] = []
21- sensors : list [Sensor ] = []
22- lights : list [ColorLogicLight ] = []
23- pumps : list [Pump ] = []
21+ relays : EquipmentDict [Relay ] = EquipmentDict ()
22+ sensors : EquipmentDict [Sensor ] = EquipmentDict ()
23+ lights : EquipmentDict [ColorLogicLight ] = EquipmentDict ()
24+ pumps : EquipmentDict [Pump ] = EquipmentDict ()
2425 chlorinator : Chlorinator | None = None
25- csads : list [CSAD ] = []
26+ csads : EquipmentDict [CSAD ] = EquipmentDict ()
2627
2728 def __init__ (self , _api : OmniLogicAPI , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
2829 super ().__init__ (_api , mspconfig , telemetry )
@@ -37,21 +38,21 @@ def _update_equipment(self, mspconfig: MSPBoW, telemetry: Telemetry | None) -> N
3738 if telemetry is None :
3839 _LOGGER .warning ("No telemetry provided to update Bow equipment." )
3940 return
40- self ._update_filters (self . mspconfig , telemetry )
41- self ._update_heater (self . mspconfig , telemetry )
42- self ._update_sensors (self . mspconfig , telemetry )
43- self ._update_lights (self . mspconfig , telemetry )
44- self ._update_pumps (self . mspconfig , telemetry )
45- self ._update_chlorinators (self . mspconfig , telemetry )
46- self ._update_csads (self . mspconfig , telemetry )
41+ self ._update_filters (mspconfig , telemetry )
42+ self ._update_heater (mspconfig , telemetry )
43+ self ._update_sensors (mspconfig , telemetry )
44+ self ._update_lights (mspconfig , telemetry )
45+ self ._update_pumps (mspconfig , telemetry )
46+ self ._update_chlorinators (mspconfig , telemetry )
47+ self ._update_csads (mspconfig , telemetry )
4748
4849 def _update_filters (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
4950 """Update the filters based on the MSP configuration."""
5051 if mspconfig .filter is None :
51- self .filters = []
52+ self .filters = EquipmentDict ()
5253 return
5354
54- self .filters = [Filter (self ._api , filter_ , telemetry ) for filter_ in mspconfig .filter ]
55+ self .filters = EquipmentDict ( [Filter (self ._api , filter_ , telemetry ) for filter_ in mspconfig .filter ])
5556
5657 def _update_heater (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
5758 """Update the heater based on the MSP configuration."""
@@ -64,34 +65,34 @@ def _update_heater(self, mspconfig: MSPBoW, telemetry: Telemetry) -> None:
6465 def _update_relays (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
6566 """Update the relays based on the MSP configuration."""
6667 if mspconfig .relay is None :
67- self .relays = []
68+ self .relays = EquipmentDict ()
6869 return
6970
70- self .relays = [Relay (self ._api , relay , telemetry ) for relay in mspconfig .relay ]
71+ self .relays = EquipmentDict ( [Relay (self ._api , relay , telemetry ) for relay in mspconfig .relay ])
7172
7273 def _update_sensors (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
7374 """Update the sensors based on the MSP configuration."""
7475 if mspconfig .sensor is None :
75- self .sensors = []
76+ self .sensors = EquipmentDict ()
7677 return
7778
78- self .sensors = [Sensor (self ._api , sensor , telemetry ) for sensor in mspconfig .sensor ]
79+ self .sensors = EquipmentDict ( [Sensor (self ._api , sensor , telemetry ) for sensor in mspconfig .sensor ])
7980
8081 def _update_lights (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
8182 """Update the lights based on the MSP configuration."""
8283 if mspconfig .colorlogic_light is None :
83- self .lights = []
84+ self .lights = EquipmentDict ()
8485 return
8586
86- self .lights = [ColorLogicLight (self ._api , light , telemetry ) for light in mspconfig .colorlogic_light ]
87+ self .lights = EquipmentDict ( [ColorLogicLight (self ._api , light , telemetry ) for light in mspconfig .colorlogic_light ])
8788
8889 def _update_pumps (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
8990 """Update the pumps based on the MSP configuration."""
9091 if mspconfig .pump is None :
91- self .pumps = []
92+ self .pumps = EquipmentDict ()
9293 return
9394
94- self .pumps = [Pump (self ._api , pump , telemetry ) for pump in mspconfig .pump ]
95+ self .pumps = EquipmentDict ( [Pump (self ._api , pump , telemetry ) for pump in mspconfig .pump ])
9596
9697 def _update_chlorinators (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
9798 """Update the chlorinators based on the MSP configuration."""
@@ -104,7 +105,7 @@ def _update_chlorinators(self, mspconfig: MSPBoW, telemetry: Telemetry) -> None:
104105 def _update_csads (self , mspconfig : MSPBoW , telemetry : Telemetry ) -> None :
105106 """Update the CSADs based on the MSP configuration."""
106107 if mspconfig .csad is None :
107- self .csads = []
108+ self .csads = EquipmentDict ()
108109 return
109110
110- self .csads = [CSAD (self ._api , csad , telemetry ) for csad in mspconfig .csad ]
111+ self .csads = EquipmentDict ( [CSAD (self ._api , csad , telemetry ) for csad in mspconfig .csad ])
0 commit comments