1
1
"""Cloud module implementation."""
2
2
3
- from pydantic .v1 import BaseModel
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro import DataClassDictMixin
7
+ from mashumaro .types import Alias
4
8
5
9
from ...feature import Feature
6
10
from ..iotmodule import IotModule
7
11
8
12
9
- class CloudInfo (BaseModel ):
13
+ @dataclass
14
+ class CloudInfo (DataClassDictMixin ):
10
15
"""Container for cloud settings."""
11
16
12
- binded : bool
13
- cld_connection : int
14
- fwDlPage : str
15
- fwNotifyType : int
16
- illegalType : int
17
+ provisioned : Annotated [ int , Alias ( "binded" )]
18
+ cloud_connected : Annotated [ int , Alias ( "cld_connection" )]
19
+ firmware_download_page : Annotated [ str , Alias ( "fwDlPage" )]
20
+ firmware_notify_type : Annotated [ int , Alias ( "fwNotifyType" )]
21
+ illegal_type : Annotated [ int , Alias ( "illegalType" )]
17
22
server : str
18
- stopConnect : int
19
- tcspInfo : str
20
- tcspStatus : int
23
+ stop_connect : Annotated [ int , Alias ( "stopConnect" )]
24
+ tcsp_info : Annotated [ str , Alias ( "tcspInfo" )]
25
+ tcsp_status : Annotated [ int , Alias ( "tcspStatus" )]
21
26
username : str
22
27
23
28
@@ -42,7 +47,7 @@ def _initialize_features(self) -> None:
42
47
@property
43
48
def is_connected (self ) -> bool :
44
49
"""Return true if device is connected to the cloud."""
45
- return self .info .binded
50
+ return bool ( self .info .cloud_connected )
46
51
47
52
def query (self ) -> dict :
48
53
"""Request cloud connectivity info."""
@@ -51,7 +56,7 @@ def query(self) -> dict:
51
56
@property
52
57
def info (self ) -> CloudInfo :
53
58
"""Return information about the cloud connectivity."""
54
- return CloudInfo .parse_obj (self .data ["get_info" ])
59
+ return CloudInfo .from_dict (self .data ["get_info" ])
55
60
56
61
def get_available_firmwares (self ) -> dict :
57
62
"""Return list of available firmwares."""
0 commit comments