summaryrefslogtreecommitdiff
path: root/test/mqtt_relay_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/mqtt_relay_util.py')
-rwxr-xr-xtest/mqtt_relay_util.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/mqtt_relay_util.py b/test/mqtt_relay_util.py
new file mode 100755
index 0000000..394bbe8
--- /dev/null
+++ b/test/mqtt_relay_util.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+import __py_include
+
+from argparse import ArgumentParser
+from homekit.config import config
+from homekit.mqtt.relay import MQTTRelayController
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('--on', action='store_true')
+ parser.add_argument('--off', action='store_true')
+ parser.add_argument('--stat', action='store_true')
+
+ config.load_app('test_mqtt_relay', parser=parser)
+ arg = parser.parse_args()
+
+ relay = MQTTRelayController('test')
+ relay.connect_and_loop(loop_forever=False)
+
+ if arg.on:
+ relay.set_power(True)
+
+ elif arg.off:
+ relay.set_power(False)
+
+ elif arg.stat:
+ relay.send_stat(dict(
+ state=False,
+ signal=-59,
+ fw_v=1.0
+ )) \ No newline at end of file