fix indentations
This commit is contained in:
parent
adeabcae00
commit
c5f86c256d
|
@ -35,9 +35,9 @@ class Controller:
|
||||||
displayL = None
|
displayL = None
|
||||||
displayR = None
|
displayR = None
|
||||||
|
|
||||||
basetopic = None
|
basetopic = None
|
||||||
mqtthost = None
|
mqtthost = None
|
||||||
mqttport = None
|
mqttport = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, base_topic, mqtt_host, mqtt_port = 1883):
|
def __init__(self, base_topic, mqtt_host, mqtt_port = 1883):
|
||||||
|
@ -77,14 +77,14 @@ class Controller:
|
||||||
self.displayL.brightness = 1.0
|
self.displayL.brightness = 1.0
|
||||||
self.displayR.brightness = 1.0
|
self.displayR.brightness = 1.0
|
||||||
|
|
||||||
self.basetopic = basetopic
|
self.basetopic = basetopic
|
||||||
self.mqtthost = mqtt_host
|
self.mqtthost = mqtt_host
|
||||||
self.mqttport = mqtt_port
|
self.mqttport = mqtt_port
|
||||||
|
|
||||||
connectToMQTT()
|
connectToMQTT()
|
||||||
|
|
||||||
def connectToMQTT(self):
|
def connectToMQTT(self):
|
||||||
print("trying to connect to mqtt")
|
print("trying to connect to mqtt")
|
||||||
self.mqtt = mqtt.Client()
|
self.mqtt = mqtt.Client()
|
||||||
self.mqtt.on_connect = self.on_connect
|
self.mqtt.on_connect = self.on_connect
|
||||||
self.mqtt.on_message = self.on_message
|
self.mqtt.on_message = self.on_message
|
||||||
|
@ -97,7 +97,7 @@ class Controller:
|
||||||
|
|
||||||
def on_disconnect(self, client, userdata, rc):
|
def on_disconnect(self, client, userdata, rc):
|
||||||
print("MQTT disconnected")
|
print("MQTT disconnected")
|
||||||
self.mode = Mode.STATIC
|
self.mode = Mode.STATIC
|
||||||
self.text = "- - - -"
|
self.text = "- - - -"
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ class Controller:
|
||||||
self.mqtt.publish(self.topic + "/" + "$hostname", socket.gethostname() , 1 )
|
self.mqtt.publish(self.topic + "/" + "$hostname", socket.gethostname() , 1 )
|
||||||
self.mqtt.publish(self.topic + "/" + "$localip", self.get_ip() , 1 )
|
self.mqtt.publish(self.topic + "/" + "$localip", self.get_ip() , 1 )
|
||||||
|
|
||||||
#clear display
|
#clear display
|
||||||
self.mode = Mode.STATIC
|
self.mode = Mode.STATIC
|
||||||
self.text = ""
|
self.text = ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,10 +261,10 @@ class Controller:
|
||||||
|
|
||||||
while run:
|
while run:
|
||||||
|
|
||||||
if !self.connected:
|
if !self.connected:
|
||||||
if (time.time()>self.last_reconnectTry+30):
|
if (time.time()>self.last_reconnectTry+30):
|
||||||
connectToMQTT()
|
connectToMQTT()
|
||||||
self.last_reconnectTry=time.time()
|
self.last_reconnectTry=time.time()
|
||||||
self.mqtt.loop(0.1) #with block timeout
|
self.mqtt.loop(0.1) #with block timeout
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue