Page 1 of 1

SIA protocol

Posted: Wednesday 23 October 2019 13:16
by Ivanhoe1
Missing some way to integrate home alarm systems to Domoticz. Many of them use SIA as protocol to talk with security centrals. Support for SIA would be nice. That would make for instance Ajax possible to integrate with domoticz.

Re: SIA protocol

Posted: Monday 09 December 2019 11:39
by Lundberg
Have you got any further with this?
Looking at integrating AJAX into my Domoticz setup as well.

Re: SIA protocol

Posted: Sunday 17 April 2022 19:37
by oeildefeu
Hello,
I did a small script that runs as a service on my Pi that recover the state of the alarm (armed, normal or night mode) but it could recover many other states
It requires pysiaalarm and python3-systemd (this latter being installed by apt) as packages and some I forgot (requests?)..

Here is the code:

Code: Select all

#! /usr/bin/env python3.9
import json
import requests
#import logging
import time

from pysiaalarm import SIAAccount, SIAClient, SIAEvent
import systemd.daemon

#logging.basicConfig(level=logging.DEBUG)

local_ip = "192.168.0.1"
sia_port = 8125
sia_account = "AAAA"
url_domoticz = "http://192.168.0.1:80/"
id_armed_night = "11" #night mode alarm switch id
id_armed_normal = "21" #alarm switch id
id_text = "35" #text device to recover non recognized code

reactions = {
	"BA" : [{"state":"ALARM","value":True}],
	"BS" : [{"state":"ALARM","value":True}],#device shorted
	"BV" : [{"state":"ALARM","value":True}],#intrusion
	"HA" : [{"state":"ALARM","value":True}],#hold-up
	"JA" : [{"state":"ALARM","value":True}],#Unauthorized access keypad
	"PA" : [{"state":"ALARM","value":True}],
	"SM" : [{"state":"ALARM","value":True}], #Alarm because of movement
	"YC" : [{"state":"ALARM","value":True}],#hub offline mobile and ethernet
	"NL" : [{"state":"ARM NIGHT" ,"value":True}],
	"NC" : [{"state":"ARM NIGHT" ,"value":True}],
	"OP" : [{"state":"ARM","value":False}],
	"CF" : [{"state":"ARM","value":True}], #armed with malfunction
	"CL" : [{"state":"ARM","value":True}],
	"OA" : [{"state":"ARM","value":False}],
	"FA":  [{"state":"FIRE" ,"value":True}],
	"KA":  [{"state":"FIRE" ,"value":True}],#temperature of fire sensor
	"WA":  [{"state":"LEAK","value":True}],
	"WH":  [{"state":"LEAK" ,"value":False}],
	"GA":  [{"state":"GAS","value":True}],
	"GH":  [{"state":"GAS" ,"value":False}],
	"BR" : [{"state":"ALARM","value":False}],
	"TA" : [{"state":"LID OPEN","value":True}],
	"TR" : [{"state":"LID OPEN","value":False}],
	"ZZ" : [{"state":"Device OFF","value":True}],
	"ZY" : [{"state":"Device OFF","value":False}],
	"YP" : [{"state":"Power failure","value":True}],
	"YQ" : [{"state":"Power failure","value":False}],
	"RB" : [{"state":"Updating firmware","value":True}],
	"RS" : [{"state":"Updating firmware","value":False}],
	"RP" : [],
	"YG" : [] #New settings
	}

def func(event: SIAEvent):
	#print(event.code)
	tipo = event.code
	if tipo in reactions:
		reaction = reactions[tipo]
		for reactio in reaction:
			state = reactio["state"]
			value = reactio["value"]
			print("Event: " + state + " : " + str(value))
			if state == "ARM" and value == False:
				r = requests.get(url_domoticz + 'json.htm?type=command&param=switchlight&idx=' + id_armed_normal + '&switchcmd=Off')
				r = requests.get(url_domoticz + 'json.htm?type=command&param=switchlight&idx=' + id_armed_night + '&switchcmd=Off')
			elif state == "ARM" and value == True:
				r = requests.get(url_domoticz + 'json.htm?type=command&param=switchlight&idx=' + id_armed_normal + '&switchcmd=On')
			elif state == "ARM NIGHT" and value == True:
				r = requests.get(url_domoticz + 'json.htm?type=command&param=switchlight&idx=' + id_armed_night + '&switchcmd=On')
	else:
		print("Unknown event: " + tipo )
		r = requests.get(url_domoticz + 'json.htm?type=command&param=udevice&idx=' + id_text + '&nvalue=0&svalue='+tipo)


account = [SIAAccount(sia_account, "")]
sleep_time = 1200
count = 0
#systemd.daemon.notify('READY=1')
with SIAClient(local_ip, sia_port, account, function=func) as client:
	#time.sleep(sleep_time)
	client.start()
	systemd.daemon.notify('WATCHDOG=1')
	while (True) :
		time.sleep(1)
		count = count + 1
		if count == 30:
			count = 0
			systemd.daemon.notify('WATCHDOG=1')

Re: SIA protocol

Posted: Friday 21 February 2025 15:49
by BartSr
can you advice how to run this script?
-Bart

Re: SIA protocol

Posted: Friday 21 February 2025 15:55
by oeildefeu
Hello,
Sorry I'm on my phone, so I'll give a short but normally good reply: go to this french thread forum and translate it in your language if necessary:

https://easydomoticz.com/forum/viewtopi ... 1c2e4ff491

You'll see the steps and how to run the script!

Re: SIA protocol

Posted: Friday 21 February 2025 15:57
by waltervl
BartSr wrote: Friday 21 February 2025 15:49 can you advice how to run this script?
-Bart
Check how I did it for another python script (TelegramBot) running as a service:
https://github.com/waltervl/dynamicTele ... emd-script

Re: SIA protocol

Posted: Friday 21 February 2025 16:19
by FireWizard
Hi,

See also this thread: viewtopic.php?p=320043&hilit=SIA+protocol#p320043

I did create something in this thread, but it ended in a dead end street.

Regards