Ajax alarm system

Hi @eavanvalkenburg. How are you so sure Jablotron 100 can be made to work with HA?

a friend of mine has a JA-1118N module and a RPI connected to that, where he can read the status of the system and then send it to MQTT in HASS.

Ah, he’s using an 8-channel BUS with PGM. Thanks. I was wondering how he has made a connection, but that will do yeah.

I found a way to get notifications about the AJAX system in HA. I will later write more on it, maybe even a custom component, but the key is in the supported SIA protocol as of version 2.7 of the AJAX system.

This is my current setup
AJAXSIA protocol — > SIA system (python script)MQTT publish — > MosquittoMQTT subscribe — > Home Assistant MQTT sensor

By setting up a local SIA monitoring server (based on python script like this one) on my LAN I was able to receive messages on that server from the AJAX alarm system.

I need to write a parser to parse the different SIA codes, see http://mocca.parcye.com/files/76/27/SIA%20coderingsoverzicht.pdf.88 in useful states which can be published through MQTT to a specific topic. Since I have not yet worked on the parsing, as test I am pushing the full SIA message.

In Home Assistant I created an MQTT sensor - which is subscribed to that topic.

The nice thing is that AJAX sends an acknowledgement message every couple of seconds, so as your AJAX hub goes down, you are also able to monitor that from within HA.

To be continued.

ps. since i am a new user i can only create 2 links max

2 Likes

I want to hear more about this when you finalized the setup! Maybe even write a blog post how to install/configure all components to make this work.

Yesterday I installed this custom component: https://github.com/Cheaterdev/sia-ha
This works perfectly for me! You would not need to use an MQTT broker anymore, it is directly catched in the custom component in HA.
You could alter the init script (reactions list) to suit your needs based on the SIA codes coming from the Ajax hub.

2 Likes

I too am looking at AJAX as a security means for my house. Since I want to start using Hass.io, I came across this topic. Isn’t this custom component using the CMS feature of AJAX? https://support.ajax.systems/en-us/article/327-how-to-use-the-sia-protocol-to-connect-the-hub-to-the-central-monitoring-station

I was wondering wether or not you still don’t want it to update your MQTT broker, since then you can subscribe multiple components to it (e.g. Hue lightning etc etc)

1 Like

Hi Sander
Please confirm if this was also with use of the Ajax alarm system? Hoping to do the same.

I can confirm that the sia-ha component works with ajax.
I have been testing it my self and added a line of code in the init__.py to handle the reset of tamper alarm, but I have written to the guy at github also, so I hope he will add it in his project.
but it really works nice

Hi Allan,

I have just purchased the Ajax Alarm System, and I am running the latest HA version (096.3). I am however getting the following in my logs:

2019-07-22 21:44:17 INFO (MainThread) [homeassistant.setup] Setting up sia
2019-07-22 21:44:17 ERROR (MainThread) [homeassistant.setup] Error during setup of component sia
File “/Users/moodiejo/.homeassistant/custom_components/sia/init.py”, line 83, in setup
File “/Users/moodiejo/.homeassistant/custom_components/sia/init.py”, line 160, in init

Any idea on this for me please?

I do realise that you are not the developer of this custom component, but any help will be truly appreciated.

Thanks you in advance.

John Moodie

Anybody who has solved the SIA integration when having more than one Zone? I have written about it in this issue tracker for SIA-HA by Cheaterdev: https://github.com/Cheaterdev/sia-ha/issues/4#issuecomment-514727373

The problem is that when having more than one zone you get unknown SIA codes. Even though I have figured out what they represent, this means that the SIA integration is unusable for anybody with more than one alarm zone. We need to be able to identify which zone is armed and which is not…

1 Like

Hi John

At first, I added the custom_components folder in the config folder, not sure if it makes a difference but thats how I read it should be.

Do you use encryption on your sia connection?, I don’t, maybe that also can cause an error

Hi Allan,

Thank you for replying.

