7
7
from ..exceptions .feature import FeatureNotSupported
8
8
from . import devolo_idl_proto_deviceapi_wifinetwork_pb2
9
9
from . import devolo_idl_proto_deviceapi_ledsettings_pb2
10
+ from . import devolo_idl_proto_deviceapi_updatefirmware_pb2
10
11
11
12
12
13
class DeviceApi (Protobuf ):
@@ -20,13 +21,13 @@ class DeviceApi(Protobuf):
20
21
:param features: Feature, the device has
21
22
"""
22
23
23
- def __init__ (self , ip : str , session : Client , path : str , version : str , features : str , password : str ):
24
+ def __init__ (self , ip : str , port : int , session : Client , path : str , version : str , features : str , password : str ):
24
25
self ._ip = ip
25
- self ._port = 14791
26
+ self ._port = port
26
27
self ._session = session
27
28
self ._path = path
28
29
self ._version = version
29
- self ._features = features .split ("," ) if features else []
30
+ self ._features = features .split ("," ) if features else ['reset' , 'update' , 'led' , 'intmtg' ]
30
31
self ._user = "devolo"
31
32
self ._password = password
32
33
self ._logger = logging .getLogger (self .__class__ .__name__ )
@@ -45,24 +46,37 @@ def wrapper(self, *args, **kwargs):
45
46
46
47
47
48
@_feature ("led" )
48
- async def async_get_led_setting (self ):
49
- """ Get LED setting asynchronously. """
49
+ async def async_get_led_setting (self ) -> dict :
50
+ """
51
+ Get LED setting asynchronously. This feature only works on devices, that announce the led feature.
52
+
53
+ return: LED settings
54
+ """
50
55
led_setting = devolo_idl_proto_deviceapi_ledsettings_pb2 .LedSettingsGet ()
51
56
response = await self ._async_get ("LedSettingsGet" )
52
57
led_setting .FromString (await response .aread ())
53
58
return self ._message_to_dict (led_setting )
54
59
55
60
@_feature ("led" )
56
61
def get_led_setting (self ):
57
- """ Get LED setting synchronously. """
62
+ """
63
+ Get LED setting synchronously. This feature only works on devices, that announce the led feature.
64
+
65
+ return: LED settings
66
+ """
58
67
led_setting = devolo_idl_proto_deviceapi_ledsettings_pb2 .LedSettingsGet ()
59
68
response = self ._get ("LedSettingsGet" )
60
69
led_setting .FromString (response .read ())
61
70
return self ._message_to_dict (led_setting )
62
71
63
72
@_feature ("led" )
64
73
async def async_set_led_setting (self , enable : bool ) -> bool :
65
- """ Set LED setting asynchronously. """
74
+ """
75
+ Set LED setting asynchronously. This feature only works on devices, that announce the led feature.
76
+
77
+ :param enable: True to enable the LEDs, False to disable the LEDs
78
+ :return: True, if LED state was successfully changed, otherwise False
79
+ """
66
80
led_setting = devolo_idl_proto_deviceapi_ledsettings_pb2 .LedSettingsSet ()
67
81
led_setting .state = int (not enable )
68
82
query = await self ._async_post ("LedSettingsSet" , data = led_setting .SerializeToString ())
@@ -72,33 +86,105 @@ async def async_set_led_setting(self, enable: bool) -> bool:
72
86
73
87
@_feature ("led" )
74
88
def set_led_setting (self , enable : bool ) -> bool :
75
- """ Set LED setting synchronously. """
89
+ """
90
+ Set LED setting synchronously. This feature only works on devices, that announce the led feature.
91
+
92
+ :param enable: True to enable the LEDs, False to disable the LEDs
93
+ :return: True, if LED state was successfully changed, otherwise False
94
+ """
76
95
led_setting = devolo_idl_proto_deviceapi_ledsettings_pb2 .LedSettingsSet ()
77
96
led_setting .state = int (not enable )
78
97
query = self ._post ("LedSettingsSet" , data = led_setting .SerializeToString ())
79
98
response = devolo_idl_proto_deviceapi_ledsettings_pb2 .LedSettingsSetResponse ()
80
99
response .FromString (query .read ())
81
100
return bool (not response .result )
82
101
102
+
103
+ @_feature ("update" )
104
+ async def async_check_firmware_available (self ) -> dict :
105
+ """
106
+ Check asynchronously, if a firmware update is available for the device.
107
+
108
+ :return: Result and new firmware version, if newer one is available
109
+ """
110
+ update_firmware_check = devolo_idl_proto_deviceapi_updatefirmware_pb2 .UpdateFirmwareCheck ()
111
+ response = await self ._async_get ("UpdateFirmwareCheck" )
112
+ update_firmware_check .ParseFromString (await response .aread ())
113
+ return self ._message_to_dict (update_firmware_check )
114
+
115
+ @_feature ("update" )
116
+ def check_firmware_available (self ) -> dict :
117
+ """
118
+ Check synchronously, if a firmware update is available for the device.
119
+
120
+ :return: Result and new firmware version, if newer one is available
121
+ """
122
+ update_firmware_check = devolo_idl_proto_deviceapi_updatefirmware_pb2 .UpdateFirmwareCheck ()
123
+ response = self ._get ("UpdateFirmwareCheck" )
124
+ update_firmware_check .ParseFromString (response .read ())
125
+ return self ._message_to_dict (update_firmware_check )
126
+
127
+ @_feature ("update" )
128
+ async def async_start_firmware_update (self ) -> bool :
129
+ """
130
+ Start firmware update asynchronously, if a firmware update is available for the device. Important: The response does
131
+ not tell you anything about the success of the update itself.
132
+
133
+ :return: True, if the firmware update was started, False if there is no update
134
+ """
135
+ update_firmware = devolo_idl_proto_deviceapi_updatefirmware_pb2 .UpdateFirmwareStart ()
136
+ response = await self ._async_get ("UpdateFirmwareStart" )
137
+ update_firmware .FromString (await response .aread ())
138
+ return bool (not update_firmware .result )
139
+
140
+ @_feature ("update" )
141
+ def start_firmware_update (self ) -> bool :
142
+ """
143
+ Start firmware update synchronously, if a firmware update is available for the device. Important: The response does
144
+ not tell you anything about the success of the update itself.
145
+
146
+ :return: True, if the firmware update was started, False if there is no update
147
+ """
148
+ update_firmware = devolo_idl_proto_deviceapi_updatefirmware_pb2 .UpdateFirmwareStart ()
149
+ response = self ._get ("UpdateFirmwareStart" )
150
+ update_firmware .FromString (response .read ())
151
+ return bool (not update_firmware .result )
152
+
153
+
83
154
@_feature ("wifi1" )
84
155
async def async_get_wifi_connected_station (self ) -> dict :
85
- """ Get wifi stations connected to the device asynchronously. """
156
+ """
157
+ Get wifi stations connected to the device asynchronously. This feature only works on devices, that announce the wifi1
158
+ feature.
159
+
160
+ :return: All connected wifi stations including connection rate data
161
+ """
86
162
wifi_connected_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiConnectedStationsGet ()
87
163
response = await self ._async_get ("WifiConnectedStationsGet" )
88
164
wifi_connected_proto .ParseFromString (await response .aread ())
89
165
return self ._message_to_dict (wifi_connected_proto )
90
166
91
167
@_feature ("wifi1" )
92
168
def get_wifi_connected_station (self ) -> dict :
93
- """ Get wifi stations connected to the device synchronously. """
169
+ """
170
+ Get wifi stations connected to the device synchronously. This feature only works on devices, that announce the wifi1
171
+ feature.
172
+
173
+ :return: All connected wifi stations including connection rate data
174
+ """
94
175
wifi_connected_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiConnectedStationsGet ()
95
176
response = self ._get ("WifiConnectedStationsGet" )
96
177
wifi_connected_proto .ParseFromString (response .read ())
97
178
return self ._message_to_dict (wifi_connected_proto )
98
179
99
180
@_feature ("wifi1" )
100
181
async def async_get_wifi_guest_access (self ) -> dict :
101
- """ Get details about wifi guest access asynchronously. """
182
+ """
183
+ Get details about wifi guest access asynchronously. This feature only works on devices, that announce the wifi1
184
+ feature.
185
+
186
+ :return: Details about the wifi guest access
187
+ """
102
188
self ._logger .debug ("Getting wifi guest access" )
103
189
wifi_guest_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiGuestAccessGet ()
104
190
response = await self ._async_get ("WifiGuestAccessGet" )
@@ -107,7 +193,12 @@ async def async_get_wifi_guest_access(self) -> dict:
107
193
108
194
@_feature ("wifi1" )
109
195
def get_wifi_guest_access (self ) -> dict :
110
- """ Get details about wifi guest access synchronously. """
196
+ """
197
+ Get details about wifi guest access synchronously. This feature only works on devices, that announce the wifi1
198
+ feature.
199
+
200
+ :return: Details about the wifi guest access
201
+ """
111
202
self ._logger .debug ("Getting wifi guest access" )
112
203
wifi_guest_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiGuestAccessGet ()
113
204
response = self ._get ("WifiGuestAccessGet" )
@@ -116,7 +207,12 @@ def get_wifi_guest_access(self) -> dict:
116
207
117
208
@_feature ("wifi1" )
118
209
async def async_set_wifi_guest_access (self , enable : bool ) -> bool :
119
- """ Enable wifi guest access asynchronously. """
210
+ """
211
+ Enable wifi guest access asynchronously. This feature only works on devices, that announce the wifi1 feature.
212
+
213
+ :param enable: True to enable, False to disable wifi guest access
214
+ :return: True, if the state of the wifi guest access was successfully changed, otherwise False
215
+ """
120
216
wifi_guest_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiGuestAccessSet ()
121
217
wifi_guest_proto .enable = enable
122
218
query = await self ._async_post ("WifiGuestAccessSet" , data = wifi_guest_proto .SerializeToString ())
@@ -126,7 +222,12 @@ async def async_set_wifi_guest_access(self, enable: bool) -> bool:
126
222
127
223
@_feature ("wifi1" )
128
224
def set_wifi_guest_access (self , enable : bool ) -> bool :
129
- """ Enable wifi guest access synchronously. """
225
+ """
226
+ Enable wifi guest access synchronously. This feature only works on devices, that announce the wifi1 feature.
227
+
228
+ :param enable: True to enable, False to disable wifi guest access
229
+ :return: True, if the state of the wifi guest access was successfully changed, otherwise False
230
+ """
130
231
wifi_guest_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiGuestAccessSet ()
131
232
wifi_guest_proto .enable = enable
132
233
query = self ._post ("WifiGuestAccessSet" , data = wifi_guest_proto .SerializeToString ())
@@ -136,30 +237,76 @@ def set_wifi_guest_access(self, enable: bool) -> bool:
136
237
137
238
@_feature ("wifi1" )
138
239
async def async_get_wifi_neighbor_access_points (self ) -> dict :
139
- """ Get wifi access point in the neighborhood asynchronously. """
240
+ """
241
+ Get wifi access point in the neighborhood asynchronously. This feature only works on devices, that announce the wifi1
242
+ feature.
243
+
244
+ :return: Visible access points in the neighborhood including connection rate data
245
+ """
140
246
wifi_neighbor_aps = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiNeighborAPsGet ()
141
247
response = await self ._async_get ("WifiNeighborAPsGet" , timeout = 15.0 )
142
248
wifi_neighbor_aps .ParseFromString (await response .aread ())
143
249
return self ._message_to_dict (wifi_neighbor_aps )
144
250
145
251
@_feature ("wifi1" )
146
252
def get_wifi_neighbor_access_points (self ) -> dict :
147
- """ Get wifi access point in the neighborhood synchronously. """
253
+ """
254
+ Get wifi access point in the neighborhood synchronously. This feature only works on devices, that announce the wifi1
255
+ feature.
256
+
257
+ :return: Visible access points in the neighborhood including connection rate data
258
+ """
148
259
wifi_neighbor_aps = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiNeighborAPsGet ()
149
260
response = self ._get ("WifiNeighborAPsGet" , timeout = 15.0 )
150
261
wifi_neighbor_aps .ParseFromString (response .read ())
151
262
return self ._message_to_dict (wifi_neighbor_aps )
152
263
153
264
@_feature ("wifi1" )
154
265
async def async_get_wifi_repeated_access_points (self ):
266
+ """
267
+ Get repeated wifi access point asynchronously. This feature only works on repeater devices, that announce the wifi1
268
+ feature.
269
+
270
+ :return: Repeated access points in the neighborhood including connection rate data
271
+ """
155
272
wifi_connected_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiRepeatedAPsGet ()
156
273
response = await self ._async_get ("WifiRepeatedAPsGet" )
157
274
wifi_connected_proto .ParseFromString (await response .aread ())
158
275
return self ._message_to_dict (wifi_connected_proto )
159
276
160
277
@_feature ("wifi1" )
161
278
def get_wifi_repeated_access_points (self ):
279
+ """
280
+ Get repeated wifi access point synchronously. This feature only works on repeater devices, that announce the wifi1
281
+ feature.
282
+
283
+ :return: Repeated access points in the neighborhood including connection rate data
284
+ """
162
285
wifi_connected_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiRepeatedAPsGet ()
163
286
response = self ._get ("WifiRepeatedAPsGet" )
164
287
wifi_connected_proto .ParseFromString (response .read ())
165
288
return self ._message_to_dict (wifi_connected_proto )
289
+
290
+ @_feature ("wifi1" )
291
+ async def async_start_wps (self ):
292
+ """
293
+ Start WPS push button configuration.
294
+
295
+ :return: True, if the WPS was successfully started, otherwise False
296
+ """
297
+ wps_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiWpsPbcStart ()
298
+ response = await self ._async_get ("WifiWpsPbcStart" )
299
+ wps_proto .FromString (await response .aread ())
300
+ return bool (not wps_proto .result )
301
+
302
+ @_feature ("wifi1" )
303
+ def start_wps (self ):
304
+ """
305
+ Start WPS push button configuration.
306
+
307
+ :return: True, if the WPS was successfully started, otherwise False
308
+ """
309
+ wps_proto = devolo_idl_proto_deviceapi_wifinetwork_pb2 .WifiWpsPbcStart ()
310
+ response = self ._get ("WifiWpsPbcStart" )
311
+ wps_proto .FromString (response .read ())
312
+ return bool (not wps_proto .result )
0 commit comments