This script monitors openhab log for messages like Terminating homekit connection
and New homekit connection
and saving connection state to specified MQTT. I'm running it with following parameters:
python3 homekiter.py --mqtt_host wb.286.su --mqtt_topic_prefix /custom/homekit_connected --logfile /usr/src/logs/openhab.log
In the openhab I have created following things and items:
Thing exec:command:openhab_refresh_homekit [ command="ssh -i /openhab/conf/id_rsa openhab@localhost -p 8101 bundle:refresh org.openhab.io.homekit", interval=0, autorun=false ]