diff --git a/src/gate/gate_state.py b/src/gate/gate_state.py index 627f516..1872bf4 100644 --- a/src/gate/gate_state.py +++ b/src/gate/gate_state.py @@ -56,6 +56,7 @@ class GateState(object): self.__power_data = DataBuffer(POWER_CONSECUTIVE_READS) self.__gate_move_timeout = 0 self.__light_read_timeout = 0 + self.__error_count = 0 def poll(self): current_time = time() @@ -165,4 +166,10 @@ class GateState(object): self.__gate_handler.stop() self.__comserver.transmit(MQTT_TOPIC, str(time()) + \ " Error handler!!!") - self.__update_state(STATE_INIT) + if self.__error_count >= 5: + self.__update_state(STATE_INIT) + self.__error_count += 1 + else: + self.__comserver.transmit(MQTT_TOPIC, str(time()) + \ + "Error Handler - couldn't reinitiate " + \ + "system. Bye bye...")