I don’t use encryption, even though the error seems to be encryption related, possibly even a python library. See further below for a full stack trace. I will scratch more on the python side and see what I can find.

The ‘sia’ folder has been added to my custom_components folder, where I also run other custom components.

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/setup.py”, line 156, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/Users/moodiejo/.homeassistant/custom_components/sia/init.py”, line 83, in setup
hass.data[DOMAIN][hub_config[CONF_ACCOUNT]] = EncryptedHub(hass, hub_config)
File “/Users/moodiejo/.homeassistant/custom_components/sia/init.py”, line 160, in init
_cipher = AES.new(self._key, AES.MODE_CBC, iv)
File “/Users/moodiejo/.homeassistant/deps/lib/python/site-packages/Crypto/Cipher/AES.py”, line 232, in new
return _create_cipher(sys.modules[name], key, mode, *args, **kwargs)
File “/Users/moodiejo/.homeassistant/deps/lib/python/site-packages/Crypto/Cipher/init.py”, line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File “/Users/moodiejo/.homeassistant/deps/lib/python/site-packages/Crypto/Cipher/_mode_cbc.py”, line 274, in _create_cbc_cipher
cipher_state = factory._create_base_cipher(kwargs)
File “/Users/moodiejo/.homeassistant/deps/lib/python/site-packages/Crypto/Cipher/AES.py”, line 93, in _create_base_cipher
raise ValueError(“Incorrect AES key length (%d bytes)” % len(key))
ValueError: Incorrect AES key length (15 bytes)

Issue bypassed - I removed the password parameter in my configuration.yaml, but am also now getting the Unknown Events as reported earlier.

Well I solved it myself. I have two zones and this worked for me. Used IObroker to find out what the SIA codes looked like and included the zone part in sia-ha.

I changed the init.py code to include the zone part and changed and added reactions as well as sensors to all of them. Would of course be better to dynamically include additional zones or to be able to define how many you have somewhere. But for those of you that are running two zones you can use the below code in your “init.py” file.

