27
27
import bellows .types as t
28
28
import bellows .uart
29
29
30
- from . import v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13
30
+ from . import v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14
31
31
32
- EZSP_LATEST = v13 . EZSPv13 .VERSION
32
+ EZSP_LATEST = v14 . EZSPv14 .VERSION
33
33
LOGGER = logging .getLogger (__name__ )
34
34
MTOR_MIN_INTERVAL = 60
35
35
MTOR_MAX_INTERVAL = 3600
@@ -56,6 +56,7 @@ class EZSP:
56
56
v11 .EZSPv11 .VERSION : v11 .EZSPv11 ,
57
57
v12 .EZSPv12 .VERSION : v12 .EZSPv12 ,
58
58
v13 .EZSPv13 .VERSION : v13 .EZSPv13 ,
59
+ v14 .EZSPv14 .VERSION : v14 .EZSPv14 ,
59
60
}
60
61
61
62
def __init__ (self , device_config : dict ):
@@ -68,7 +69,7 @@ def __init__(self, device_config: dict):
68
69
self ._send_sem = PriorityDynamicBoundedSemaphore (value = MAX_COMMAND_CONCURRENCY )
69
70
70
71
self ._stack_status_listeners : collections .defaultdict [
71
- t .EmberStatus , list [asyncio .Future ]
72
+ t .sl_Status , list [asyncio .Future ]
72
73
] = collections .defaultdict (list )
73
74
74
75
self .add_callback (self .stack_status_callback )
@@ -78,13 +79,13 @@ def stack_status_callback(self, frame_name: str, args: list[Any]) -> None:
78
79
if frame_name != "stackStatusHandler" :
79
80
return
80
81
81
- status = args [0 ]
82
+ status = t . sl_Status . from_ember_status ( args [0 ])
82
83
83
84
for listener in self ._stack_status_listeners [status ]:
84
85
listener .set_result (status )
85
86
86
87
@contextlib .contextmanager
87
- def wait_for_stack_status (self , status : t .EmberStatus ) -> Generator [asyncio .Future ]:
88
+ def wait_for_stack_status (self , status : t .sl_Status ) -> Generator [asyncio .Future ]:
88
89
"""Waits for a `stackStatusHandler` to come in with the provided status."""
89
90
listeners = self ._stack_status_listeners [status ]
90
91
@@ -228,10 +229,10 @@ def cb(frame_name, response):
228
229
cbid = self .add_callback (cb )
229
230
try :
230
231
v = await self ._command (name , * args )
231
- if v [0 ] != t .EmberStatus . SUCCESS :
232
+ if t . sl_Status . from_ember_status ( v [0 ]) != t .sl_Status . OK :
232
233
raise Exception (v )
233
234
v = await fut
234
- if v [spos ] != t .EmberStatus . SUCCESS :
235
+ if t . sl_Status . from_ember_status ( v [spos ]) != t .sl_Status . OK :
235
236
raise Exception (v )
236
237
finally :
237
238
self .remove_callback (cbid )
@@ -267,9 +268,9 @@ async def leaveNetwork(self, timeout: float | int = NETWORK_OPS_TIMEOUT) -> None
267
268
"""Send leaveNetwork command and wait for stackStatusHandler frame."""
268
269
stack_status = asyncio .Future ()
269
270
270
- with self .wait_for_stack_status (t .EmberStatus .NETWORK_DOWN ) as stack_status :
271
+ with self .wait_for_stack_status (t .sl_Status .NETWORK_DOWN ) as stack_status :
271
272
(status ,) = await self ._command ("leaveNetwork" )
272
- if status != t .EmberStatus . SUCCESS :
273
+ if status != t .sl_Status . OK :
273
274
raise EzspError (f"failed to leave network: { status .name } " )
274
275
275
276
async with asyncio_timeout (timeout ):
@@ -302,10 +303,10 @@ def __getattr__(self, name: str) -> Callable:
302
303
return functools .partial (self ._command , name )
303
304
304
305
async def formNetwork (self , parameters : t .EmberNetworkParameters ) -> None :
305
- with self .wait_for_stack_status (t .EmberStatus .NETWORK_UP ) as stack_status :
306
+ with self .wait_for_stack_status (t .sl_Status .NETWORK_UP ) as stack_status :
306
307
v = await self ._command ("formNetwork" , parameters )
307
308
308
- if v [0 ] != self . types . EmberStatus . SUCCESS :
309
+ if t . sl_Status . from_ember_status ( v [0 ]) != t . sl_Status . OK :
309
310
raise zigpy .exceptions .FormationFailure (f"Failure forming network: { v } " )
310
311
311
312
async with asyncio_timeout (NETWORK_OPS_TIMEOUT ):
@@ -361,7 +362,7 @@ async def get_board_info(
361
362
)
362
363
version = None
363
364
364
- if status == t .EmberStatus . SUCCESS :
365
+ if t . sl_Status . from_ember_status ( status ) == t .sl_Status . OK :
365
366
build , ver_info_bytes = t .uint16_t .deserialize (ver_info_bytes )
366
367
major , ver_info_bytes = t .uint8_t .deserialize (ver_info_bytes )
367
368
minor , ver_info_bytes = t .uint8_t .deserialize (ver_info_bytes )
@@ -388,7 +389,7 @@ async def _get_nv3_restored_eui64_key(self) -> t.NV3KeyId | None:
388
389
# is not implemented in the firmware
389
390
return None
390
391
391
- if rsp .status == t .EmberStatus . SUCCESS :
392
+ if t . sl_Status . from_ember_status ( rsp .status ) == t .sl_Status . OK :
392
393
nv3_restored_eui64 , _ = t .EUI64 .deserialize (rsp .value )
393
394
LOGGER .debug ("NV3 restored EUI64: %s=%s" , key , nv3_restored_eui64 )
394
395
@@ -434,7 +435,7 @@ async def reset_custom_eui64(self) -> None:
434
435
0 ,
435
436
t .LVBytes32 (t .EUI64 .convert ("FF:FF:FF:FF:FF:FF:FF:FF" ).serialize ()),
436
437
)
437
- assert status == t .EmberStatus . SUCCESS
438
+ assert t . sl_Status . from_ember_status ( status ) == t .sl_Status . OK
438
439
439
440
async def write_custom_eui64 (
440
441
self , ieee : t .EUI64 , * , burn_into_userdata : bool = False
@@ -460,12 +461,12 @@ async def write_custom_eui64(
460
461
0 ,
461
462
t .LVBytes32 (ieee .serialize ()),
462
463
)
463
- assert status == t .EmberStatus . SUCCESS
464
+ assert t . sl_Status . from_ember_status ( status ) == t .sl_Status . OK
464
465
elif mfg_custom_eui64 is None and burn_into_userdata :
465
466
(status ,) = await self .setMfgToken (
466
467
t .EzspMfgTokenId .MFG_CUSTOM_EUI_64 , ieee .serialize ()
467
468
)
468
- assert status == t .EmberStatus . SUCCESS
469
+ assert t . sl_Status . from_ember_status ( status ) == t .sl_Status . OK
469
470
elif mfg_custom_eui64 is None and not burn_into_userdata :
470
471
raise EzspError (
471
472
f"Firmware does not support NV3 tokens. Custom IEEE { ieee } will not be"
@@ -507,7 +508,7 @@ async def set_source_routing(self) -> None:
507
508
0 ,
508
509
)
509
510
LOGGER .debug ("Set concentrator type: %s" , res )
510
- if res [0 ] != self . types . EmberStatus . SUCCESS :
511
+ if t . sl_Status . from_ember_status ( res [0 ]) != t . sl_Status . OK :
511
512
LOGGER .warning ("Couldn't set concentrator type %s: %s" , True , res )
512
513
513
514
if self ._ezsp_version >= 8 :
@@ -579,7 +580,7 @@ async def write_config(self, config: dict) -> None:
579
580
# XXX: A read failure does not mean the value is not writeable!
580
581
status , current_value = await self .getValue (cfg .value_id )
581
582
582
- if status == self . types . EmberStatus . SUCCESS :
583
+ if t . sl_Status . from_ember_status ( status ) == t . sl_Status . OK :
583
584
current_value , _ = type (cfg .value ).deserialize (current_value )
584
585
else :
585
586
current_value = None
@@ -593,7 +594,7 @@ async def write_config(self, config: dict) -> None:
593
594
594
595
(status ,) = await self .setValue (cfg .value_id , cfg .value .serialize ())
595
596
596
- if status != self . types . EmberStatus . SUCCESS :
597
+ if t . sl_Status . from_ember_status ( status ) != t . sl_Status . OK :
597
598
LOGGER .debug (
598
599
"Could not set value %s = %s: %s" ,
599
600
cfg .value_id .name ,
@@ -608,7 +609,7 @@ async def write_config(self, config: dict) -> None:
608
609
609
610
# Only grow some config entries, all others should be set
610
611
if (
611
- status == self . types . EmberStatus . SUCCESS
612
+ t . sl_Status . from_ember_status ( status ) == t . sl_Status . OK
612
613
and cfg .minimum
613
614
and current_value >= cfg .value
614
615
):
@@ -628,7 +629,7 @@ async def write_config(self, config: dict) -> None:
628
629
)
629
630
630
631
(status ,) = await self .setConfigurationValue (cfg .config_id , cfg .value )
631
- if status != self . types . EmberStatus . SUCCESS :
632
+ if t . sl_Status . from_ember_status ( status ) != t . sl_Status . OK :
632
633
LOGGER .debug (
633
634
"Could not set config %s = %s: %s" ,
634
635
cfg .config_id ,
0 commit comments