Browse Source

[cli][supervise] added control variables

Maxime Alves LIRMM@home 4 years ago
parent
commit
edadd5f119
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      pyheatpump/cli.py

+ 10
- 3
pyheatpump/cli.py View File

183
 
183
 
184
     logger.debug(h.__dict__())
184
     logger.debug(h.__dict__())
185
 
185
 
186
-    post_req = requests.post(
186
+    post_resp = requests.post(
187
         url=build_url(post_url),
187
         url=build_url(post_url),
188
         json=h.__dict__(),
188
         json=h.__dict__(),
189
         verify=False
189
         verify=False
190
     )
190
     )
191
-    if post_req.status_code == 200:
191
+    if post_resp.status_code == 200:
192
         logger.info('POST to supervisor succeeded')
192
         logger.info('POST to supervisor succeeded')
193
 
193
 
194
     get_path = '/'.join((
194
     get_path = '/'.join((
200
         **{'path': get_path}
200
         **{'path': get_path}
201
     }
201
     }
202
 
202
 
203
-    get_req = requests.get(
203
+    get_resp = requests.get(
204
         url=build_url(get_url),
204
         url=build_url(get_url),
205
         verify=False
205
         verify=False
206
     )
206
     )
207
+
208
+    control_data = get_resp.json()
209
+    if h.control(control_data):
210
+        commit()
211
+        logger.info('GET to supervisor succeded : updated values')
212
+    else:
213
+        logger.warn('Unable to set data from supervisor\n{}'.format(control_data))

Loading…
Cancel
Save