Ajax alarm system

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

:slight_smile: yes, the code needed is made by CheaterDev and can be downloaded from here:

https://github.com/Cheaterdev/sia-ha

All SIA codes supported by the SIA protocol can potentially be used. CheaterDev has not developed for all of them but fire, leak and burglar alarm status works. And if the alarm is armed or not.

Also, see my modified code in the posts above to get support for multiple zones and especially the TR code which is needed to properly reset the alarm state after a triggered alarm.

Amazing! Thanks! I don’t have Home Assistant yet so just needed to be sure I understood this correct :grinning:

1 Like

The only thing you have to do it type in the IP address and the port on Ajax HUB of your homeassistant so Ajax connects to HomeAssistant as a control central.

yeah that is perfect, I don’t want my alarm system controlled by HA exactly because of security considerations, just want to read status. And my system should arrive today!

I sorry for my English…I’m trying to setup mu Ajax hub whit home assistant but I receive this error

Setup failed for sia: Invalid config.
23:51 setup.py (ERROR)
Unable to import sia: No module named ‘sseclient’
23:51 config.py (ERROR)

this is my configuration

sia:
port: 8250
hubs:
- name: casa
account: AAA
password: XXXXXXXXXXXXXXXX

where the port is the port of my home assistant and it is configured in the surveillance station of Ajax app whit the ha ip and ha port.
can you help me please thank so much

Hi all, I’ve taken @CheaterDev s repo and set it up to work with HACS, so you can add the custom repo with this link: https://github.com/eavanvalkenburg/sia as an Integration, to get the component through the community store. I also plan to further develop the component since I now have an Ajax system, so feel free to put in issues and PRs there!

4 Likes

hi all, I’ve made some major updates to the component, same link as before, watch out because the config is very different as well. It now has the ability to specify zones with specific sensors in each (for instance if you have a zone with and without a smoke detector). But it will also auto-discover sensors once your system sends a message that is mapped to a particular type of sensor. The very least you get is a sensor.hubname_last_heartbeat which shows when the last RP messages came in, and it will put into the attributes YG messages. If there are other message types that should do something let me know of create an issue or PR in the repo. In the repo a doc with all SIA protocal messages is also present. Have fun!

A full config here:

sia:
  port:  port
  hubs:
    - name: hubname
      account: account
      encryption_key: password
      zones:
        - zone: 1
          name: zonename
          sensors:
           - alarm
           - moisture
           - smoke
6 Likes

Amazing stuff! Good work! I will test this out as soon as I can.

Hi, i don’t know where else to ask but i will give it a try here, i don’t have an ajax alarm home but in our office we do and is 100% compatible with a regional monitoring station to receive signals from the AJAX alarm using the SIA protocol. Is it possible from my home assistant by utilising the same protocol to connect to the monitoring station from my HA instance ? i am very happy with HA as alarm since i have every sensor imaginable integrated i just need an alert to the monitoring station if the alarm is triggered. sorry if i am way off topic.

Hi Eduard, this is great.
I got it to work and have the following ‘issues’

  1. Each minute my log says:
    “2019-09-26 21:11:56 ERROR (Thread-2) [custom_components.sia] subsection not found”
    Any idea where this is coming from? I did at first not have any zones configured in the hub, but when I did and added the ‘zones’ part in the config, the issue persists, so that does not look related. Despite the ‘subsection not found’ it looks like is is working though.

  2. When homebridge restarts it forgets the entity (alarm_control_panel.ajax_1_alarm in my case). The only way to have it available again is to ‘arm’ the system once. However the ‘smoke’ alarm sensor is also not listed. I do not plan to create a fire to get the entity :slight_smile:
    I did not had this issue with the ‘Cheaterdev/sia-ha’ version.

(encryption is anabled with 16 characters, and ping interval is set to 1 in the hub and ha config)

Hi @mandark, Thanks for trying it, I’ve been working on a major rebuild and that is in the Beta branch on github, that has a fix for the subsection error, but since I haven’t finished testing all the other improvements, no guaranteeL on other errors! I noticed in my own setup the same so I’ll have to look into that, but I’m traveling so want be able to do that until next week, prob Thursday.

1 Like

Hi Eduard, I have installed the beta version, and added as a quick workaround for the second issue to the end of ‘def init(self, hass, hub_config)’ in the file “init.py” the following:

sensor_id = self._upsert_sensor(1, DEVICE_CLASS_ALARM)
self._states[sensor_id].state = STATE_ALARM_DISARMED
self._states[sensor_id].assume_available()
sensor_id = self._upsert_sensor(1, DEVICE_CLASS_SMOKE)
self._states[sensor_id].state = False
self._states[sensor_id].assume_available()

(I do not have the flood sensor)
I think a more permanent solution would be to read the zone section from config file and set the default values of the defined sensors to their ‘clear’ states.

Hi @mandark and others, just released a new version, should have many fixes, and I’ve also improved the debug logging to make it a bit easier to track when something goes wrong. v0.2!