class Hub:
    reactions = {            
            "Nri1/BA" : [{"state":"ALARM_ZONE1","value":True}],
            "Nri1/TA" : [{"state":"ALARM_ZONE1" ,"value":True}],
            "Nri1/CG" : [{"state":"STATUS_ZONE1" ,"value":False},{"state":"STATUS_NIGHT_MODE" ,"value":False}],
            "Nri1/CL" : [{"state":"STATUS_ZONE1" ,"value":False},{"state":"STATUS_NIGHT_MODE" ,"value":False}],
            "Nri1/NL" : [{"state":"STATUS_NIGHT_MODE" ,"value":False}],
            "Nri1/NP" : [{"state":"STATUS_NIGHT_MODE" ,"value":True}],
            "Nri1/WA":  [{"state":"LEAK_ZONE1","value":True}],
            "Nri1/WH":  [{"state":"LEAK_ZONE1" ,"value":False}],
            "Nri1/GA":  [{"state":"GAS_ZONE1","value":True}],
            "Nri1/GH":  [{"state":"GAS_ZONE1" ,"value":False}],
            "Nri1/BR" : [{"state":"ALARM_ZONE1","value":False}],
            "Nri1/OG" : [{"state":"STATUS_ZONE1","value":True},{"state":"STATUS_NIGHT_MODE","value":True}],
            "Nri1/OP" : [{"state":"STATUS_ZONE1","value":True},{"state":"STATUS_NIGHT_MODE","value":True}],
            "Nri2/BA" : [{"state":"ALARM_ZONE2","value":True}],
            "Nri2/TA" : [{"state":"ALARM_ZONE2" ,"value":True}],
            "Nri2/CG" : [{"state":"STATUS_ZONE2" ,"value":False}],
            "Nri2/CL" : [{"state":"STATUS_ZONE2" ,"value":False}],
            "Nri2/WA":  [{"state":"LEAK_ZONE2","value":True}],
            "Nri2/WH":  [{"state":"LEAK_ZONE2" ,"value":False}],
            "Nri2/GA":  [{"state":"GAS_ZONE2","value":True}],
            "Nri2/GH":  [{"state":"GAS_ZONE2" ,"value":False}],
            "Nri2/BR" : [{"state":"ALARM_ZONE2","value":False}],
            "Nri2/OG" : [{"state":"STATUS_ZONE2","value":True}],
            "Nri2/OP" : [{"state":"STATUS_ZONE2","value":True}],
            "Nri0/RP" : []
        }

    def __init__(self, hass, hub_config):
        self._name = hub_config[CONF_NAME]
        self._accountId = hub_config[CONF_ACCOUNT]
        self._hass = hass
        self._states = {}
        self._states["LEAK_ZONE1"] = SIABinarySensor("sia_leak_zone1_" + self._name,"moisture" , hass)
        self._states["GAS_ZONE1"] = SIABinarySensor("sia_gas_zone1_" + self._name,"smoke", hass)
        self._states["ALARM_ZONE1"]  = SIABinarySensor("sia_alarm_zone1_" + self._name,"safety", hass)
        self._states["STATUS_ZONE1"]  = SIABinarySensor("sia_status_zone1_" + self._name, "lock", hass)
        self._states["STATUS_NIGHT_MODE"]  = SIABinarySensor("sia_status_night_mode_" + self._name, "lock", hass)
        self._states["LEAK_ZONE2"] = SIABinarySensor("sia_leak_zone2_" + self._name,"moisture" , hass)
        self._states["GAS_ZONE2"] = SIABinarySensor("sia_gas_zone2_" + self._name,"smoke", hass)
        self._states["ALARM_ZONE2"]  = SIABinarySensor("sia_alarm_zone2_" + self._name,"safety", hass)
        self._states["STATUS_ZONE2"]  = SIABinarySensor("sia_status_zone2_" + self._name, "lock", hass)
    
    def manage_string(self, msg):
        _LOGGER.debug("manage_string: " + msg)
        
        pos = msg.find('/')        
        assert pos>=0, "Can't find '/', message is possibly encrypted"
        # tipo = msg[pos+1:pos+3]
        tipo = msg[pos-4:pos+3]

Edit: In order for the alarm status to be reset to safe/normal after a triggered alarm has been deactivated you need to add the TR code. Otherwise the alarm status will always show “unsafe”.

"Nri1/TR" : [{"state":"ALARM_ZONE1" ,"value":False}],
"Nri2/TR" : [{"state":"ALARM_ZONE2" ,"value":False}],
2 Likes

does it require any specific components in your ajax system or is it just the Hub (not even the Hub Plus) connected into your network?

You just have to set up the SIA Protocol in the Ajax App. You define which IP your HA server is on and then set a port that is not used for anything else (I used 8124). The Ping interval should be set to 1 minute and with connect on demand enabled. Then you download CheaterDev’s repository and add the sia integration in the configuration.yaml file.

The only thing I had trouble with was the encryption password which only may contain up to 32 HEX or 16 ASCII characters. It took a shile to figure out that it was the password that was not formatted correctly. This is explained here:

thanks for the extensive writeup! much appreciated, will order my Ajax system soon! And the component is purely Ajax -> HA (one-way) and not two-way correct (although the protocol could do two-way presumably)?

Yes, only one way. I use it purely for reading the status of the alarm and to automate things based on that.

If you want two way for the possibility to arm and disarm the alarm there is no Ajax supported solution. You could achieve it by stripping an Ajax SpaceControl remote and solder it to a remote controlled relay. For example a Sonoff or similar and then connect that to HA. But you need to understand the security implications of doing this.

Wait what!? Are you saying that without any additional hardware I can read the Ajax alarm status in HA? If so this is amazing! I love my Ajax alarm but wish I could get the status in HA (armed, disarmed, intrution detected). Are these three states the ones that you get and it is updated every minute?

Edit:
I have been in contact with Ajax and IFTTT is something they are working on (again) so that will hopefully be amazng too.

1 Like