diff --git a/commands/__init__.py b/commands/__init__.py index e33820c..234242d 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -88,7 +88,6 @@ async def np(ctx): async def run_events(mqtt_host): retained = { - "bitlair/alarm", "bitlair/doorduino/doorbell", "bitlair/doorduino/dooropen", # Unused. Payload is 0|1 like the doorbell. "bitlair/doorduino/lockstate", @@ -96,9 +95,14 @@ async def run_events(mqtt_host): "bitlair/state", "bitlair/state/djo", } + non_retained = { + "bitlair/alarm/events", + } async with aiomqtt.Client(mqtt_host) as mq: - await asyncio.gather(*[mq.subscribe(topic) for topic in retained]) + await asyncio.gather( + *[mq.subscribe(topic) for topic in retained | non_retained] + ) async for msg in mq.messages: # Retained messages trigger an initial message on connecting. Prevent relaying them to Discord on startup. if str(msg.topic) in retained: @@ -107,8 +111,9 @@ async def run_events(mqtt_host): payload = msg.payload.decode("ascii") - if msg.topic.matches("bitlair/alarm"): - yield f"Alarm: {payload}" + if msg.topic.matches("bitlair/alarm/events"): + if not payload.startswith("RP"): # Ignore communication tests. + yield f"Alarm event: {payload}" elif msg.topic.matches("bitlair/state"): yield f"Bitlair is now {payload.upper()}" elif msg.topic.matches("bitlair/state/djo"):