#!/usr/bin/env python3 import include_homekit 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()