fic: [Sensors monitoring] fix reload list of sensors to monitor

pull/49/head
Terrtia 2020-11-10 15:04:45 +01:00
parent 3edf227cc1
commit a297cef179
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 3 additions and 1 deletions

View File

@ -234,6 +234,7 @@ def add_sensor_to_monitor(sensor_uuid, delta_time):
r_serv_db.sadd('to_monitor:sensors', sensor_uuid)
r_serv_db.hset('to_monitor:sensor:{}'.format(sensor_uuid), 'delta_time', delta_time)
r_serv_db.set('sensors_monitoring:last_updated', int(time.time()))
r_serv_db.srem('sensors_monitoring:sensors_error', sensor_uuid)
def delete_sensor_to_monitor(sensor_uuid):
r_serv_db.srem('to_monitor:sensors', sensor_uuid)

View File

@ -32,6 +32,7 @@ def reload_all_sensors_to_monitor_dict(dict_to_monitor, last_updated):
dict_to_monitor = Sensor.get_all_sensors_to_monitor_dict()
last_updated = int(time.time())
print('updated: List of sensors to monitor')
return dict_to_monitor
if __name__ == "__main__":
@ -49,5 +50,5 @@ if __name__ == "__main__":
curr_time = int(time.time())
if curr_time - time_refresh >= 60:
time_refresh = curr_time
reload_all_sensors_to_monitor_dict(all_sensors_to_monitor, last_updated)
dict_to_monitor = reload_all_sensors_to_monitor_dict(all_sensors_to_monitor, last_updated)
##-- --##