ParadoxAlarmInterface / pai

Paradox Magellan, Spectra and EVO, with MQTT, Signal, Pushbullet, Pushover and others
https://gitter.im/paradox-alarm-interface
Eclipse Public License 2.0
340 stars 91 forks source link

Issue connecting to MG5050 via Serial #60

Closed RaihaX closed 5 years ago

RaihaX commented 5 years ago

System MG5050 VIA USB-Serial (I have tried two https://www.jaycar.com.au/arduino-compatible-usb-to-serial-adaptor-module/p/XC4464 and http://www.logicware.com.au/6pin-usb-2.0-to-ttl-uart-module-serial-converter-c) using RPi 2 running raspbian.

Describe the bug Running bare bone config haven't enabled anything except for changing the log to debug mode and changing my password to None (I have successfully manage to connect twice and realise that i needed to use None to get in (on my second attempt)). I don't know why I can connect in those two times as nothing has changed (at that point i only had my first board) the only difference is that i haven't tried connecting in about 12 hours so I am not sure if there some sort of persistent session or the panel can lock me out due to multiple failed attempts?

The rest of the time I get the following (even after trying the second USB-Serial), i have also tried numerous different dupont jumper cables in case i have some faulty ones (socket - socket or socket to pin out using a breadboard).

The only thing i have yet to try is using a different RPi (not sure if somehow its not compatible with RPi 2?)

ps. assuming that the serial port goes from TX/RX/GND (I found from an earlier post) i had to cross my tx and rx line on the usb-serial as otherwise it wasn't receiving any data from the panel.

pss. I have no other device connected to the panel (babyware/ip150 etc etc) this is the sole device. Also not running Docker as I figure I will use the Docker once i can get this up and running manually - using the latest copy from GitHub.

2019-03-21 13:34:02,505 - INFO - PAI - Starting Paradox Alarm Interface 2019-03-21 13:34:02,507 - INFO - PAI - Console Log level set to 10 2019-03-21 13:34:03,509 - INFO - PAI - Using Serial Connection 2019-03-21 13:34:03,546 - INFO - PAI - Starting... 2019-03-21 13:34:03,549 - INFO - PAI.paradox.paradox - Connecting to interface 2019-03-21 13:34:03,551 - DEBUG - PAI.paradox.connections.serial_connection - Opening Serial port: /dev/ttyUSB0 2019-03-21 13:34:03,567 - DEBUG - PAI.paradox.connections.serial_connection - Serial port open! 2019-03-21 13:34:03,569 - INFO - PAI.paradox.paradox - Connecting to panel 2019-03-21 13:34:03,572 - INFO - PAI.paradox.paradox - Initiating communication 2019-03-21 13:34:03,578 - DEBUG - PAI.paradox.paradox - PC -> A b'72000000000000000000000000000000000000000000000000000000000000000000000072' 2019-03-21 13:34:03,665 - DEBUG - PAI.paradox.paradox - PC <- A b'72ff10010000a52601024064210747160000010100160220070101001602200700000000fb' 2019-03-21 13:34:03,672 - DEBUG - PAI.paradox.paradox - Container: fields = Container: length = 36 offset2 = 36 offset1 = 0 data = b'r\xff\x10\x01\x00\x00\xa5&\x01\x02@d!\x07G\x16'... (truncated, total 36) value = Container: po = Container: command = 7 message_center = 2 new_protocol = 255 protocol_id = 16 protocol = Container: version = 1 revision = 0 build = 0 family_id = 165 product_id = (enum) (unknown) 38 talker = (enum) CONTROLLER_APPLICATION 1 application = Container: version = 2 revision = 64 build = 100 serial_number = b'!\x07G\x16' (total 4) hardware = Container: version = 0 revision = 0 bootloader = Container: version = 1 revision = 1 build = 0 day = 22 month = 2 year = 32 processor_id = 7 encryption_id = 1 reserved0 = b'\x01\x00' (total 2) label = b'\x16\x02 \x07\x00\x00\x00\x00' (total 8) checksum = b'\xfb' (total 1) 2019-03-21 13:34:03,694 - INFO - PAI.paradox.paradox - Found Panel version 2.64 build 100 2019-03-21 13:34:03,696 - INFO - PAI.paradox.paradox - Starting communication 2019-03-21 13:34:03,701 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:03,715 - DEBUG - PAI.paradox.paradox - PC <- A b'e0141303150a1300030000000000005a6f6e6520303320202020202020202000000000007e' 2019-03-21 13:34:03,717 - DEBUG - PAI.paradox.paradox - Unknown message: e0 14 13 03 15 0a 13 00 03 00 00 00 00 00 00 5a 6f 6e 65 20 30 33 20 20 20 20 20 20 20 20 20 00 00 00 00 00 7e 2019-03-21 13:34:03,718 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:08,727 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:13,738 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:18,749 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:23,759 - DEBUG - PAI.paradox.paradox - PC -> A b'5f200000000000000000000000000000000000000000000000000000000000000002000081' 2019-03-21 13:34:28,770 - ERROR - PAI - Unable to connect to alarm

Thank you in advance! and hopefully I can get this working.

RaihaX commented 5 years ago

FYI I don't know why but the only to get this working is to change the log to log.info run the script, let it fail to connect then change it back to log.debug and run it again and it constantly work.

Don't know why after doing that it doesn't give out an "Unknown Message".

jpbarraca commented 5 years ago

That is very strange. I have access to a MG5050 and cannot reproduce this. I think we need to create a branch with code specific for debugging this.

RaihaX commented 5 years ago

It is odd indeed would it be specific to my firmware and build?

Do you know what the unknown message that I get when the connection fails?

RaihaX commented 5 years ago

So I am just going to ignore the issue now that i have figured out a way to get it working (still trying to get it to work with HASS) - as long as i keep my log to debug it will always work and not fail to connect.

jpbarraca commented 5 years ago

I tested with a MG5050 6.128 and I could not replicate the error. What is the FW version of your module?

RaihaX commented 5 years ago

Is that the panel version that comes through from the debug lines? if so I guess my firmware is running 2.64?

If not I assume I will need to check this using baby ware?

jpbarraca commented 5 years ago

check with babyware

RaihaX commented 5 years ago

Will check this weekend

FYI i push the latest version from git and ran the script again and now I am not getting an "Unknown Message" anymore.

It gives me a "read failed: device reports readiness to read but returned no data (device is disconnected or multiple access on port?).

Trying to read up on it and will probably spend some time tinkering with your code to debug this further.

jpbarraca commented 5 years ago

That happens if there are 2 instances of Pai running or the previous did not disconnected. I suspect of the second case.

RaihaX commented 5 years ago

Best way to clear the instance?

Shutdown the panel for x minutes?

jpbarraca commented 5 years ago

It will automatically disconnect after some time (not more than 2 minutes). What we can do is disconnect the panel before we connect, so that the previous session is closed. The code is actually there, but we may have a bug.

jpbarraca commented 5 years ago

Can you please test? We now send a disconnect message before a new connection is established. I tested with a MG5050 and it presented no issue.

RaihaX commented 5 years ago

Sorry i forgot to reply to this - I have turn the script (with the latest update) into a service and I noticed that I am still getting the unknown message but if i just let it run after 5-10 mins it will eventually connect.

Now the other thing that i notice - the mqtt command was no longer responsive and when i check the status of the script it keep requesting state/status from the panel and not receiving anything.

I had to terminate the script and run it again for it to work again - so not sure if it somehow "dies" after a while?

A minor mqtt question, I can't get the state of the panel but I can control it fine can I assume that the partition id for retrieving the states is the same for control? this is the topic I'm using in HASS paradox/states/partitions/1/current_hass.

ps. I have yet to try babyware to check the firmware as i didn't get the chance this weekend. I really need to do this as I assume i can get the id/name of the partition through this.

jpbarraca commented 5 years ago

The labels are mapped directly from the panel. However, if the labels are not loaded, the command will be ignored as the target object doesn't exist. The latest commit helps you?

If PAI connects you can point babyware to the IP address of the system with PAI, port 10000 as a direct IP Connection.

RaihaX commented 5 years ago

The latest commit help (i don't get the read failed etc etc) as I mention it was still giving me the unknown message but if I just let it keep running it will keep reconnecting and after 5-10 mins it seems to connect to the panel.

Ill update this if i am still having that other issue where the panel was no longer responsive until i terminate the script and start it again.

I figured if the control command is working; i assume i got the correct "label" for my partition - I just can't figure out why HASS is not receiving the state of my panel.

Ah good to know that I can connect babyware with an IP Address - i can spin up a Windows VM on my server and check it out through there. Makes it a lot easier as I needed to get a female to male usb cable so i can extended the cp2102 usb serial to reach my laptop.

RaihaX commented 5 years ago

So I manage to connect using babyware through PAI ip connection sort off. Lots of problem though I keep getting packet timeout and the connection drops out constantly and is always stuck on step 6 when its trying to communicate on the bus modules.

I manage to at least figure out my firmware version is 2.4, need to figure out the partition name/label/id all i can see is Zones/Area so far.

jpbarraca commented 5 years ago

Try winload. Babyware is more picky . Also, can you update the firmware to v5 or v6? We never tested with v2.4

RaihaX commented 5 years ago

I assume you need to connect using either babyware or winload in order to upgrade the firmware?

Winload doesn't seem to want to connect at all - it fails straight away (just checked this is v5.6, i can't find a place to download v5.71)

I couldn't get winload from the paradox website though as there was no download link on the page. I did manage to source one from a random site.

jpbarraca commented 5 years ago

If you search for winload 5.71, google will provide you some links. You should connect directly to the serial port (without PAI).

Regarding your issues, I'm a bit lost. That module is one of the most tested ones, and those errors should not exist. I believe there is something fundamentally wrong with your setup. Maybe the firmware version as it is very very old.

RaihaX commented 5 years ago

I will try winload direct to the serial port and will have to read up on how to upgrade the paradox panel - it does seem very old if you guys are all using v5 or newer

RaihaX commented 5 years ago

Just an update on this - I have updated my panel to the latest 6.8 and all my issues seems to have gone away - so more then likely a compatibility issue v2.4 is definitely a no go!

Will monitor it for a few days but so far so good - monitored and controlled through HASS.

On a side note i tried baby ware with direct connect VIA serial and that still didn't work (stuck on the same stage) but WinLoad v5.71 was the magic bullet!

ps. The interface for winload takes me back a decade or two though lol...

jpbarraca commented 5 years ago

Thanks for the update.

RaihaX commented 5 years ago

So far so good - no issue for the whole day.

Before I updated the panel the panel would stop responding after x amount of minute (doesn't disconnect but it will stop sending messages back to pai) - i actually had to restart the service every 30 min in an attempt to get it going.

So far it has been a solid connection with no time out issue.

jpbarraca commented 5 years ago

We will add a note to the README stating that panels with older firmware may present some issues.

RaihaX commented 5 years ago

That would be handy for new users!

Happy to close this as it seems to be working really well now!