Ajax alarm system

Can you actually get the status of each individual AJAX sensor in Home Assistant ?
I thought it was not possible with the AJAX Api.

In a Professor Farnsworth voice: ‘Gooood news everyone!’

I’m hearing confirmations about a proper API, specifically for home automation purposes, that AJAX seem to be releasing this year.

2 Likes

Please elaborate! From whom? Ajax themselves?

My alarm status goes from armed to unavailable after a short time. Then when i disarm it goed from disarmed to unavailable

You probably have the wrong ping frequency set in the Ajax Hub compared to your integration. Both needs to be set to 1 min.

From AJAX themselves yes. I first heard it from a developer on another home automation platform who is in contact with AJAX about a smart home project. The second reference was written in a review of the AJAX system by a Dutch website called Smarthome Magazine.

2 Likes

Great news! I really hope they will implement the ability to get each sensor’s individual status through Home Assistant. This is the only thing I am currently missing.

Except for the SIA integration I am currently using a Wemos D1 Mini ESP8266 via mqtt to control the button presses on my SpaceControl. So I now have the ability to fully control my Ajax alarm through Home Assistant. The only thing missing is the possibility to utilize sensors such as DoorProtect and MotionProtect for smart home purposes.

Thanks. Thats it. Had the ajax aystem on 24hours

1 Like

Has anyone updated to the new release? I get this when doing a test (via the add-on Check Home Assistant configuration). Anything I should consider doing before updating?

gave it a second try and this time I get this error message:

Testing configuration at /tmp/config
INFO:homeassistant.util.package:Attempting install of psutil==5.6.7
INFO:homeassistant.util.package:Attempting install of aiohttp_cors==0.7.0
INFO:homeassistant.util.package:Attempting install of hass-nabucasa==0.31
INFO:homeassistant.util.package:Attempting install of home-assistant-frontend==20200220.4
INFO:homeassistant.util.package:Attempting install of PyNaCl==1.3.0
INFO:homeassistant.util.package:Attempting install of defusedxml==0.6.0
INFO:homeassistant.util.package:Attempting install of netdisco==2.6.0
INFO:homeassistant.util.package:Attempting install of distro==1.4.0
INFO:homeassistant.util.package:Attempting install of sqlalchemy==1.3.13
INFO:homeassistant.util.package:Attempting install of HAP-python==2.7.0
INFO:homeassistant.util.package:Attempting install of mutagen==1.43.0
INFO:homeassistant.util.package:Attempting install of gTTS-token==1.1.3
Failed config
  General Errors: 
    - Component error: sia - No module named 'Crypto'

Successful config (partial)

HI, can any one help me to add Custom cards for -key fob - (disarmed;armed;night mode)

the SIA protocol doesn’t allow changing the mode, it is for listening only unfortunately, hopefully Ajax will release their API at some point, so we can do more advanced stuff!

1 Like

thnks @eavanvalkenburg

If you want to be able to control the Ajax alarm from HA you can do it by soldering an ESP8266 such as a Wemos D1 Mini onto a Ajax SpaceControl and use MQTT to control the SpaceControl buttons from HA.

The soldering part is a little bit tricky but I managed to do it without any previous soldering experience. The Arduino part and MQTT setup is pretty straight forward when you have some example code. There are numerous guides online showing how to add a code sketch to an ESP8266 card.

Also, if you have Home Assistant (former Hass.io) and not Home Assistant Core you can easily add the Mosquitto MQTT broker as an addon. Then you just need to add the MQTT switches into your switches.yaml and the automations into automations.yaml.

I started out by following this guide: https://bitbucket.org/iesus_sonesson/d1-ajax-mqtt/src/master/

Since I have two zones I actually soldered two SpaceControls onto the ESP8266 board and used the below code sketch. You can see which pins I used on the ESP8266 board:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#define  ARM_ZONE2     D1
#define  DISARM_ZONE2  D5
#define  DISARM_ZONE1  D2
#define  ARM_ZONE1     D6
#define  NIGHT         D7

WiFiClient   espClient;
PubSubClient mqtt(espClient);
const char* ssid     = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* host     = "YOUR_MQTT_BROKER_IP";

void setup() {
  Serial.begin(115200);
  //built in led on because it looks good
  pinMode(LED_BUILTIN, OUTPUT);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(500);
  }
  mqtt.setServer(host, 1883);
  mqtt.setCallback(callback);
}

