Skip to content

Commit

Permalink
Merge pull request #62 from konikoni428/fix/mqtt-sample-not-working
Browse files Browse the repository at this point in the history
MQTT sample can't work properly
  • Loading branch information
mochipon authored Aug 1, 2022
2 parents e15fe11 + 0181b40 commit 4ca3826
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion example/mqtt2sesame/mqtt2sesame.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def onMQTTMessage(client, userdata, msg: MQTTMessage) -> None:

if not isinstance(uuid, str):
raise TypeError("Failed to parse the device uuid from topic")
if cmd not in ["LOCK, UNLOCK"]:
if cmd not in ["LOCK", "UNLOCK"]:
raise TypeError("Failed to parse command: {}".format(cmd))

if cmd == "LOCK" or cmd == "UNLOCK":
Expand All @@ -187,6 +187,8 @@ def onMQTTMessage(client, userdata, msg: MQTTMessage) -> None:
async def runner():
global mqtt_client, config, cmd_queue, connected_devices

cmd_queue = asyncio.Queue()

lwt_topic = "{}/LWT".format(config["mqtt"]["topic_prefix"])
mqtt_client.will_set(lwt_topic, payload="offline", qos=1, retain=True)
mqtt_client.on_message = onMQTTMessage
Expand Down

0 comments on commit 4ca3826

Please sign in to comment.