mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Enhance _set method so it can set more than just lights status
This commit is contained in:
parent
8e94aad5c1
commit
66b155c3db
1 changed files with 3 additions and 3 deletions
|
@ -99,7 +99,7 @@ def shutdown(opts, *args, **kw):
|
|||
return True
|
||||
|
||||
|
||||
def _set(lamp_id, state):
|
||||
def _set(lamp_id, state, method="state"):
|
||||
'''
|
||||
Set state to the device by ID.
|
||||
|
||||
|
@ -107,8 +107,8 @@ def _set(lamp_id, state):
|
|||
:param state:
|
||||
:return:
|
||||
'''
|
||||
res = json.loads(requests.put(CONFIG['url']+"/lights/"
|
||||
+ str(lamp_id) + "/state", json=state).content)
|
||||
url = "{0}/lights/{1}".format(CONFIG['url'], lamp_id) + (method and "/{0}".format(method) or '')
|
||||
res = json.loads(requests.put(url, json=state).content)
|
||||
res = len(res) > 1 and res[-1] or res[0]
|
||||
if res.get('success'):
|
||||
res = {'result': True}
|
||||
|
|
Loading…
Add table
Reference in a new issue