@@ -175,36 +175,24 @@ def _base_json_request(self, url: str, method: consts.Method = consts.Method.GET
175
175
def arm_home (self , sub_id : Optional [int ] = None , code : Optional [str ] = None ):
176
176
sid = "0xffffffff" if sub_id is None else str (sub_id )
177
177
data = None
178
- if code is None :
179
- data = {
180
- "Operate" : {
181
- "moduleOperateCode" : code
182
- }
183
- }
178
+ if code is not None :
179
+ data = {"Operate" : {"moduleOperateCode" : code }}
184
180
return self ._base_json_request (f"http://{ self .host } { consts .Endpoints .Alarm_ArmHome .replace ('{}' , sid )} " ,
185
181
method = consts .Method .PUT , data = data )
186
182
187
183
def arm_away (self , sub_id : Optional [int ] = None , code : Optional [str ] = None ):
188
184
sid = "0xffffffff" if sub_id is None else str (sub_id )
189
185
data = None
190
- if code is None :
191
- data = {
192
- "Operate" : {
193
- "moduleOperateCode" : code
194
- }
195
- }
186
+ if code is not None :
187
+ data = {"Operate" : {"moduleOperateCode" : code }}
196
188
return self ._base_json_request (f"http://{ self .host } { consts .Endpoints .Alarm_ArmAway .replace ('{}' , sid )} " ,
197
189
method = consts .Method .PUT , data = data )
198
190
199
191
def disarm (self , sub_id : Optional [int ] = None , code : Optional [str ] = None ):
200
192
sid = "0xffffffff" if sub_id is None else str (sub_id )
201
193
data = None
202
- if code is None :
203
- data = {
204
- "Operate" : {
205
- "moduleOperateCode" : code
206
- }
207
- }
194
+ if code is not None :
195
+ data = {"Operate" : {"moduleOperateCode" : code }}
208
196
return self ._base_json_request (f"http://{ self .host } { consts .Endpoints .Alarm_Disarm .replace ('{}' , sid )} " ,
209
197
method = consts .Method .PUT , data = data )
210
198
0 commit comments