@@ -82,12 +82,16 @@ async def doBearerRequest(self, resourceUrl, options=None, refreshed=False):
82
82
async with self ._cloud_lock :
83
83
_LOGGER .debug ("BEARER REQUEST URL: %s" , resourceUrl )
84
84
_LOGGER .debug ("BEARER REQUEST HEADERS: %s" , headers )
85
- if options is not None and "method" in options and options ["method" ] == "PATCH" :
85
+ if (
86
+ options is not None
87
+ and "method" in options
88
+ and options ["method" ] == "PATCH"
89
+ ):
86
90
_LOGGER .debug ("BEARER REQUEST JSON: %s" , options ["json" ])
87
91
func = functools .partial (
88
92
requests .patch , resourceUrl , headers = headers , data = options ["json" ]
89
93
)
90
- # res = requests.patch(resourceUrl, headers=headers , data=options["json"])
94
+ # res = requests.patch(resourceUrl, headers, data=options["json"])
91
95
else :
92
96
func = functools .partial (requests .get , resourceUrl , headers = headers )
93
97
# res = requests.get(resourceUrl, headers=headers)
@@ -505,18 +509,27 @@ async def async_update(self, **kwargs):
505
509
dev_data
506
510
)
507
511
508
- if dev_data ["managementPoints" ][1 ]["econoMode" ]["value" ] == "on" :
512
+ _mode = "none"
513
+ if (
514
+ "econoMode" in dev_data ["managementPoints" ][1 ]
515
+ and dev_data ["managementPoints" ][1 ]["econoMode" ]["value" ] == "on"
516
+ ):
509
517
_mode = "eco"
510
- elif dev_data ["managementPoints" ][1 ]["powerfulMode" ]["value" ] == "on" :
518
+ if (
519
+ "powerfulMode" in dev_data ["managementPoints" ][1 ]
520
+ and dev_data ["managementPoints" ][1 ]["powerfulMode" ]["value" ] == "on"
521
+ ):
511
522
_mode = "powerful"
512
- else :
513
- _mode = "none"
514
523
515
- _LOGGER .debug ("DEVICE %s: %s/%s/%s/%s" ,
524
+ _LOGGER .debug (
525
+ "DEVICE %s: %s/%s/%s/%s" ,
516
526
dev_data ["managementPoints" ][1 ]["name" ]["value" ],
517
527
dev_data ["managementPoints" ][1 ]["onOffMode" ]["value" ],
518
528
dev_data ["managementPoints" ][1 ]["operationMode" ]["value" ],
519
529
_mode ,
520
- "streamer" if dev_data ["managementPoints" ][1 ]["streamerMode" ]["value" ] == "on" else "nostreamer" )
530
+ "streamer"
531
+ if dev_data ["managementPoints" ][1 ]["streamerMode" ]["value" ] == "on"
532
+ else "nostreamer" ,
533
+ )
521
534
522
535
return True
0 commit comments