void reconnect() {
  while (!mqtt.connected()) {
    Serial.print("Attempting MQTT connection...");
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // if (mqtt.connect(clientId.c_str())) {
    if (mqtt.connect(clientId.c_str(), "mqtt", "RANDOM_20_CHARACTER_ID")) {
      mqtt.subscribe("ajax/alarm");
    } else {
      Serial.print("failed, rc=");
      Serial.print(mqtt.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
  Serial.println("MQTT Connected.");
}

void loop() {
  if (!mqtt.connected()) {
    reconnect();
  }
  mqtt.loop();
}


void callback(
  char* topic,
  byte* payload,
  unsigned int length
) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  String msg = "";
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
    msg = msg+(char)payload[i];
  }

  if (strcmp(topic, "ajax/alarm") == 0 && msg == "arm_zone1") {
    pressButton(ARM_ZONE1);
  } else if (strcmp(topic, "ajax/alarm") == 0 && msg == "disarm_zone1") {
    pressButton(DISARM_ZONE1);
  } else if (strcmp(topic, "ajax/alarm") == 0 && msg == "arm_zone2") {
    pressButton(ARM_ZONE2);
  } else if (strcmp(topic, "ajax/alarm") == 0 && msg == "disarm_zone2") {
    pressButton(DISARM_ZONE2);
  } else if (strcmp(topic, "ajax/alarm") == 0 && msg == "night") {
    pressButton(NIGHT);
  }
}

void pressButton(int buttonId) {
  pinMode(buttonId, OUTPUT);
  digitalWrite(buttonId, LOW);
  delay(300);
  pinMode(buttonId, INPUT);
  Serial.println(" SENT SIGNAL");
}

This is an example for your automations.yaml, repeat and modify for multiple zones and night mode:

# Zone 1
- id: alarm-state-to-mqtt-armed-zone1
  alias: Ajax - Alarm armed state zone 1 to mqtt
  trigger:
    - entity_id: binary_sensor.sia_status_zone1_ajax
      platform: state
  action:
    - service: mqtt.publish
      data:
        topic: ajax/armed-state-zone1
        payload_template: "{% if is_state('binary_sensor.sia_status_zone1_ajax', 'on') %}
            off
          {% else %}
            on
          {% endif %}"
        retain: true

This is for your switches.yaml:

# Ajax MQTT ESP8266 D1 Mini SpaceControl
  - platform: mqtt
    name: "ajax_arm_zone1"
    state_topic: "ajax/armed-state-zone1"
    state_on: "on"
    state_off: "off"
    command_topic: "ajax/alarm"
    payload_on: "arm_zone1"
    payload_off: "disarm_zone1"
    unique_id: "ajax_arm_zone1"

Hopefully someone can use this :slight_smile:

9 Likes

fireon,
you’ve just made my day. I am in the beginning of what you have done. I have basic soldering skills, have wemos d1 mini, some experience with flashing esp8266 and waiting for new SpaceControle victim to arrive.

Thank you a lot for the code examples. :heart:
I will be very thankful for sharing photos of your Ajax SpaceControl soldered to Wemos. :raised_hands:

I was trying to test it with a multimeter. As I get it right, buttons are normally open. Is it necessary to use both outputs of the button?

3 Likes

Happy to help! :slight_smile:

You can see some pretty good pictures here: https://bitbucket.org/iesus_sonesson/d1-ajax-mqtt/src/master/

Use small cables and make sure to only solder onto the metal part of the button connection. Any solder touching the board will cause a problem.

You only need one cable per button connected to the inner upper button connection + one cable for ground connected to one of the outer button connections (I used the upper right one as in the link) + power connected to the side of the battery slot.

Ground cable to the GND pin and power to the 3V pin. I would urge you to use the same pins for the button cables as I did since some of the other unused pins can be used by the ESP8266 during the boot process. I think one or two more of the pins could be used but you need to check that if you need more pins. You don’t want it to press a button during boot.

4 Likes

Does anyone know the state when the smoke detector goes off? The alarm has triggered, is it the same for the smoke alarm? I want to turn all the lights in the house when smoke is detected.

I’ve tried to capture the most understandable events in the component, but you should get a log line when it encounters a unknown event type. If the event type is known the binary_sensor with device_class smoke would turn “on”.

Hmmm, so the only way to find out is to trigger the FireProtect device and see what the triggered event when smoke is detected is called? Maybe someone has tried and knows?

Currently it uses these events:

"GA": {"type": DEVICE_CLASS_SMOKE, "new_state": True},
"GH": {"type": DEVICE_CLASS_SMOKE, "new_state": False},

Which are Gas Alarm and Gas Alarm Restore in the SIA documentation.

Maybe we are talking about different things, I’m bad at explaining :slight_smile:

But I want to find the state in red below for when smoke is detected (screenshot is from when alarm is triggered), that’s what I’m trying to explain :slight_smile: