summaryrefslogtreecommitdiff
path: root/bin/inverter_mqtt_util.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/inverter_mqtt_util.py
parente9fc2c1835f7ac8e072919df81a6661c6308dea9 (diff)
parentb7f1d55c9b4de4d21b11e5615a5dc8be0d4e883c (diff)
merge with master
Diffstat (limited to 'bin/inverter_mqtt_util.py')
-rwxr-xr-xbin/inverter_mqtt_util.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/inverter_mqtt_util.py b/bin/inverter_mqtt_util.py
new file mode 100755
index 0000000..6003c62
--- /dev/null
+++ b/bin/inverter_mqtt_util.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import __py_include
+
+from argparse import ArgumentParser
+from homekit.config import config
+from homekit.mqtt import MqttWrapper, MqttNode
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('mode', type=str, choices=('sender', 'receiver'), nargs=1)
+
+ config.load_app('inverter_mqtt_util', parser=parser)
+ arg = parser.parse_args()
+ mode = arg.mode[0]
+
+ mqtt = MqttWrapper(client_id=f'inverter_mqtt_{mode}',
+ clean_session=mode != 'receiver')
+ node = MqttNode(node_id='inverter')
+ module_kwargs = {}
+ if mode == 'sender':
+ module_kwargs['status_poll_freq'] = int(config.app_config['poll_freq'])
+ module_kwargs['generation_poll_freq'] = int(config.app_config['generation_poll_freq'])
+ node.load_module('inverter', **module_kwargs)
+ mqtt.add_node(node)
+
+ mqtt.connect_and_loop()