@@ -184,7 +184,7 @@ def req_post(self,
184
184
def req_put (self ,
185
185
uri_path : str ,
186
186
data : typing .Optional [dict ] = None ,
187
- json : typing .Optional [dict ] = None ,
187
+ json_data : typing .Optional [dict ] = None ,
188
188
headers : typing .Optional [dict ] = None
189
189
) -> None :
190
190
"""Helper method for initiating a HTTP PUT request.
@@ -195,7 +195,7 @@ def req_put(self,
195
195
Args:
196
196
uri_path (str): The path to be used in the PUT request.
197
197
data (dict, optional): A optional dict with data to be submitted as part of the PUT request.
198
- json : Data to be submitted as json.
198
+ json_data : Data to be submitted as json.
199
199
headers: Specify optional custom headers.
200
200
201
201
Returns:
@@ -204,7 +204,7 @@ def req_put(self,
204
204
if headers is None :
205
205
headers = {'Content-Type' : 'text/plain' }
206
206
207
- r = self .session .put (self .url_rest + uri_path , data = data , json = json , headers = headers , timeout = self .timeout )
207
+ r = self .session .put (self .url_rest + uri_path , data = data , json = json_data , headers = headers , timeout = self .timeout )
208
208
self ._check_req_return (r )
209
209
210
210
# fetch all items
@@ -300,7 +300,7 @@ def get_item_raw(self, name: str) -> typing.Any:
300
300
Returns:
301
301
dict: A JSON decoded dict.
302
302
"""
303
- return self .req_get ('/items/{}' . format ( name ) )
303
+ return self .req_get (f '/items/{ name } ' )
304
304
305
305
def logout (self ) -> bool :
306
306
"""OAuth2 session logout method.
@@ -378,7 +378,7 @@ def create_or_update_item(self,
378
378
Can be one of ['EQUALITY', 'AND', 'OR', 'NAND', 'NOR', 'AVG', 'SUM', 'MAX', 'MIN', 'COUNT', 'LATEST', 'EARLIEST']
379
379
function_params: Optional list of function params (no documentation found), depending on function name.
380
380
"""
381
- paramdict : typing .Dict [str , typing .Union [str , typing .List [str ], typing .Dict [str , typing .Union [str , typing .List ]]]] = {}
381
+ paramdict : typing .Dict [str , typing .Union [str , typing .List [str ], typing .Dict [str , typing .Union [str , typing .List [ str ] ]]]] = {}
382
382
383
383
if isinstance (_type , type ):
384
384
if issubclass (_type , openhab .items .Item ):
@@ -427,14 +427,14 @@ def create_or_update_item(self,
427
427
if function_name == 'COUNT' and (not function_params or len (function_params ) != 1 ):
428
428
raise ValueError (f'Group function "{ function_name } " requires one arguments' )
429
429
430
- paramdict ['function' ] = {'name' : function_name }
431
-
432
430
if function_params :
433
- paramdict ['function' ]['params' ] = function_params
431
+ paramdict ['function' ] = {'name' : function_name , 'params' : function_params }
432
+ else :
433
+ paramdict ['function' ] = {'name' : function_name }
434
434
435
435
self .logger .debug ('About to create item with PUT request:\n %s' , str (paramdict ))
436
436
437
- self .req_put (f'/items/{ name } ' , json = paramdict , headers = {'Content-Type' : 'application/json' })
437
+ self .req_put (f'/items/{ name } ' , json_data = paramdict , headers = {'Content-Type' : 'application/json' })
438
438
439
439
440
440
# noinspection PyPep8Naming
0 commit comments