Here is the python script on my openhab server, it works :
import json
import logging
import time
import paho.mqtt.client as paho
from pysiaalarm import SIAAccount, SIAClient, SIAEvent
broker="IPADRESSOFBROKER"
port=1883
def on_publish(client,userdata,result): #create function for callback
print("data published \n")
pass
client1= paho.Client("control1") #create client object
client1.on_publish = on_publish #assign function to callback
client1.connect(broker,port)
#logging.basicConfig(level=logging.DEBUG)
events = []
def func(event: SIAEvent):
events.append(event)
with open("local_config.json", "r") as f:
config = json.load(f)
print("Config: ", config)
account = [SIAAccount(config["account_id"], config["key"])]
sleep_time = 30
with SIAClient(config["host"], config["port"], account, function=func) as client:
#time.sleep(sleep_time)
#counts = client.counts
while 1:
for ev in events:
print(ev)
ret= client1.publish("alarme/state",ev.full_message) #publish
events=[]
time.sleep(1)
#print("--------------------------------------------------")
#print("Number of events: ", len(events))
#print("Counts: ", counts)
#print("--------------------------------------------------")