maragelis / ParadoxRs232toMqtt

esp8266, serial bus to mqtt for Paradox alarm systems
MIT License
80 stars 22 forks source link

Events stop after some time #27

Closed ciscozine closed 5 years ago

ciscozine commented 5 years ago

Hi, I have a Magellan 5000 and I use a WemosD1 mini to connect to the alarm system.

At night I arm the alarm, but in the morning "ParadoxRs232toMqtt" seems to be down. I can ping the wemos but I cannot receive MQTT Message.

What can I do? How can I do to debug it?

I use hassio on a rasperry and "Mosquitto broker" as a MQTT Server.

thanks Fabio

maragelis commented 5 years ago

Have you tried the new release ? There where many bug fixes done. Are you also getting "paradox disconnected" on the status topic ?

ciscozine commented 5 years ago

Yes, I have tried the last release without resolve the problem

Thanks

maragelis commented 5 years ago

Is there any chance the raspberry is going to sleep? Are you also getting "paradox disconnected" on the status topic ?

ciscozine commented 5 years ago

No It doesn't go to sleep. Do you know where can I find MQTT broker log on hassio?

thanks

maragelis commented 5 years ago

No sorry. Use mqtt.fx and leave it connected to status topic

ciscozine commented 5 years ago

Ok. I'll update you. Other commands useful for debug this type of problem? For the last, do you use some particular version of home assistant with your project?

thanks again

maragelis commented 5 years ago

No I dont use home assistant. I use openhab and homekit

maragelis commented 5 years ago

If you want you can try this https://github.com/maragelis/ParadoxRs232toMqtt/tree/Dev/ParadoxAlarmSystem/ParadoxAlarmSystemOTA

It has some mqtt connection updates, and get back to me Thanks

ciscozine commented 5 years ago

What are the differences between the 2ino files? thanks

maragelis commented 5 years ago

the one is a ino arduino file the other is a precompiled bin file for flashing

ciscozine commented 5 years ago

Sorry, I didn't see the extension file :D Last question: what happens if WEMOS lost connection for about 1minute to the access point? Does it try to reconnect to the AP?

Thanks I'll update you after testing the new ino file

maragelis commented 5 years ago

Yes it will reconnect

ciscozine commented 5 years ago

Hi, I'll load the new sketch. I'll update you tomorrow. A question. I have trace =1 but using console (9600 or 115200) I do not see nothing. Why?

thanks

ciscozine commented 5 years ago

Again, the same problem. The interface to the paradox seems be down.

I have sniffed the IP flow.

The wemos is live (icmp ok), the mqtt flow still persist. I notice only a SSDP port unreachable ssdp:

each five minute the wemos send to the broker a ssdp message, but at 3:06am the wemos send 2 ssdp message and 1 of that it's a port unreachable (problem on hassio server?) image But I don't know if it is the problem.

2 questions:

  1. My circuit has no resistor. is this the cause the problem?
  2. Can you tell me for each lib, which version have you used? I updated some lib and now, if i try to compile the sketch, I see "DynamicJsonBuffer' was not declared in this scope"

Thanks again

maragelis commented 5 years ago

My friend there is nothing to trace in this situation, trace is for tracing problems with panel commands.

1) Are you using a stable pubsub library? Dont use beta software. 2) Is Trace off <-- very important Trace must be off for seamless operation. Send Trace=0 3) Try flashing a relaese file .bin https://github.com/maragelis/ParadoxRs232toMqtt/releases/tag/v2.1.1. I have many wemos connected to panels without this problem.

ciscozine commented 5 years ago

I'll test and I'll update you! Thansk. My personal suggestion for .bin file. Why don't you give use the possibility to enable authentication and SSL encryption? It would be perfect :)

Thanks

maragelis commented 5 years ago

I will look into it

ciscozine commented 5 years ago

I update you. also with the .bin the problem still persist. What I notice is that after the problem the log of my mqtt broker on hassio (raspberry) is: 1549393009: Client 80:7D:3A:3E:B5:FF has exceeded timeout, disconnecting. 1549393009: Socket error on client 80:7D:3A:3E:B5:FF, disconnecting. but I can ping the wemos d1..

Moreover if I unplug the power and plug the power, the wemos d1 led blinks only 1 time and the ping stop to work. If I detach the serial port to the alarm system and unplug/plug the power, the wemos d1 led blink correctly (3 or 4 times); then if I attach the serial port the broker receive the message correctly.

Thanks

ciscozine commented 5 years ago

One time I receive also a "{"status":"Problem connecting to panel"}". I change the cable without any changes. This is why I ask you if it is better use some resistor .

Moreover I confirm that the Alarme system serial works fine because I called the alarm man specialist.

thanks

maragelis commented 5 years ago

So this happens only when armed ? please help so I can help.

ciscozine commented 5 years ago

No I noticed that only when disarmed. I cannot test if armed because there is a PIR sensor that I cannot disable

maragelis commented 5 years ago

So you are disarmed and the wemos disconnects from mqtt ?

ciscozine commented 5 years ago

I'm sorry. I understand now. Generally when I try do disarm the system (it is armed), the wemos stops to work.

maragelis commented 5 years ago

Are you maybe having low wifi signal

maragelis commented 5 years ago

If the wifi signal cut out for too long the times out and cannot reconnect. Please check if you are getting disconnect status message.

After how long does it disconnect ?

maragelis commented 5 years ago

{"status":"Paradox Disconnected"} this is the last will message if wifi is disconnected, can you check if you are getting this message.

