11""" aiocomfoconnect CLI application """
2+
23from __future__ import annotations
34
45import argparse
1415from aiocomfoconnect .exceptions import (
1516 AioComfoConnectNotConnected ,
1617 AioComfoConnectTimeout ,
18+ BridgeNotFoundException ,
1719 ComfoConnectNotAllowed ,
20+ UnknownActionException ,
1821)
1922from aiocomfoconnect .properties import Property
2023from aiocomfoconnect .sensors import SENSORS
@@ -61,7 +64,7 @@ async def main(args):
6164 await run_set_flow_for_speed (args .host , args .uuid , args .speed , args .flow )
6265
6366 else :
64- raise Exception ("Unknown action: " + args .action )
67+ raise UnknownActionException ("Unknown action: " + args .action )
6568
6669
6770async def run_discover (host : str = None ):
@@ -78,7 +81,7 @@ async def run_register(host: str, uuid: str, name: str, pin: int):
7881 # Discover bridge so we know the UUID
7982 bridges = await discover_bridges (host )
8083 if not bridges :
81- raise Exception ("No bridge found" )
84+ raise BridgeNotFoundException ("No bridge found" )
8285
8386 # Connect to the bridge
8487 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -117,7 +120,7 @@ async def run_deregister(host: str, uuid: str, uuid2: str):
117120 # Discover bridge so we know the UUID
118121 bridges = await discover_bridges (host )
119122 if not bridges :
120- raise Exception ("No bridge found" )
123+ raise BridgeNotFoundException ("No bridge found" )
121124
122125 # Connect to the bridge
123126 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -145,7 +148,7 @@ async def run_set_speed(host: str, uuid: str, speed: Literal["away", "low", "med
145148 # Discover bridge so we know the UUID
146149 bridges = await discover_bridges (host )
147150 if not bridges :
148- raise Exception ("No bridge found" )
151+ raise BridgeNotFoundException ("No bridge found" )
149152
150153 # Connect to the bridge
151154 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -165,7 +168,7 @@ async def run_set_mode(host: str, uuid: str, mode: Literal["auto", "manual"]):
165168 # Discover bridge so we know the UUID
166169 bridges = await discover_bridges (host )
167170 if not bridges :
168- raise Exception ("No bridge found" )
171+ raise BridgeNotFoundException ("No bridge found" )
169172
170173 # Connect to the bridge
171174 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -185,7 +188,7 @@ async def run_set_comfocool(host: str, uuid: str, mode: Literal["auto", "off"]):
185188 # Discover bridge so we know the UUID
186189 bridges = await discover_bridges (host )
187190 if not bridges :
188- raise Exception ("No bridge found" )
191+ raise BridgeNotFoundException ("No bridge found" )
189192
190193 # Connect to the bridge
191194 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -205,7 +208,7 @@ async def run_set_boost(host: str, uuid: str, mode: Literal["on", "off"], timeou
205208 # Discover bridge so we know the UUID
206209 bridges = await discover_bridges (host )
207210 if not bridges :
208- raise Exception ("No bridge found" )
211+ raise BridgeNotFoundException ("No bridge found" )
209212
210213 # Connect to the bridge
211214 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -225,7 +228,7 @@ async def run_show_sensors(host: str, uuid: str):
225228 # Discover bridge so we know the UUID
226229 bridges = await discover_bridges (host )
227230 if not bridges :
228- raise Exception ("No bridge found" )
231+ raise BridgeNotFoundException ("No bridge found" )
229232
230233 def alarm_callback (node_id , errors ):
231234 """Print alarm updates."""
@@ -277,7 +280,7 @@ async def run_show_sensor(host: str, uuid: str, sensor: int, follow=False):
277280 # Discover bridge so we know the UUID
278281 bridges = await discover_bridges (host )
279282 if not bridges :
280- raise Exception ("No bridge found" )
283+ raise BridgeNotFoundException ("No bridge found" )
281284
282285 def sensor_callback (sensor_ , value ):
283286 """Print sensor update."""
@@ -331,7 +334,7 @@ async def run_get_property(host: str, uuid: str, node_id: int, unit: int, subuni
331334 # Discover bridge so we know the UUID
332335 bridges = await discover_bridges (host )
333336 if not bridges :
334- raise Exception ("No bridge found" )
337+ raise BridgeNotFoundException ("No bridge found" )
335338
336339 # Connect to the bridge
337340 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -351,7 +354,7 @@ async def run_get_flow_for_speed(host: str, uuid: str, speed: Literal["away", "l
351354 # Discover bridge so we know the UUID
352355 bridges = await discover_bridges (host )
353356 if not bridges :
354- raise Exception ("No bridge found" )
357+ raise BridgeNotFoundException ("No bridge found" )
355358
356359 # Connect to the bridge
357360 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
@@ -371,7 +374,7 @@ async def run_set_flow_for_speed(host: str, uuid: str, speed: Literal["away", "l
371374 # Discover bridge so we know the UUID
372375 bridges = await discover_bridges (host )
373376 if not bridges :
374- raise Exception ("No bridge found" )
377+ raise BridgeNotFoundException ("No bridge found" )
375378
376379 # Connect to the bridge
377380 comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid )
0 commit comments