Gate: remove MQTT
This commit is contained in:
parent
d1f6944216
commit
d1f952b87e
@ -154,14 +154,14 @@ class Gate(object):
|
||||
self.__engine_1.down()
|
||||
# workaround for high power after starting engine
|
||||
time.sleep(1)
|
||||
msg = str(time.time()) + " Initialization"
|
||||
try:
|
||||
self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
self.__client.loop_start()
|
||||
self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
self.__client.loop_stop()
|
||||
except (ValueError, TypeError, socket.error, ssl.CertificateError):
|
||||
logging.info('unable to publish to mqtt')
|
||||
# msg = str(time.time()) + " Initialization"
|
||||
# try:
|
||||
# self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
# self.__client.loop_start()
|
||||
# self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
# self.__client.loop_stop()
|
||||
# except (ValueError, TypeError, socket.error, ssl.CertificateError):
|
||||
# logging.info('unable to publish to mqtt')
|
||||
pwr = self.__power_sensor.power_mw()
|
||||
msg = 'e1: {} mW'.format(pwr)
|
||||
logging.debug(msg)
|
||||
@ -232,13 +232,13 @@ class Gate(object):
|
||||
time.sleep(1)
|
||||
self.__engine_2.stop()
|
||||
msg = str(time.time()) + " Opened"
|
||||
try:
|
||||
self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
self.__client.loop_start()
|
||||
self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
self.__client.loop_stop()
|
||||
except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
# try:
|
||||
# self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
# self.__client.loop_start()
|
||||
# self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
# self.__client.loop_stop()
|
||||
# except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
# logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
if check_to_close(light_avg) is True:
|
||||
next_state = STATE_CLOSING_1
|
||||
self.__update_state(next_state)
|
||||
@ -247,14 +247,14 @@ class Gate(object):
|
||||
next_state = self.__next_state
|
||||
if self.__is_transition():
|
||||
self.__engine_2.stop()
|
||||
msg = str(time.time()) + " Closed"
|
||||
try:
|
||||
self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
self.__client.loop_start()
|
||||
self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
self.__client.loop_stop()
|
||||
except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
# msg = str(time.time()) + " Closed"
|
||||
# try:
|
||||
# self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
# self.__client.loop_start()
|
||||
# self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
# self.__client.loop_stop()
|
||||
# except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
# logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
if check_to_open(light_avg) is True:
|
||||
next_state = STATE_OPENING_1
|
||||
self.__update_state(next_state)
|
||||
@ -263,14 +263,14 @@ class Gate(object):
|
||||
next_state = self.__next_state
|
||||
if self.__is_transition():
|
||||
self.__engine_1.up()
|
||||
msg = str(time.time()) + " Opening" + str(light_avg) + " lx"
|
||||
try:
|
||||
self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
self.__client.loop_start()
|
||||
self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
self.__client.loop_stop()
|
||||
except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
# msg = str(time.time()) + " Opening" + str(light_avg) + " lx"
|
||||
# try:
|
||||
# self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
# self.__client.loop_start()
|
||||
# self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
# self.__client.loop_stop()
|
||||
# except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
# logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
self.__gate_run_time = time.time()
|
||||
|
||||
# workaround for high power after starting engine
|
||||
@ -312,14 +312,14 @@ class Gate(object):
|
||||
next_state = self.__next_state
|
||||
if self.__is_transition():
|
||||
self.__engine_1.down()
|
||||
msg = str(time.time()) + " Closing " + str(light_avg) + " lx"
|
||||
try:
|
||||
self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
self.__client.loop_start()
|
||||
self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
self.__client.loop_stop()
|
||||
except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
# msg = str(time.time()) + " Closing " + str(light_avg) + " lx"
|
||||
# try:
|
||||
# self.__client.connect(MQTT_HOST, MQTT_PORT)
|
||||
# self.__client.loop_start()
|
||||
# self.__client.publish(MQTT_TOPIC, msg, qos=2, retain=True)
|
||||
# self.__client.loop_stop()
|
||||
# except (ValueError, TypeError, socket.error, ssl.CertificateError) as err:
|
||||
# logging.info('unable to publish to mqtt ({})'.format(err))
|
||||
self.__gate_run_time = time.time()
|
||||
|
||||
# workaround for high power after starting engine
|
||||
|
Loading…
Reference in New Issue
Block a user