summaryrefslogtreecommitdiff
path: root/bin/gpiorelayd.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-02-17 03:08:25 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-02-17 03:08:25 +0300
commit0ce2e41a2bad790c5232fafb4b6ed631ca8cd957 (patch)
treefd401495b87cae8c95a4c4edf2c851c8177b6069 /bin/gpiorelayd.py
parente9fc2c1835f7ac8e072919df81a6661c6308dea9 (diff)
parentb7f1d55c9b4de4d21b11e5615a5dc8be0d4e883c (diff)
merge with master
Diffstat (limited to 'bin/gpiorelayd.py')
-rwxr-xr-xbin/gpiorelayd.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/gpiorelayd.py b/bin/gpiorelayd.py
new file mode 100755
index 0000000..89ba78e
--- /dev/null
+++ b/bin/gpiorelayd.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+import logging
+import os
+import sys
+import __py_include
+
+from argparse import ArgumentParser
+from homekit.util import Addr
+from homekit.config import config
+from homekit.relay.sunxi_h3_server import RelayServer
+
+logger = logging.getLogger(__name__)
+
+
+if __name__ == '__main__':
+ if os.getegid() != 0:
+ sys.exit('Must be run as root.')
+
+ parser = ArgumentParser()
+ parser.add_argument('--pin', type=str, required=True,
+ help='name of GPIO pin of Allwinner H3 sunxi board')
+ parser.add_argument('--listen', type=str, required=True,
+ help='address to listen to, in ip:port format')
+
+ arg = config.load_app(no_config=True, parser=parser)
+ listen = Addr.fromstring(arg.listen)
+
+ try:
+ RelayServer(pinname=arg.pin, addr=listen).run()
+ except KeyboardInterrupt:
+ logger.info('Exiting...')