Make JSON configuratino actually work
This commit is contained in:
@@ -5,9 +5,8 @@ import ssl
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
cfg = None
|
cfg = None
|
||||||
with open('../config.json') as json_config:
|
with open('config.json') as json_config:
|
||||||
cfg = json.load(json_config)
|
cfg = json.load(json_config)
|
||||||
|
|
||||||
connected = False
|
connected = False
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
@@ -35,11 +34,11 @@ mqttc.on_connect = on_connect
|
|||||||
mqttc.on_disconnect = on_disconnect
|
mqttc.on_disconnect = on_disconnect
|
||||||
mqttc.on_message = on_message
|
mqttc.on_message = on_message
|
||||||
|
|
||||||
mqttc.connect(cfg.mqtt.host, cfg.mqtt.port, cfg.mqtt.timeout)
|
mqttc.connect(cfg["mqtt"]["host"], cfg["mqtt"]["port"], cfg["mqtt"]["timeout"])
|
||||||
|
|
||||||
mqttc.loop_start()
|
mqttc.loop_start()
|
||||||
|
|
||||||
mqttc.will_set("hello/test", "Disconnected", )
|
# mqttc.will_set("hello/test", "Disconnected", )
|
||||||
|
|
||||||
pub = input("Enter something to publish: ")
|
pub = input("Enter something to publish: ")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user