ciscozine commented 5 years ago

Well, I have an access point at 20cm .. It isn't a wireless problem; in fact i can ping the wemos without any problem. No I don't see "{"status":"Paradox Disconnected"}" .

maragelis commented 5 years ago

that tells me that the serial has stopped responding on the wemos.

maragelis commented 5 years ago

can i get what panel you have and firmware if possible

ciscozine commented 5 years ago

Paradox Magellan 5000. I don't know the firmware. Can I find it with your system?

maragelis commented 5 years ago

IF that is the one with the 433mhz transmitter make sure your cables and wemos are well grounded and shielded. I will look into it as I only have the SP series api ans get back to you. @rjduraocosta are you using the same panel ?

maragelis commented 5 years ago

Could you if you have the means to read the voltage over your tx and rx lines. if they are above 3.3v I suggest a level converter between wemos and panel .

maragelis commented 5 years ago

Are you powering the wemos from the panel ?

ciscozine commented 5 years ago

I used power from the panel and from a external power supply. Each one have the problem. tomorrow I check the cable and the welding.

thanks again

rjduraocosta commented 5 years ago

Hello again,

In my case I saw it happening armed and disarmed. My panel is also an MG5000. In my case I am also missing some zone OFF events. My "cable" is straight wires coming from the panel to the Wemos board and I am powering the Wemos board from the panel through a buck converter. Tomorrow I will measure the voltage on the rx tx lines and get back to you.

Thank you for all the help.

rjduraocosta commented 5 years ago

Hello @maragelis and @ciscozine ,,

I measured the voltage on my Wemos Pin's and they are the following:

Some ideas: Move the RX/TX to the original ones? Level Shifter? Resistors? RF Interference?

@ciscozine any news about your setup?

Thanks for the help.

maragelis commented 5 years ago

I am betting on interference. I will try tackle it in code but it could yield unwanted results. How about using a longer cable and moving the wemos further away.

ciscozine commented 5 years ago

Hi @maragelis , good news.

I have tested all components with the tester and it seems ok, but I have identified the cause of my problem (I hope). A solder.

Thanks for all.

For the last but not the least, my suggestion is to make a bin file with the possibility to enable authentication and encryption (ssl).

rjduraocosta commented 5 years ago

Hello again,

I could try and move the Wemos further away for testing, but I cloud only do this at the weekend. It is all in a box that I have to move further and also do another longer cable.

Thanks for the suggestion.

rjduraocosta commented 5 years ago

Hello @maragelis good evening,

I have been testing the system and I found one thing, that it is the following:

If you have some other idea other than mving the wemos away until this weekend, or something I could test I appreciate it.

I do not have a level converter I just have resistors right now. I am not sure if using resistors at the Wemos RX line is fast enough for the serial communication with this configuration: image

Thanks again for your work.

maragelis commented 5 years ago

ok so I am starting to understand what is going on. Can you please tell me the last message you receive before it goes down. Is it a mqtt disconnect ?

The only way we will see whats going on is for you to use a ftdi adapter connect to d4 / RX and get Trace messages

rjduraocosta commented 5 years ago

I have never seen an mqtt disconnect message before the system goes down. In all the tests the last message in the mqtt broker was a zone event, sometimes ON event sometimes OFF event.

Tomorrow I will use an ftdi adapter and connect it to D4 to see the messages. Before that I have to enable TRACE=1through mqtt, right? Another thing, can I use the Arduino IDE Serial monitor for that or do you recommend another program?

Thanks for the support.

maragelis commented 5 years ago

Trace=1 yes, not TRACE=1 yes you can use Arduino IDE just choose right port

maragelis commented 5 years ago

If you have patience we will fix it I just need your help.

rjduraocosta commented 5 years ago

Perfect! You can count on me.

Tomorrow I will share the Trace output's with you.

Thanks again for all for the support.

rjduraocosta commented 5 years ago

Hello @maragelis,

I have the data for you. I restarted the system this morning just to start from scratch and then enabled the Trace and monitored the MQTT messages. For about 2 hours it was all stable with the reporting the zone events to the MQTT broker. After that period I stopped receiving the zone events and hads to send a "wake up" to the system by a command through MQTT, just like I described yesterday. Attached you will find the Trace file. If you open it with and editor that you can see line numbers look at line 1138 that is when I "woke" the system up.

Thanks again for all your effort and help. MG5000_Trace_20190207.txt

maragelis commented 5 years ago

Ok thanks @rjduraocosta , I saw the problem. The serial buffer is getting corrupt. I do have code which tries to fix this, but looks like its getting stuck somewhere. I will try send you an update to see if this solves the problem. It should be ready by tonight be patient as I have day job too.

rjduraocosta commented 5 years ago

@maragelis, thank you for your work. Please take your time and when you are ready I will test it for you, no problem. I also have a day job and I know how thinks are no problem at all. I just had todays day off, remaining vacation day from last year, that is why I could test this today.

Thanks again and please take your time.

maragelis commented 5 years ago

I have a new cleaned up version 2.2 for testing and I think I have squashed this bug. I also had this long time ago. It happens when to-many events overflow the serial buffer. In the login i clear the buffer thats why it starts working again. Looks like its taking to long to process the incoming messages.

maragelis commented 5 years ago

Can you please try this version

https://github.com/maragelis/ParadoxRs232toMqtt/tree/Dev/ParadoxAlarmSystem/ParadoxAlarmSystemOTA