Jablotron JA-80 series and JA-100 series alarm integration

Your script is succesfully sending multiple startup messages:

2019-05-03 19:34:43 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 19:34:44 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Sending startup message

But it seems like it doesn’t always receive a response when you send a message.
I’ve already experienced something like this before: when I send a startup message in about every 10 seconds, I get a response guaranteed. But when there’s like 5 seconds between them, there’s no response. Or well, not always. For example, when I send a message every 1 second, I could get a response after 7 or 8 messages or so.

How many settings I have on my alarm? For now I have just 1 zone if that’s what you mean. I do have multiple sensors, but no PGM’s programmed so far. I’ve used J-Link before online, but since I’m running out of GPRS credits, I need to wire it manually. I’ll see if I can make a direct connection from my pc soon. Thanks for your help so far! :slight_smile: I’ll keep you posted.

Yes I have, but it doesn’t work. I see the actions (and the code) in the log, but it seems like it’s not arming or disarming anything yet.

I’ll have a look at improving the send startup code such that it retries if message don’t come back, but that will be a bit of a harder change, so probably won’t be immediate. If you could try the J-Link meanwhile, that would be appreciated. Do you have access to a Windows machine to run it?

Ok, I’ll appreciate! Yeah, running J-link now as an administrator (not as a Service aka root user :wink: ). In the meanwhile I’m running HID Trace in the background, but I’m not sure if this tool will provide me/you with the data we’re looking for. Is there something specific I need to look out for? I mean, would you like me to sniff all the messages when pressing all buttons? (0-9, * and #) so you can create all bindings?

Using the tool I mentioned, you could trace all messages down a specific HID, so there will be no data flowing down the HID to the Jablotron until you do something in the virtual keypad. Yes, if you could press all buttons in turn that would be great. My panel has specific setting buttons too, but they emulate multi key presses. So for example ABC button means set-all zones and is just the same as pressing *, then 1

New version posted, it has a watcher thread that checks data is flowing every 10 seconds and if not sends another startup message

I’m tracing all messages right now, while opening a virtual keypad in J-link.
It seems like I’m receiving data as a continuous stream. Sometimes with tens of lines within a second, way more than I was sniffing with cat /dev/hidraw0 on a unix system.

Thanks! Here’s my HA log. We can see clearly 2 things:

  1. Your interval of 10 seconds is kinda working, but every 20 seconds. I’m not sure if we need to pay more attention at this, since the HID sniffer on Windows is showing data more frequently. I’m not sure why debian (cat /dev/hidraw0) is not showing data more frequently like the HID sniffer.
  2. calling services from within HA, like ‘alarm_arm_home’ for example, is being logged but not sending the right binaries maybe. I do recognize my alarm code, which I replaced by 1, 2, 3, 4.

Replaced alarm code:
1 (\x81),
2 (\x82),
3 (\x83),
4 (\x84)

2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 3, message: b'\x00\x02\x01\x81',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 4, message: b'\x00\x02\x01\x82',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 5, message: b'\x00\x02\x01\x83',
2019-05-03 21:30:58 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 6, message: b'\x00\x02\x01\x84',

Full log:

2019-05-03 21:30:15 WARNING (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data has not been received for 10 seconds, retry startup message,
2019-05-03 21:30:15 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:16 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:16 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data is flowing, wait 10 seconds before checking again,
2019-05-03 21:30:16 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:16 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 1, message: b'\x00\x02\x01\x8f',
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 2, message: b'\x00\x02\x01\x81',
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 3, message: b'\x00\x02\x01\x81',
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 4, message: b'\x00\x02\x01\x82',
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 5, message: b'\x00\x02\x01\x83',
2019-05-03 21:30:16 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 6, message: b'\x00\x02\x01\x84',
2019-05-03 21:30:36 WARNING (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data has not been received for 10 seconds, retry startup message,
2019-05-03 21:30:36 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:37 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:37 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data is flowing, wait 10 seconds before checking again,
2019-05-03 21:30:37 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:37 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:56 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1885963280] Received {'type': 'call_service', 'domain': 'alarm_control_panel', 'service': 'alarm_arm_home', 'service_data': {'entity_id': 'alarm_control_panel.jablotron_alarm', 'code': 1234}, 'id': 24},
2019-05-03 21:30:57 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=alarm_control_panel, service=alarm_arm_home, service_data=entity_id=alarm_control_panel.jablotron_alarm, code=1234>,
2019-05-03 21:30:57 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1885904208] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'alarm_control_panel', 'service': 'alarm_arm_home', 'service_data': {'entity_id': 'alarm_control_panel.jablotron_alarm', 'code': 1234}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 5, 3, 19, 30, 57, 2670, tzinfo=<UTC>), 'context': {'id': '57fe96f940b84175a8a25de68ccbec3e', 'parent_id': None, 'user_id': '3cb58b4fde11478e9cb2c903819a1aaf'}}},
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending *2,
2019-05-03 21:30:57 WARNING (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data has not been received for 10 seconds, retry startup message,
2019-05-03 21:30:57 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:57 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:57 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Sending startup message,
2019-05-03 21:30:57 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data is flowing, wait 10 seconds before checking again,
2019-05-03 21:30:57 DEBUG (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message,
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 1, message: b'\x00\x02\x01\x8f',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 2, message: b'\x00\x02\x01\x82',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 3, message: b'\x00\x02\x01\x81',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 4, message: b'\x00\x02\x01\x82',
2019-05-03 21:30:57 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 5, message: b'\x00\x02\x01\x83',
2019-05-03 21:30:58 DEBUG (MainThread) [custom_components.jablotron.alarm_control_panel] sending packet 6, message: b'\x00\x02\x01\x84',

Great you are seeing data.

Can you filter it so you can see what is being sent from PC to Control Panel (on my standard view of Device Monitoring Studio, there is a separate pane for the read and the write data? (I’m not sure how I set that up or if it was default, we just need the write data.) That should be the info I need to create the correct codes to set/unset the system. When I see that trace, I’m likely to be able to improve the start-up message logic too… as you observe, its not ideal at the moment!

Also, please choose the “Raw data view” when you set up the trace from Device Monitoring Studio. If the steps for this trace are not obvious, just say and I’ll give some more detailed instructions.

I suspect you are now seeing a constant stream as J-Link is sending messages to the Control Panel while you are running it and therefore its like the ‘startup message’ is running continuously.

Hi,

I am away for the weekend so will test your updated code next week.
I am not sure what is the model of control panel but got some pictures

Bear with me. I’m short on resources and preparing a Windows machine with Device Monitoring Studio. I’ll be back to you soon!

Ah, sorry I thought you had it setup, my mistake. Whenever you have a chance.

Ok Matt, did a scan and I’ve send you a PM with a link to the sniffing results. I’ve opened up the virtual keypad in J-link and made a scan while clicking the keypad buttons in order 1-9, 0, *, #. I hope you’re able to discipher the right codes, at least if you want to. Thanks in advance!

OK,
I deployed your new file with following logs:

12 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.jablotron
2019-05-08 14:26:12 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.manual
12 DEBUG (ThreadPoolExecutor-0_2) [custom_components.jablotron.alarm_control_panel] Sending startup message
12 DEBUG (ThreadPoolExecutor-0_2) [custom_components.jablotron.alarm_control_panel] Successfully sent startup message
12 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=alarm_control_panel.jablotron_alarm, old_state=None, new_state=<state alarm_control_panel.jablotron_a2019-05-08 14:26:13 DEBUG (ThreadPoolExecutor-0_1) [custom_components.jablotron.alarm_control_panel] Data is flowing, wait 10 seconds before checking again
2019-05-08 14:26:13 ERROR (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Unrecognised data stream, device type likely not a JA-82 or JA101 control panel. Please raise an issue at Issues · mattsaxon/HASS-Jablotron80 · GitHub with this packet info [b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’]
2019-05-08 14:26:14 ERROR (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Unrecognised data stream, device type likely not a JA-82 or JA101 control panel. Please raise an issue at Issues · mattsaxon/HASS-Jablotron80 · GitHub with this packet info [b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’]
2019-05-08 14:26:15 ERROR (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Unrecognised data stream, device type likely not a JA-82 or JA101 control panel. Please raise an issue at Issues · mattsaxon/HASS-Jablotron80 · GitHub with this packet info [b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’]
2019-05-08 14:26:16 ERROR (ThreadPoolExecutor-0_0) [custom_components.jablotron.alarm_control_panel] Unrecognised data stream, device type likely not a JA-82 or JA101 control panel. Please raise an issue at Issues · mattsaxon/HASS-Jablotron80 · GitHub with this packet info [b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’]

So, I have checked exact model of main board and its actually not JA-82 but JA-82C (1)
Any ideas?

So you are actually getting a huge stream of zeros in the data back from the device.

Can I ask you to run the following in your RPi

hexdump /dev/ttyUSB0

you will hopefully see data coming back that is non zero. If there is no data run the following and try again

echo -ne “\x00\x00\x01\x01” > /dev/ttyUSB0

If neither of those work, were going to need to trace what happens when you use the OLink software connected to the RPi, can you get a Windows machine connected to it?

My alarm is a JA-82K, so suspect it is the different serial cable that is causing the difference.

@mattsaxon I’ve changed your alarm_control_panel.py script and added support for JA-100 series. I’m able to arm the system home and away. Where do you want me to put it? If you allow me to create/edit a branch, I’d be happy to share my changes.

@plaksnor & @mattsaxon: Good job! I would be very happy to have the updated script. I am currently controlling my Jablotron JA-100 system in HASS trough Homebridge (https://www.npmjs.com/package/homebridge-jablotron). This is far from stable. I expect it has to do with the fact that my JA-100 system is connected via GSM connection to the Jablotron cloud (i have poor 3G/4G network reception in my house). I expect that controlling it trough a serial cable will be less error-prone and way more responsive!

@plaksnor: What cable did you use to control your JA-100 series? An official Jablotron cable, or one from Aliexpress? :slight_smile:

hi @Marcel1, I just made a fork of the HASS project of @mattsaxon in order to publish the changes:
https://github.com/plaksnor/HASS-Jablotron80/tree/dev. It works for me using a default printer-USB cable of about 10 years old or so. Just an old one like this will do, probably also for you.

The code is still a concept version though. I’m able to arm and disarm my JA-100KL over USB from within HA, but it will take a while in order to see things working. I think we should be able to work on this, but I’m running short on Python skills…

Running for a couple of hours now. Tested with both arming it from the Jablotron app as wel as HA.