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!
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
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.
I will be very thankful for sharing photos of your Ajax SpaceControl soldered to Wemos.
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?
Happy to help!
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.
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
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
That is the alarm_control_panel, the smoke (FireProtect) and water leak (LeaksProtect) sensors will show up as Binary_sensors in HA with device classes Smoke and Moisture, see docs for those here: https://www.home-assistant.io/integrations/binary_sensor/
I’m facing the same issue.
Run two fresh installation of HA 0.108.9, one on macos and another on synology/docker. Sia 0.2.4 was installed through hacs. The Ajax hub is on Wifi, ethernet port is being used because of lockdown…
Both setups behave the same : hub status and mode change get updated for one minute or two and then the alarm remains in an unavailable state.
The ping frequency set to ‘1’ in Ajax and to ‘1’ in sia (tried setting to ‘60’ in sia in vain).
Looking at the logs, i’ve seen some CRC mismatch events after restarting HA, could the sia server crash after erroneous packets have been received ?
Tried to wireshark, but can’t get the packets to the sia server.
CRC mismatch is most likely due to encryption key not being correct, not sure what happens if that happens with each message. In general the component creates a server that runs on the specified port, the Alarm system needs to be able to reach that server and port (with ip and port specified in your alarm). But if you do get the CRC mismatch messages it means it is able to read the message coming in, but the CRC in the message does not equal the CRC that is calculated based on the content. The ping frequency basically means that the alarm system sends a message every X minutes to say “I"m still alive” and other than that it is silent unless something happens with the systems (alarms armed, disarmed, changes to config and the heartbeat), usually for debugging I set both to 1 minutes so you get at least those messages every minute.
Oh and the unavailable happens if the component does not get a new message (of any kind) from your alarm within the ping interval (in minutes) + a margin, so if you have your component setup with 1 minute ping interval, but your alarm is set to 10 minutes, then after 1 minute your alarm goes into state unavailable so that you can do automations based on your alarm being offline. So keep those settings in sync between your alarm and HA.
Thank for your explanations, I’ve synced back ping intervals on both systems, encryption is not used.
I have two issues,
- ping are not sent/received/processed after 2 minutes : the lovelace card says “last heartbeat : XX ago.” XX being as of now 4 minutes.
- When changing the ajax hub from armed/disarmed mode manually several times, the lovelace card is correctly updated until it freezes : the state either goes unavailable or remains in the last known state.
After restarting HA, I see CRC mismatch events, I will try switching to wired, that could eliminate wifi connections issues.
Here is one CRC mismatch event from HA logs :
2020-04-29 17:49:50 DEBUG (Thread-2) [custom_components.sia] TCP: Handle Line: event: CRC: 19A5, Calc CRC: 8FE9, Full Message: "SIA-DCS"1384L0#AAA[, Message type: SIA-DCS, Sequence: 1384, Receiver: , Prefix: L0, Account: AAA, Encrypted Content: , Content: , Zone: , Code: , Message: , Timestamp: , Code: , Type: , Description: , Concerns:
2020-04-29 17:49:50 ERROR (Thread-2) [custom_components.sia] TCP: Handle Line: CRC mismatch, received: 19A5, calculated: 8FE9
hmm, I’ve not used the unencrypted version a lot myself, so might be a bug in the parsing of the message when not encrypted, could you turn on encryption to verify? just needs 16 HEX characters.
Turned encryption on and wired Ajax hub.
When setting the Ajax hub to disarmed, ping are processed properly every minute and events show instantly in HA.
When the hub is in armed mode, looks like a 1 minute ‘stall’ something happens. After that, processing goes back to normal.
As I don’t which of these two changes (or both) made the setup work, my advice is to :
- turn encryption on
- try using the hub wired instead of wifi.
Eduard, thanks for your support
Xavier.
thanks for checking, I think it is likely due to encryption so will fix that, I’m currently working through making it an official component, so might not show up in this version.
Hello! Wondering if anyone has Ajax running with the uartBridge at the moment?
I would like to know if it is possible to find out the status of the sensors by this method.