@@ -35,15 +35,15 @@ def __init__(
3535 self ,
3636 username : str = None ,
3737 password : str = None ,
38- device_id : str = None ,
38+ control_panel_id : str = None ,
3939 ):
4040 """Initialize the connection."""
4141 self .username = username
4242 self .password = password
43- self .devices = None
43+ self .control_panel_id = control_panel_id
4444 self .authorized = False
4545 self .authorization = None
46- self .areas = self .outputs = self .zones = {}
46+ self ._areas = self ._outputs = self ._zones = []
4747
4848 self .registry = DeviceRegistry ()
4949
@@ -80,8 +80,33 @@ def is_authenticated(self):
8080 """Get the state of the authentication."""
8181 return self .authorized
8282
83- async def get_devices (self ):
84- """Retrieve the devices."""
83+ @property
84+ def control_panels (self ):
85+ """Get the control panels."""
86+ return self .list_control_panels ()
87+
88+ @property
89+ def endpoints (self ):
90+ """Get the endpoints."""
91+ raise NotImplemented
92+
93+ @property
94+ def zones (self ):
95+ """Get the zones."""
96+ return self ._zones
97+
98+ @property
99+ def outputs (self ):
100+ """Get the outputs."""
101+ return self ._outputs
102+
103+ @property
104+ def areas (self ):
105+ """Get the areas."""
106+ return self ._areas
107+
108+ async def get_control_panels (self ):
109+ """Retrieve the present control panels."""
85110 if self .authorized is False :
86111 await self .connect ()
87112
@@ -94,23 +119,23 @@ async def get_devices(self):
94119 _LOGGER .debug ("Status code:" , response .status_code )
95120
96121 for response_entry in response .json ():
97- device = AvailableDevice . create_new_device (response_entry )
98- self .registry .register (device )
122+ control_panel = AvailableControlPanel . create_new_control_panel (response_entry )
123+ self .registry .register (control_panel )
99124
100- async def list_devices (self ):
101- """List all available devices ."""
102- await self .get_devices ()
125+ async def list_control_panels (self ):
126+ """List all available control panels ."""
127+ await self .get_control_panels ()
103128
104- device_list = []
105- for device in self .registry .devices ():
106- device_list .append (
107- {"online" : device .online , "hash" : device .hash , "name" : device .name }
129+ control_panels_list = []
130+ for control_panel in self .registry .devices ():
131+ control_panels_list .append (
132+ {"online" : control_panel .online , "hash" : control_panel .hash , "name" : control_panel .name }
108133 )
109134
110- return device_list
135+ return control_panels_list
111136
112- async def get_units (self , device_id , pin ):
113- """List all units of a devices ."""
137+ async def get_endpoints (self , device_id , pin ):
138+ """List all endpoints of a control panel ."""
114139 if self .authorized is False :
115140 await self .connect ()
116141
@@ -124,14 +149,14 @@ async def get_units(self, device_id, pin):
124149 response_data = response .json ()
125150
126151 if response_data [ZONE ]:
127- self .zones = response_data [ZONE ]
152+ self ._zones = response_data [ZONE ]
128153 if response_data [OUTPUT ]:
129- self .outputs = response_data [OUTPUT ]
154+ self ._outputs = response_data [OUTPUT ]
130155 if response_data [AREA ]:
131- self .areas = response_data [AREA ]
156+ self ._areas = response_data [AREA ]
132157
133158 async def get_status (self , entity_id ):
134- """Get the status of an unit ."""
159+ """Get the status of an endpoint ."""
135160 if self .authorized is False :
136161 self .connect ()
137162
@@ -142,28 +167,27 @@ async def get_status(self, entity_id):
142167 async with httpx .AsyncClient () as client :
143168 response = await client .get (str (url ), headers = headers )
144169
145- return response .json ()[ "zone" ][ 0 ]
170+ return response .json ()
146171
147172
148- class AvailableDevice :
149- """Representation of an available device ."""
173+ class AvailableControlPanel :
174+ """Representation of an available control panel ."""
150175
151176 def __init__ (self , hash , online , name ):
152- """Initialize the new device ."""
177+ """Initialize the new control panel ."""
153178 self .hash = hash
154179 self .online = online
155180 self .name = name
156181
157182 @staticmethod
158- def create_new_device (response_entry ):
159- """Create a new device ."""
160- device = AvailableDevice (
183+ def create_new_control_panel (response_entry ):
184+ """Create a new control panel ."""
185+ control_panel = AvailableControlPanel (
161186 hash = response_entry ["hash" ],
162187 online = bool (response_entry ["centrale_online" ]),
163188 name = response_entry ["username" ][0 ]["label" ],
164189 )
165- return device
166-
190+ return control_panel
167191
168192class DeviceRegistry (object ):
169193 """Representation of the devices registry."""
0 commit comments