pysiaalarm icon indicating copy to clipboard operation
pysiaalarm copied to clipboard

Aritech - ATS1000A - test connection

Open RPJacobs opened this issue 1 year ago • 47 comments

We have a php sia pac script but trying to switch to pysiaalarm for HA intergration.

If I start run.py with the same port and key, my alarm generates the following error

Config:  {'host': '0.0.0.0', 'port': 12300, 'account_id': '123456', 'key': 'xxxxxxxxxxxxxx'}
DEBUG:pysiaalarm.sync.client:Starting SIA.
----------------------------------------
Exception happened during processing of request from ('x.x.x.x', 1203)
Traceback (most recent call last):
  File "/usr/lib/python3.8/socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.8/socketserver.py", line 747, in __init__
    self.handle()
  File "/home/jacobs/github/Kiwatt/pysiaalarm/tests/pysiaalarm/sync/handler.py", line 44, in handle
    raw = self.request.recv(1024)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------

I think this is due to the fact that the alarm first needs a (scrambled) 48 hex key send to it before it gives the sia message. After the alarm connects to the port my php script send the key to the alarm:

	function connect($socket){
		$client = new pacClient($this, $socket, $this->clientNr++);
		$this->clients[(int)$socket] = $client;
		$this->sockets[] = $socket;

		socket_getpeername($socket, $addr);
		$this->clients[(int)$socket]->ip = $addr;
		$this->log('#'.$client->id.': client connected '.$socket.' ('.$addr.')', 'light_green');
		$client->sendKey();
	}


	function sendKey(){
		$scramble = hex2bin('xxxxxxxxxxxxxxxxxxxxxxxxxxxx');
		$keyLength = strlen($scramble);

		$key = openssl_random_pseudo_bytes($keyLength);
		$this->key = $key;

		for($i = 0; $i < $keyLength; $i++){
			$key[$i] = $key[$i] ^ $scramble[$i];
		}
		$this->server->log($this->key, 'light_red');
		$this->send($key);
	}

	function send($message, $encrypt = false){
		if($this->server->debug){
			$this->server->log('#'.$this->id.": send\n".hexdump($message), 'red');
		}

		if($encrypt){
			$message = $this->encrypt($message);
		}
		socket_write($this->socket, $message, strlen($message));
	}
[Wed, 10 May 2023 15:03:59 +0200] #21: client connected Resource id #33 (x.x.x.x)
[Wed, 10 May 2023 15:03:59 +0200] #21: send
0000: 79 59 BB 2A 21 F0 20 58 C6 DE 85 2D 02 B8 94 CA  yY.*!..X...-....
0010: E8 6F FF 0B 16 9F 2F D4                          .o..../.

[Wed, 10 May 2023 15:03:59 +0200] #21: recv
0000: 53 52 30 30 30 31 4C 30 30 30 31 20 20 20 20 31  SR0001L0001....1
0010: 32 33 34 35 36 58 58 20 20 20 20 00 00 00 00 00  23456XX.........

[Wed, 10 May 2023 15:03:59 +0200] #21: send
0000: 41 43 4B 0D 00 00 00 00                          ACK.....

please advice

RPJacobs avatar May 10 '23 14:05 RPJacobs

I got the decoding working but it seem te be a different SIA protocol:

0101002F"SIA-DCS"0013R0001L0001[#123456|NNR003]

RPJacobs avatar May 11 '23 16:05 RPJacobs

ik neem aan dat je in jou ats een pac hebt geprogrammeerd met het ip adres en poort van system wat pysiaalarm draait?

bjornmorsman avatar May 15 '23 15:05 bjornmorsman

Dat klopt

RPJacobs avatar May 15 '23 15:05 RPJacobs

I would love to see the Aritech ATSx000 and ATSx500 series work with this integration.

I have total access to both systems of you guys need anything to test. Im a Installer. And we also install the alphatronics UNii systems, which work with DC09 protocol, havent tested that.

If i can be of any assistance... Let me know.

ThaSteef avatar Oct 24 '23 11:10 ThaSteef

NL: Zou mooi zijn als dit gaat werken!

Back to English: @RPJacobs; did you get anywhere with this? I have the same ATS1000A-IP-MM board. If you look at the UTCAR parser.go you can see some example regex patterns. If you need to test something, please let me know.

Can you share the php files you have?

A github user wichers also made an interesting pull request: https://github.com/eavanvalkenburg/pysiaalarm/pull/44 with support for our panels/alarms. @eavanvalkenburg is there anything we can do to get this installed for testing?

sanderpleijers avatar Jan 19 '24 13:01 sanderpleijers

Due to time constraints and too many projects I was putting this on hold, would be great if someone would pick this up. fyi. I did get my implementation working with my ATS after hacking it into HA.

wichers avatar Jan 30 '24 10:01 wichers

Hi @wichers; any instructions/hints on how to set it up in HA? I do have the custom_components\sia, but how to use your version of the pysiaalarm? Is that done via the manifest.json?

I can also test the functionality if i get it running...

sanderpleijers avatar Jan 30 '24 10:01 sanderpleijers

Yes, some tips for HA are welcome.

ThaSteef avatar Jan 30 '24 20:01 ThaSteef

Based on the work of @wichers I adapted pysiaalarm to enable communication with my ATS1000A. See https://github.com/voskuh/pysiaalarm

To test the changes I cloned the home assistant SIA integration to a new repo and custom component. The custom SIA component uses the adapted pysialarm repo and adds an option to select OH protocol in the config flow. Furthermore there are some minor tweaks in code consequences in the alarm panel. It's necessary to use a 6 digit account id or add preceding 0's if you have a shorter account id in the settings of your alarm system. It's still work in progress. https://github.com/voskuh/custom-sia

voskuh avatar Mar 10 '24 12:03 voskuh

Hi voskuh,

thanx for the great work! Can you tell us how we can install and use your custom component?

bjornmorsman avatar Mar 11 '24 16:03 bjornmorsman

Hi Bjorn,

You need to copy the custom-sia repository to your home assistant config folder (the same folder where the configuration.yaml file is located). Then, when you install the SIA integration in the integration section (Settings > Devices & Services) this custom component will override the build in integration.

voskuh avatar Mar 11 '24 21:03 voskuh

Hi Voskuh,

i am testing right now, when i install the custom sia as you said i get the following error. do you know what the problem is?

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 444, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/sia/init.py", line 14, in async_setup_entry hub.async_setup_hub() File "/config/custom_components/sia/hub.py", line 54, in async_setup_hub self.update_accounts() File "/config/custom_components/sia/hub.py", line 117, in update_accounts protocol=CommunicationsProtocol(self._protocol), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 744, in call return cls.new(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 1158, in new raise ve_exc ValueError: 'OH' is not a valid CommunicationsProtocol

bjornmorsman avatar Mar 12 '24 14:03 bjornmorsman

Nice work Voskuh,

I also tried to install, but with no luck. Same sort of errors occur i believe.

Running HA on a VM on my NAS. I did use the HACS way om importing a custom repository, not a manual copy of the files.

ThaSteef avatar Mar 12 '24 15:03 ThaSteef

There is a failure to load the adapted version of pysiaalarm. I made some changes in the manifest.json file. So I hope that it will install correctly. Please make sure to first remove the SIA integration in the integrations section in HA. Then update in HACS or re-install the custom component (remove files and copy the new files). Restart HA and try to set up the integration again. Hope that will fix the issue.

voskuh avatar Mar 12 '24 17:03 voskuh

Hi Voskuh,

Thnx for fixing the error, how did you program you pac in the ats8500 software? if i program it the way i am used to i get all sorts of errors. FTC, connection to pac failed. i think 1 at 10 messages gets to the custom component, al the others will fail. also a manual test call to the component will fail.

is that correct?

Thanx in advance

bjornmorsman avatar Mar 13 '24 15:03 bjornmorsman

I don't have the ats8500 software. So can't give you a fancy screenshot of my settings. I hope to get the software in the future because I want to control the alarm system with HA as well, but it needs reverse engineering. Ip address of home assistant port: an unused port (same port in PAC and integration settings), client number: random 6 digit number (must be same in PAC and integration settings). Protocol: oh-xsia mode: Primary PAC I don't have any errors on my GI and the connection to the custom component is stable since this morning (after some changes I made to the pysiaalarm repo). Before I had connection issues as well. Would you mind enable debug logging of the integration in home assistant and share the log.

voskuh avatar Mar 13 '24 18:03 voskuh

I can set you up with the latest software version, and firmware versions. Technical documents, some knowhow and 18 years of experience with this brand.

On topic, I think i got the HA part working, but its not receiving information at the moment. Could be on the ATS side of programming or something else, but i havent had time to check.

I use the ATS1500A-IP series (there is also a totally new model the ATS1700 on the market but i havent seen that yet.

Op wo 13 mrt 2024 19:06 schreef voskuh @.***>:

I don't have the ats8500 software. So can't give you a fancy screenshot of my settings. I hope to get the software in the future because I want to control the alarm system with HA as well, but it needs reverse engineering. Ip address of home assistant port: an unused port (same port in PAC and integration settings), client number: random 6 digit number (must be same in PAC and integration settings). Protocol: oh-xsia mode: Primary PAC I don't have any errors on my GI and the connection to the custom component is stable since this morning (after some changes I made to the pysiaalarm repo). Before I had connection issues as well. Would you mind enable debug logging of the integration in home assistant and share the log.

— Reply to this email directly, view it on GitHub https://github.com/eavanvalkenburg/pysiaalarm/issues/49#issuecomment-1995218656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVNVUNZIRAPV36AIFJARL6LYYCIR3AVCNFSM6AAAAAAX4ZF63KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVGIYTQNRVGY . You are receiving this because you commented.Message ID: @.***>

ThaSteef avatar Mar 13 '24 18:03 ThaSteef

@voskuh ; First of all thank you so much for your effort and time! Im waiting for this for so long now! :-D @ThaSteef ; I am interested in the latest software, mine is very old unfortunately. Can you share?

I use an ATS1000AIP. I have the custom_component setup like (screenshot has a 0 to much on the port btw) 2024-03-13 20_10_20-Window

And in ATS8500 downloader: 2024-03-13 20_11_40-Window

But nothing valid seems to come trough. Did i select the correct values in ATS8500? This is the home assistant log;

024-03-13 20:04:04.360 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'\n01010052"SIA-DCS"0002R0001L0001[#696900|NRP000*\'Paneel\'NM]EC0974F06D2C60A6|#696900\r\x00\x00\x00\x00'
2024-03-13 20:04:04.360 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010052"SIA-DCS"0002R0001L0001[#696900|NRP000*'Paneel'NM]EC0974F06D2C60A6|#696900
2024-03-13 20:04:04.361 WARNING (MainThread) [pysiaalarm.base_server] Last line could not be parsed succesfully. Error message: Parse content: no matches found in #696900|NRP000*'Paneel'NM]EC0974F06D2C60A6|#696900, using matcher: re.compile('\n[#]?(?P<account>[A-Fa-f0-9]{3,16})?\n[|]?\n[N]?\n(?:ti)?(?:(?<=ti)(?P<ti>\\d{2}:\\d{2}))?\\/?\n(?:id)?(?:(?<=id)(?P<id>\\d*))?\\/?\n(?:ri)?(?:(?<=ri)(?P<ri>\\d*))?\\/?\n(?P<code>[a-zA-Z]{2})?\n(?P<, re.VERBOSE). Line: 01010052"SIA-DCS"0002R0001L0001[#696900|NRP000*'Paneel'NM]EC0974F06D2C60A6|#696900
2024-03-13 20:04:04.362 DEBUG (MainThread) [pysiaalarm.aio.server] Response send to alarm system: b'\n4A080025"NAK"0000L0R0A0[]_19:04:04,03-13-2024\r'

sanderpleijers avatar Mar 13 '24 19:03 sanderpleijers

Great to see that at least some messages came through. Although the custom component can't read them properly. Seeing the incoming lines is very helpful. There are two types of incoming lines. A heartbeat (frequency based on heartbeat time) and other states. Incoming lines for my system: Heartbeat: SR0001L0001 072538XX Other state: 01010039"SIA-DCS"0002R0001L0001[#072538|Nri01/CL003*''NM]

So if your system is sending messages in an other format, it's likely that they will not be recognized and it will fail. So we will need to add new Regex patterns for these line formats to fix it.

@ThaSteef If it's possible to get the software I would be delighted. Can you provide me some HA debug logs as well? @sanderpleijers When I compare your settings with mine, the only difference is Protocol OH version mine is OH V 1.9.3. Maybe that explains the difference in incoming line format?

voskuh avatar Mar 13 '24 21:03 voskuh

Nice to see someone picking this up. It could be helpful to have a look at OH Network Receiver ver. 3.2.4.4 User Manual, there are some SIA specific details about SIA message formatting. I think it would be even more helpful to get that software, so you don't need to do the reverse engineering of the messages from scratch.

wichers avatar Mar 13 '24 21:03 wichers

btw. It doesn't take much to get most of the software, I registered myself at https://secure.carriercms.com/ a long time ago. There you can find the ATS8500 software and firmware for your ATS. The OH Net Rec - Software page is restricted though. There should be a 4 user (limited) demo version of the OH NetRec software, somewhere..

wichers avatar Mar 13 '24 22:03 wichers

hi all, love the interaction here, unfortunately I have sold the house with my alarm system, so no longer have a SIA enabled device to test against, if someone wants to be co-owner of this repo so that you can get these developments tested, integrated and release let me know!

eavanvalkenburg avatar Mar 14 '24 08:03 eavanvalkenburg

@sanderpleijers When I compare your settings with mine, the only difference is Protocol OH version mine is OH V 1.9.3. Maybe that explains the difference in incoming line format?

I tried setting it to OH V 1.9.3 but no change. Messages are coming in so it seems there is data only why is it different? Maybe different in room/panel setup? @voskuh can you check if every setting is exactly the same?

The data is looking good but sensors are not updated:

2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010040"SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM]
2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.event] Content matches: {'account': '696900', 'ti': None, 'id': None, 'ri': None, 'code': 'UA', 'message': "010*'HA Woonkamer'NM", 'xdata': None, 'timestamp': ''}
2024-03-14 11:37:06.594 DEBUG (MainThread) [pysiaalarm.aio.server] Response send to alarm system: b'\n29C5001C"ACK"0045R0001L0001#696900[]\r'
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code UA for port 12300 and account 696900
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:31.296 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'SR0001L0001 696900XX \x00\x00\x00\x00\x00'

sanderpleijers avatar Mar 14 '24 13:03 sanderpleijers

@voskuh, Here is a simplified server implementation that is working well for me: https://gist.github.com/wichers/31a7e2ff1e9a1bb36b8412642766cd69

I still need to have a look at the types of response messages though.

wichers avatar Mar 14 '24 14:03 wichers

ATS8500 software and the update for the latest version are here: (for a few days) https://wetransfer.com/downloads/2e00226452853fc69cc95346aeb3d75420240314192732/07a8baa1aa807bc41ea75fe0f23cc3a520240314192752/7e4a24?trk=TRN_TDL_01&utm_campaign=TRN_TDL_01&utm_medium=email&utm_source=sendgrid

There is also the latest version for a ATSx500A-ip alarm panel. DONT USE IT ON A ATSx000a-IP PANEL!! IF YOU HAVE A OLD FIRMWARE VERSION, PERHAPSE YOU MUST UPDATE THE BOOTLOADER FIRST. if that is the case, let me know.

ThaSteef avatar Mar 14 '24 19:03 ThaSteef

@sanderpleijers When I compare your settings with mine, the only difference is Protocol OH version mine is OH V 1.9.3. Maybe that explains the difference in incoming line format?

I tried setting it to OH V 1.9.3 but no change. Messages are coming in so it seems there is data only why is it different? Maybe different in room/panel setup? @voskuh can you check if every setting is exactly the same?

The data is looking good but sensors are not updated:

2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010040"SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM]
2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.event] Content matches: {'account': '696900', 'ti': None, 'id': None, 'ri': None, 'code': 'UA', 'message': "010*'HA Woonkamer'NM", 'xdata': None, 'timestamp': ''}
2024-03-14 11:37:06.594 DEBUG (MainThread) [pysiaalarm.aio.server] Response send to alarm system: b'\n29C5001C"ACK"0045R0001L0001#696900[]\r'
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code UA for port 12300 and account 696900
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:31.296 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'SR0001L0001 696900XX \x00\x00\x00\x00\x00'

The new versions of OH should bring extra features or new sensors. But the basics stay the same. If extra functionalities or new type of sensors come along they are added to the protocol. Current version is V4.0

ThaSteef avatar Mar 14 '24 19:03 ThaSteef

Thanks for all the helpful comments and the download link. Will try to install and connect to my alarm system asap.

@sanderpleijers When I compare your settings with mine, the only difference is Protocol OH version mine is OH V 1.9.3. Maybe that explains the difference in incoming line format?

I tried setting it to OH V 1.9.3 but no change. Messages are coming in so it seems there is data only why is it different? Maybe different in room/panel setup? @voskuh can you check if every setting is exactly the same?

The data is looking good but sensors are not updated:

2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010040"SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM]
2024-03-14 11:37:06.588 DEBUG (MainThread) [pysiaalarm.event] Content matches: {'account': '696900', 'ti': None, 'id': None, 'ri': None, 'code': 'UA', 'message': "010*'HA Woonkamer'NM", 'xdata': None, 'timestamp': ''}
2024-03-14 11:37:06.594 DEBUG (MainThread) [pysiaalarm.aio.server] Response send to alarm system: b'\n29C5001C"ACK"0045R0001L0001#696900[]\r'
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code UA for port 12300 and account 696900
2024-03-14 11:37:06.595 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:06.596 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #696900|NUA010*'HA Woonkamer'NM], Zone (ri): None, Code: UA, Message: 010*'HA Woonkamer'NM, Account: 696900, Receiver: R0001, Line: L0001, Timestamp: None, Length: 0040, Sequence: 0045, CRC: 0101, Calc CRC: 00DA, Encrypted Content: None, Full Message: "SIA-DCS"0045R0001L0001[#696900|NUA010*'HA Woonkamer'NM].
2024-03-14 11:37:31.296 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'SR0001L0001 696900XX \x00\x00\x00\x00\x00'

I can see in your logs that it's working correctly and the event is send to home assistant. But not all SIA codes will change the status of the alarm in HA. See https://github.com/voskuh/custom-sia/blob/master/custom_components/sia/alarm_control_panel.py (line 41 and further) for all SIA codes that lead to a change. It's possible to use other codes in automations. For example (in event_type 12300 is my port number and 072538 client ID):

id: '1710365833280'
alias: Alarm events
description: ''
trigger:
  - platform: event
    event_type: sia_event_12300_072538
condition:
  - condition: not
    conditions:
      - condition: template
        value_template: '{{trigger.event.data.code == "RP"}}'
action:
  - service: notify.signal_messages
    metadata: {}
    data:
      message: 'Alarm event ontvangen: {{trigger.event.data}}'
mode: single  

So I assume the V1.9.3. format is parsed correctly, but there can be some issues with receiving all events. I hope to update the repo tomorrow to support protocol OH v3 and fix an issue where not all messages come through.

voskuh avatar Mar 14 '24 21:03 voskuh

@sanderpleijers when i connect my system (ats3500) to the integration i get heartbeat errors and in the end an FTC. Do you see this behavior to?

2024-03-15 04:34:23.987 DEBUG (MainThread) [pysiaalarm.aio.client] Starting OH-SIA.
2024-03-15 04:34:38.350 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'\n0101003B"SIA-DCS"0003R0001L0001[#001991|NRS000*\'Morsman\'NM]\r\x00\x00\x00'
2024-03-15 04:34:38.350 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 0101003B"SIA-DCS"0003R0001L0001[#001991|NRS000*'Morsman'NM]
2024-03-15 04:34:38.350 DEBUG (MainThread) [pysiaalarm.event] Content matches: {'account': '001991', 'ti': None, 'id': None, 'ri': None, 'code': 'RS', 'message': "000*'Morsman'NM", 'xdata': None, 'timestamp': ''}
2024-03-15 04:34:38.355 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code RS for port 12400 and account 001991
2024-03-15 04:34:38.355 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRS000*'Morsman'NM], Zone (ri): None, Code: RS, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0003, CRC: 0101, Calc CRC: BEEB, Encrypted Content: None, Full Message: "SIA-DCS"0003R0001L0001[#001991|NRS000*'Morsman'NM].
2024-03-15 04:34:38.355 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRS000*'Morsman'NM], Zone (ri): None, Code: RS, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0003, CRC: 0101, Calc CRC: BEEB, Encrypted Content: None, Full Message: "SIA-DCS"0003R0001L0001[#001991|NRS000*'Morsman'NM].
2024-03-15 04:34:38.355 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRS000*'Morsman'NM], Zone (ri): None, Code: RS, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0003, CRC: 0101, Calc CRC: BEEB, Encrypted Content: None, Full Message: "SIA-DCS"0003R0001L0001[#001991|NRS000*'Morsman'NM].
2024-03-15 04:34:44.098 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'SR0001L0001 001991XX \x00\x00\x00\x00\x00'
2024-03-15 04:34:44.098 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: SR0001L0001 001991XX 
2024-03-15 04:34:44.101 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code RP for port 12400 and account 001991
2024-03-15 04:34:44.101 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: None, Zone (ri): None, Code: RP, Message: , Account: 001991, Receiver: 0001, Line: 0001, Timestamp: None, Length: 32, Sequence: None, CRC: , Calc CRC: None, Encrypted Content: None, Full Message: SR0001L0001 001991XX .
2024-03-15 04:34:44.102 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: None, Zone (ri): None, Code: RP, Message: , Account: 001991, Receiver: 0001, Line: 0001, Timestamp: None, Length: 32, Sequence: None, CRC: , Calc CRC: None, Encrypted Content: None, Full Message: SR0001L0001 001991XX .
2024-03-15 04:34:44.102 DEBUG (MainThread) [custom_components.sia.binary_sensor] New state will be True
2024-03-15 04:34:44.102 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: None, Zone (ri): None, Code: RP, Message: , Account: 001991, Receiver: 0001, Line: 0001, Timestamp: None, Length: 32, Sequence: None, CRC: , Calc CRC: None, Encrypted Content: None, Full Message: SR0001L0001 001991XX .
2024-03-15 04:35:15.606 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'\n0101003B"SIA-DCS"0004R0001L0001[#001991|NRB000*\'Morsman\'NM]\r\x00\x00\x00'
2024-03-15 04:35:15.606 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 0101003B"SIA-DCS"0004R0001L0001[#001991|NRB000*'Morsman'NM]
2024-03-15 04:35:15.607 DEBUG (MainThread) [pysiaalarm.event] Content matches: {'account': '001991', 'ti': None, 'id': None, 'ri': None, 'code': 'RB', 'message': "000*'Morsman'NM", 'xdata': None, 'timestamp': ''}
2024-03-15 04:35:15.611 DEBUG (MainThread) [custom_components.sia.hub] Adding event to dispatch and bus for code RB for port 12400 and account 001991
2024-03-15 04:35:15.612 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRB000*'Morsman'NM], Zone (ri): None, Code: RB, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0004, CRC: 0101, Calc CRC: 6F8A, Encrypted Content: None, Full Message: "SIA-DCS"0004R0001L0001[#001991|NRB000*'Morsman'NM].
2024-03-15 04:35:15.612 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRB000*'Morsman'NM], Zone (ri): None, Code: RB, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0004, CRC: 0101, Calc CRC: 6F8A, Encrypted Content: None, Full Message: "SIA-DCS"0004R0001L0001[#001991|NRB000*'Morsman'NM].
2024-03-15 04:35:15.612 DEBUG (MainThread) [custom_components.sia.sia_entity_base] Received event: Content: #001991|NRB000*'Morsman'NM], Zone (ri): None, Code: RB, Message: 000*'Morsman'NM, Account: 001991, Receiver: R0001, Line: L0001, Timestamp: None, Length: 003B, Sequence: 0004, CRC: 0101, Calc CRC: 6F8A, Encrypted Content: None, Full Message: "SIA-DCS"0004R0001L0001[#001991|NRB000*'Morsman'NM].
2024-03-15 04:35:28.010 DEBUG (MainThread) [pysiaalarm.aio.client] Stopping OH-SIA.
2024-03-15 04:35:28.011 DEBUG (MainThread) [pysiaalarm.aio.client] Starting OH-SIA.
2024-03-15 04:36:37.294 DEBUG (MainThread) [pysiaalarm.aio.client] Stopping OH-SIA.
2024-03-15 04:36:37.294 DEBUG (MainThread) [pysiaalarm.aio.client] Starting OH-SIA.
2024-03-15 04:37:39.136 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'\n01010053"SIA-DCS"0001R0001L0001[#001991|NRS000*\'Morsman\'NM]F18CF5754F6B9D9E|#001991\r\x00\x00\x00'
2024-03-15 04:37:39.136 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010053"SIA-DCS"0001R0001L0001[#001991|NRS000*'Morsman'NM]F18CF5754F6B9D9E|#001991
2024-03-15 04:37:39.136 WARNING (MainThread) [pysiaalarm.base_server] Last line could not be parsed succesfully. Error message: Parse content: no matches found in #001991|NRS000*'Morsman'NM]F18CF5754F6B9D9E|#001991, using matcher: re.compile('\n[#]?(?P<account>[A-Fa-f0-9]{3,16})?\n[|]?\n[N]?\n(?:ti)?(?:(?<=ti)(?P<ti>\\d{2}:\\d{2}))?\\/?\n(?:id)?(?:(?<=id)(?P<id>\\d*))?\\/?\n(?:ri)?(?:(?<=ri)(?P<ri>\\d*))?\\/?\n(?P<code>[a-zA-Z]{2})?\n(?P<, re.VERBOSE). Line: 01010053"SIA-DCS"0001R0001L0001[#001991|NRS000*'Morsman'NM]F18CF5754F6B9D9E|#001991
2024-03-15 04:37:39.148 DEBUG (MainThread) [pysiaalarm.utils.osborne_hoffman] OH-XSIA OH data b'\n01010053"SIA-DCS"0002R0001L0001[#001991|NRB000*\'Morsman\'NM]F18CF5754F6B9D9E|#001991\r\x00\x00\x00'
2024-03-15 04:37:39.148 DEBUG (MainThread) [pysiaalarm.base_server] Incoming line: 01010053"SIA-DCS"0002R0001L0001[#001991|NRB000*'Morsman'NM]F18CF5754F6B9D9E|#001991
2024-03-15 04:37:39.149 WARNING (MainThread) [pysiaalarm.base_server] Last line could not be parsed succesfully. Error message: Parse content: no matches found in #001991|NRB000*'Morsman'NM]F18CF5754F6B9D9E|#001991, using matcher: re.compile('\n[#]?(?P<account>[A-Fa-f0-9]{3,16})?\n[|]?\n[N]?\n(?:ti)?(?:(?<=ti)(?P<ti>\\d{2}:\\d{2}))?\\/?\n(?:id)?(?:(?<=id)(?P<id>\\d*))?\\/?\n(?:ri)?(?:(?<=ri)(?P<ri>\\d*))?\\/?\n(?P<code>[a-zA-Z]{2})?\n(?P<, re.VERBOSE). Line: 01010053"SIA-DCS"0002R0001L0001[#001991|NRB000*'Morsman'NM]F18CF5754F6B9D9E|#001991

bjornmorsman avatar Mar 15 '24 03:03 bjornmorsman

Did an update on the custom component and pysiaalarm. Changes are:

  • add OH protocol message content parser
  • change response after heartbeat. I hope to fix most of the communication errors
  • making debug log for communication more verbose to make debugging easier
  • fix delay in receiving messages
  • fix showing wrong state in alarm panel in HA after burglary restoral

Please update or re-install. Make sure to reboot. I hope it will fix most of the errors. Let me know and provide the output of the debug log if you experience issues.

voskuh avatar Mar 15 '24 11:03 voskuh

fyi updated my POC. I got my hands on both the V3 and V4 of OH-Netrec. My gist implementation https://gist.github.com/wichers/31a7e2ff1e9a1bb36b8412642766cd69 (mostly regexes and a little logic) is based on the V3 version and seems to be working with SIA/XSIA and CID.

wichers avatar Mar 15 '24 12:03 wichers