|
@@ -157,9 +157,11 @@ def supervise(since):
|
157
|
157
|
|
158
|
158
|
from .models.heatpump import Heatpump
|
159
|
159
|
|
160
|
|
- last_update = None
|
161
|
|
- if since:
|
162
|
|
- last_update = int(datetime.now().strftime('%s')) - config.getint('supervisor', 'interval')
|
|
160
|
+
|
|
161
|
+ if not since:
|
|
162
|
+ last_update = 0
|
|
163
|
+ else:
|
|
164
|
+ last_update = get_last_update()
|
163
|
165
|
|
164
|
166
|
h = Heatpump(mac_address, last_update)
|
165
|
167
|
|
|
@@ -204,6 +206,7 @@ def supervise(since):
|
204
|
206
|
)
|
205
|
207
|
if post_resp.status_code == 200:
|
206
|
208
|
logger.info('POST to supervisor succeeded')
|
|
209
|
+ set_last_update(int(datetime.now().strftime('%s')))
|
207
|
210
|
|
208
|
211
|
get_path = '/'.join((
|
209
|
212
|
config.get('supervisor', 'get_path'),
|
|
@@ -223,5 +226,6 @@ def supervise(since):
|
223
|
226
|
if h.control(control_data):
|
224
|
227
|
commit()
|
225
|
228
|
logger.info('GET to supervisor succeded : updated values')
|
|
229
|
+ set_last_update(int(datetime.now().strftime('%s')))
|
226
|
230
|
else:
|
227
|
231
|
logger.warn('Unable to set data from supervisor\n{}'.format(control_data))
|