vanackej / risco-mqtt-local

Provide Risco alarm system integration to Home assistant using local TCP communication (no cloud required) and MQTT
MIT License
24 stars 11 forks source link

Connection to panel works only when bad password provided #20

Closed kkmaslowski closed 2 years ago

kkmaslowski commented 2 years ago

Describe the bug Connection to panel works only when bad password provided

Configuration

Logs Correct password:

Loading config from: /data/config.json
2/20/2022, 11:12:25 AM [info] autoConnect enabled, starting communication
2/20/2022, 11:12:25 AM [info] Connecting to mqtt server: mqtt://192.168.10.100:1883
2/20/2022, 11:12:26 AM [info] Connected on mqtt server: mqtt://192.168.10.100:1883
2/20/2022, 11:12:26 AM [info] Panel is not connected, waiting
2/20/2022, 11:12:34 AM [warn] Command[1] 'RMT=5678' Timeout
2/20/2022, 11:12:34 AM [warn] Bad Panel Id: 1. Trying to find the right one
2/20/2022, 11:12:37 AM [error] No remaining possible Panel Id, abandon
2/20/2022, 11:12:37 AM [error] Unable to connect to the control panel.
2/20/2022, 11:12:38 AM [warn] Command[51] Wrong CRC value for the response.
2/20/2022, 11:12:40 AM [warn] Command[51] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:12:42 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:12:42 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:12:43 AM [warn] Command[50] Wrong CRC value for the response.
2/20/2022, 11:12:46 AM [warn] Command[50] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:12:47 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:12:48 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:12:49 AM [warn] Command[50] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:12:52 AM [warn] Command[53] Wrong CRC value for the response.
2/20/2022, 11:12:52 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:12:53 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:12:55 AM [warn] Command[53] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:12:57 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:12:58 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:12:58 AM [warn] Command[53] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:13:01 AM [warn] Command[52] Wrong CRC value for the response.
2/20/2022, 11:13:02 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:13:03 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:13:04 AM [warn] Command[52] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:13:07 AM [warn] Command[52] receivedId is the same as lastReceivedId, ignoring this panel message
2/20/2022, 11:13:07 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:13:08 AM [warn] Command[NaN] Wrong CRC value for the response.
2/20/2022, 11:13:10 AM [error] Command[5] Too many bad CRC value.
2/20/2022, 11:13:12 AM [warn] Command[4] 'DCN' Timeout
2/20/2022, 11:13:13 AM [error] Command[NaN] Too many bad CRC value.
2/20/2022, 11:13:13 AM [warn] Command[5] receivedId is the same as lastReceivedId, ignoring this panel message

Wrong password:

Loading config from: /data/config.json
2/20/2022, 11:13:31 AM [info] autoConnect enabled, starting communication
2/20/2022, 11:13:31 AM [info] Connecting to mqtt server: mqtt://192.168.10.100:1883
2/20/2022, 11:13:31 AM [info] Connected on mqtt server: mqtt://192.168.10.100:1883
2/20/2022, 11:13:31 AM [info] Panel is not connected, waiting
2/20/2022, 11:13:36 AM [warn] Command[1] 'RMT=56788' Timeout
2/20/2022, 11:13:37 AM [warn] Command[1] Receipt of an error code: Invalid Value
2/20/2022, 11:13:37 AM [warn] Provided password is incorrect
2/20/2022, 11:13:37 AM [info] Trying to guess password (brut force)
2/20/2022, 11:13:37 AM [info] Trying passwords from 0000 to 9999...
2/20/2022, 11:13:37 AM [info] 0000 to 0099...
2/20/2022, 11:13:42 AM [info] 0100 to 0199...
2/20/2022, 11:13:47 AM [info] 0200 to 0299...
2/20/2022, 11:13:53 AM [info] 0300 to 0399...
2/20/2022, 11:13:58 AM [info] 0400 to 0499...
2/20/2022, 11:14:03 AM [info] 0500 to 0599...
2/20/2022, 11:14:08 AM [info] 0600 to 0699...
2/20/2022, 11:14:14 AM [info] 0700 to 0799...
2/20/2022, 11:14:19 AM [info] 0800 to 0899...
2/20/2022, 11:14:24 AM [info] 0900 to 0999...
...
2/20/2022, 11:19:22 AM [info] Discovered Access Code : 5678
2/20/2022, 11:19:23 AM [info] Panel info: LightSys/RP432, FW 2.59
2/20/2022, 11:19:23 AM [info] Panel options: 4 parts, 32 zones, 14 outputs, Pir Cam support: false
2/20/2022, 11:19:26 AM [warn] Command[16] Receipt of an error code: Device Doesn't Exists
2/20/2022, 11:19:26 AM [info] Output does not exists, stopping outputs discovery
2/20/2022, 11:19:26 AM [info] Panel is ready, subscribing to panel partitions and zones events
2/20/2022, 11:19:26 AM [info] Panel and MQTT communications are ready
2/20/2022, 11:19:26 AM [info] Publishing Home Assistant discovery info
vanackej commented 2 years ago

