@@ -95,7 +95,11 @@ def set_temperature(self, thermostat, temperature):
95
95
thermostat ['properties' ][key ]['statusLastUpdated' ] = str (datetime .now ())
96
96
97
97
url = DEVICES_URL + "/" + thermostat ['id' ]
98
- return self ._request_action (url , json .dumps (thermostat ))
98
+ try :
99
+ return self ._request_action (url , json .dumps (thermostat ))
100
+ except SpiderApiException :
101
+ _LOGGER .error (f"Unable to set temperature to { temperature } ." )
102
+ return False
99
103
100
104
def set_operation_mode (self , thermostat , mode ):
101
105
""" Set the operation mode. Unfortunately, the API requires the complete object"""
@@ -107,7 +111,11 @@ def set_operation_mode(self, thermostat, mode):
107
111
thermostat ['properties' ][key ]['statusLastUpdated' ] = str (datetime .now ())
108
112
109
113
url = DEVICES_URL + "/" + thermostat ['id' ]
110
- return self ._request_action (url , json .dumps (thermostat ))
114
+ try :
115
+ return self ._request_action (url , json .dumps (thermostat ))
116
+ except SpiderApiException :
117
+ _LOGGER .error (f"Unable to set operation mode to { mode } . Is this operation mode supported?" )
118
+ return False
111
119
112
120
def set_fan_speed (self , thermostat , fan_speed ):
113
121
""" Set the fan speed. Unfortunately, the API requires the complete object"""
@@ -121,11 +129,10 @@ def set_fan_speed(self, thermostat, fan_speed):
121
129
122
130
url = DEVICES_URL + "/" + thermostat ['id' ]
123
131
try :
124
- action_requested = self ._request_action (url , json .dumps (thermostat ))
125
- # Exception will occur when fan_speed is not supported
132
+ return self ._request_action (url , json .dumps (thermostat ))
126
133
except SpiderApiException :
127
- action_requested = False
128
- return action_requested
134
+ _LOGGER . error ( f"Unable to set fan speed to { fan_speed } . Is this fan speed supported?" )
135
+ return False
129
136
130
137
def update_power_plugs (self ):
131
138
""" Retrieve power plugs """
@@ -170,12 +177,20 @@ def get_power_plug(self, unique_id):
170
177
def turn_power_plug_on (self , power_plug_id ):
171
178
""" Turn the power_plug on"""
172
179
url = POWER_PLUGS_URL + "/" + power_plug_id + "/switch"
173
- return self ._request_action (url , "true" )
180
+ try :
181
+ return self ._request_action (url , "true" )
182
+ except SpiderApiException :
183
+ _LOGGER .error ("Unable to turn power plug on." )
184
+ return False
174
185
175
186
def turn_power_plug_off (self , power_plug_id ):
176
187
""" Turn the power plug off"""
177
188
url = POWER_PLUGS_URL + "/" + power_plug_id + "/switch"
178
- return self ._request_action (url , "false" )
189
+ try :
190
+ return self ._request_action (url , "false" )
191
+ except SpiderApiException :
192
+ _LOGGER .error ("Unable to turn power plug off." )
193
+ return False
179
194
180
195
def _is_authenticated (self ):
181
196
""" Check if access token is expired """
0 commit comments