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

Using ESP32 to bridge serial port to wifi AND to another serial device after it #352

Closed Gyosa3 closed 1 year ago

Gyosa3 commented 1 year ago

Feature description

Hi, I am trying to add my Paradox alarm (Magellan MG5070) to my Home Assistant setup, but the two devices are quite distant so I need to use IP communication. The alarm is part of a service contract that I have with a security company, so I cannot do everything I want with the alarm panel, the company needs to have control/validation over the setup.

I thought the less intrusive option was to get serial over IP via an ESP32 device that I would plug into the panel and not interfere with the normal operation of the alarm. Also because Raspberries are very scarce and expensive at the moment, but ESP32 are available and cheap.

I have bought an ESP32 board with 12v-5v converters and 5V-3.3V opto-couplers, the setup is ready but when I opened the alarm panel... there was a GSM/LTE module installed already on the serial port. I cannot remove it, it is installed by the security company that manages the alarm for me. That's how they remotely control the installation, they don't hook to my wifi.

So my idea is the following:

As the ESP32 has several UART on the chip, I would like to plug the ESP32 on the serial port of the alarm panel instead of the GSM module, send the serial data to PAI over wifi, and at the same time, bidirectionally clone the serial data to the GSM module via a second UART on the ESP32 board.

Has this been tried before? Is this realistic?

My first concern, before the firmware, is the hardware and the voltage. The wiki here: https://github.com/ParadoxAlarmInterface/pai/wiki/Connection-methods#serial-over-ip-esp32
mentions the direct connection of the TX and RX pins of the alarm panel to the ESP32, while they are on 5V on the alarm panel but are on 3.3V on the ESP32. I think the wiki is delivering an inaccurate message, no? I have seen other posts on other forums that were all using 5v-3.3V converters to hook into the ESP32.

This would also mean that if an official module from Paradox (like the GSM module) is plugged in to another UART of the ESP32 the voltage level should be upped again to 5V to transmit to the second device (GSM or IP150 for example). As the opto couplers have usually 4 channels, th same board could be used before and after the ESP32. But that's purely theoretical.

Then for the software to achieve this: Actually I have understood the concept of plugging the ESP32 UART into the Alarm panel, but I have not understood what firmware I should install on the ESP32 to send the data to PAI. The wiki page is quite vague on this point, as if it is a marginal setup. There is a link to this project: https://github.com/cybertza/PAI-ESP32 but it is not clear how this relates to PAI and to ESPHome. It says: added ESPhome example as well (its not tested with pannel, but on the bench it works, it then leverages off the ESPHome stack to keep the device alive, can also add a relay to add to an Panic input if you wanted to do something to that effect). I don't have a clue what it means, and the code itself refers to: https://github.com/oxan/esphome-stream-server that seems to be the actual code for streaming the serial data to HA over wifi? That's so unclear to me, but it is my first esphome implementation so I am an absolute beginner in this space. There is no better explanation in the esphome page on uart: https://esphome.io/components/uart.html this is very generic and does not really say how the serial data is sent to a receipient like PAI.

I would be happy if you could give me some feedback on all this, on the cloning of the serial data, on the voltages in the wiki, on the source codes to use via ESPHome or not, etc. Thank you so much! G.

yozik04 commented 1 year ago

I had some reports that ESP module approach was working for some (@cybertza). Never tried myself. Wiki is freely editable. If I'd do I would use a step down converter to connect to the panel. ESP Module is only needed to make serial connection from PAI. No processing is done on ESP. No idea how to add an another module after ESP32 in chain unfortunately. Sorry for taking so long to reply. I was thinking that somebody with working setup would respond to you.