I need logs in debug mode to be able to analyze the issue. Only for correct code situation. Thx

vanackej commented 2 years ago

Can you try again with 0.3.6 please ?

kkmaslowski commented 2 years ago

0.3.6:

Loading config from: /data/config.json
2/21/2022, 10:54:04 AM [info] autoConnect enabled, starting communication
2/21/2022, 10:54:04 AM [info] Connecting to mqtt server: mqtt://192.168.10.100:1883
2/21/2022, 10:54:04 AM [info] Connected on mqtt server: mqtt://192.168.10.100:1883
2/21/2022, 10:54:04 AM [info] Panel is not connected, waiting
2/21/2022, 10:54:10 AM [warn] Command[1] 'RMT=5678' Timeout
2/21/2022, 10:54:11 AM [warn] Bad Panel Id: 1. Trying to find the right one
2/21/2022, 10:54:14 AM [error] No remaining possible Panel Id, abandon
2/21/2022, 10:54:14 AM [error] Unable to connect to the control panel.
2/21/2022, 10:54:14 AM [warn] Command[NaN] Wrong CRC value for the response.
2/21/2022, 10:54:16 AM [warn] Command[NaN] Wrong CRC value for the response.
2/21/2022, 10:54:19 AM [warn] Command[NaN] Wrong CRC value for the response.
2/21/2022, 10:54:19 AM [warn] Command[4] 'DCN' Timeout
2/21/2022, 10:54:19 AM [info] TCP Socket Disconnected
2/21/2022, 10:54:19 AM [info] Won't attempt automatic reconnection

Debug log attached.

risco-debug.txt

vanackej commented 2 years ago

Well, that's very strange. The CRC returned by yout panel is only 3 chars long, whereas every other CRC I've seen and computed CRCs are always 4 chars long... I really don't understand why. Can you send the full debug logs for wrong password case ? I wan't to compare received buffers and CRCs in this situation

kkmaslowski commented 2 years ago

wrong_password-debug.log

vanackej commented 2 years ago

I see your firmware version is very outdated. Yours : FSVER=2.59 24/09/13 Mine : FSVER=5.72 23/01/18

I think the protocol is bugged in your version and produces wrong CRC in some situations. Can you update the firmware ?

kkmaslowski commented 2 years ago

I'll try to do it today. Do you know 'remote upgrade password'? I'm trying to run update from CS.

vanackej commented 2 years ago

No sorry I never performed a firmware update by myself

Le lun. 21 févr. 2022 à 14:51, Kamil Maslowski @.***> a écrit :

I'll try to do it today. Do you know 'remote upgrade password'? I'm trying to run update from CS.

— Reply to this email directly, view it on GitHub https://github.com/vanackej/risco-mqtt-local/issues/20#issuecomment-1046902377, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECPHJUKQ7DVE4VQ4P24TTU4I7ONANCNFSM5O4I75FA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

vanackej commented 2 years ago

I found a bug in the decryption method. You don't need a firmware update. Fix coming soon, I'll let you know

vanackej commented 2 years ago

v0.3.8 available => Let me know

vanackej commented 2 years ago

I checked with an unit test and your CRC problem should be gone now. I close the issue, feel free to reopen or comment if not ok.

kkmaslowski commented 2 years ago

Great news, it works! Thank you for your hard work.

Loading config from: /data/config.json
2/23/2022, 7:44:22 AM [info] autoConnect enabled, starting communication
2/23/2022, 7:44:22 AM [info] Connecting to mqtt server: mqtt://192.168.10.100:1883
2/23/2022, 7:44:22 AM [info] Connected on mqtt server: mqtt://192.168.10.100:1883
2/23/2022, 7:44:22 AM [info] Panel is not connected, waiting
2/23/2022, 7:44:30 AM [warn] Command[1] 'RMT=5678' Timeout
2/23/2022, 7:44:30 AM [info] Panel info: LightSys/RP432, FW 2.70
2/23/2022, 7:44:30 AM [info] Panel options: 4 parts, 32 zones, 14 outputs, Pir Cam support: false
2/23/2022, 7:44:30 AM [info] Starting devices discovery
2/23/2022, 7:44:34 AM [warn] Command[21] Receipt of an error code: Device Doesn't Exists
2/23/2022, 7:44:34 AM [info] Output does not exists, stopping outputs discovery
2/23/2022, 7:44:34 AM [info] Panel is ready, subscribing to panel partitions and zones events
2/23/2022, 7:44:34 AM [info] Panel and MQTT communications are ready
2/23/2022, 7:44:34 AM [info] Publishing Home Assistant discovery info
2/23/2022, 7:44:34 AM [info] [Panel => MQTT][Discovery] Published alarm_control_panel to HA on partition 1
...