From 92576cd6d3a5276b3672c1d3875f4f63c611d489 Mon Sep 17 00:00:00 2001 From: Shy Date: Tue, 14 Mar 2017 15:50:06 +0100 Subject: [PATCH] Disable retain for gate and shutdown --- c4ctrl.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/c4ctrl.py b/c4ctrl.py index 7602af9..da313ff 100755 --- a/c4ctrl.py +++ b/c4ctrl.py @@ -17,12 +17,13 @@ class C4Interface(): # Set a default topic if topic: self.topic = topic - def update(self, cmd, topic=None): + def update(self, cmd, topic=None, retain=True): """Send cmd to topic via the MQTT broker.""" from paho.mqtt import publish - # Overwrite default topic + # Overwrite defaults if topic: self.topic = topic + if retain == False: self.retain = retain if type(cmd) == list: # Add and to every message @@ -93,7 +94,7 @@ class C4Interface(): def open_gate(self): """Open the gate.""" - self.update(cmd=b'\x01', topic="club/gate") + self.update(cmd=b'\x01', topic="club/gate", retain=False) def shutdown(self, force=False): """Invoke the shutdown routine.""" @@ -101,7 +102,7 @@ class C4Interface(): payload = b'\x44' else: payload = b'\x00' - self.update(cmd=payload, topic="club/shutdown") + self.update(cmd=payload, topic="club/shutdown", retain=False) class Dmx: