@@ -70,9 +70,15 @@ def name(self) -> str:
70
70
@property
71
71
def available (self ) -> bool :
72
72
"""Return if device is online or not."""
73
- return next (
74
- attr ['Value' ] for attr in self ._device_json .get ('Attributes' , [])
75
- if attr .get ('AttributeDisplayName' ) == 'online' ) == "True"
73
+ # Both ability to retrieve state from MyQ cloud AND device itself has
74
+ # to be online.
75
+ is_available = self .api .online and \
76
+ next (
77
+ attr ['Value' ] for attr in
78
+ self ._device_json .get ('Attributes' , [])
79
+ if attr .get ('AttributeDisplayName' ) == 'online' ) == "True"
80
+
81
+ return is_available
76
82
77
83
@property
78
84
def serial (self ) -> str :
@@ -107,8 +113,8 @@ def state(self) -> str:
107
113
def _update_state (self , value : str ) -> None :
108
114
"""Update state temporary during open or close."""
109
115
attribute = next (attr for attr in self ._device ['device_info' ].get (
110
- 'Attributes' , []) if attr .get ('AttributeDisplayName' )
111
- == 'doorstate' )
116
+ 'Attributes' , []) if attr .get (
117
+ 'AttributeDisplayName' ) == 'doorstate' )
112
118
if attribute is not None :
113
119
attribute ['Value' ] = value
114
120
@@ -143,6 +149,9 @@ async def _set_state(self, state: int) -> bool:
143
149
self .name , err )
144
150
return False
145
151
152
+ if set_state_resp is None :
153
+ return False
154
+
146
155
if int (set_state_resp .get ('ReturnCode' , 1 )) != 0 :
147
156
_LOGGER .error (
148
157
'%s: Error setting the device state: %s' , self .name ,
0 commit comments