[cli][supervise] use last_update configuration value
This commit is contained in:
parent
e4b9b43ddd
commit
34a2f0c49d
1 changed files with 7 additions and 3 deletions
|
|
@ -157,9 +157,11 @@ def supervise(since):
|
|||
|
||||
from .models.heatpump import Heatpump
|
||||
|
||||
last_update = None
|
||||
if since:
|
||||
last_update = int(datetime.now().strftime('%s')) - config.getint('supervisor', 'interval')
|
||||
|
||||
if not since:
|
||||
last_update = 0
|
||||
else:
|
||||
last_update = get_last_update()
|
||||
|
||||
h = Heatpump(mac_address, last_update)
|
||||
|
||||
|
|
@ -204,6 +206,7 @@ def supervise(since):
|
|||
)
|
||||
if post_resp.status_code == 200:
|
||||
logger.info('POST to supervisor succeeded')
|
||||
set_last_update(int(datetime.now().strftime('%s')))
|
||||
|
||||
get_path = '/'.join((
|
||||
config.get('supervisor', 'get_path'),
|
||||
|
|
@ -223,5 +226,6 @@ def supervise(since):
|
|||
if h.control(control_data):
|
||||
commit()
|
||||
logger.info('GET to supervisor succeded : updated values')
|
||||
set_last_update(int(datetime.now().strftime('%s')))
|
||||
else:
|
||||
logger.warn('Unable to set data from supervisor\n{}'.format(control_data))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue