Relay alarm events instead of alarm state
This commit is contained in:
parent
a1a197c7ee
commit
6282851acb
1 changed files with 9 additions and 4 deletions
|
@ -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"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue