Visonic Powermax and Powermaster Integration

From your log file I see this

[custom_components.visonic.pyvisonic] ERROR Connection Lost : disconnected because the Ethernet/USB connection was externally terminated.

This means that your wifi is disconnecting it, probably external to HA. This is described here on the wiki and as such there’s not much more I can do.

Hi all,

I’ve read everything in the wiki and tried to find information regarding the NEXT CAM PG2 PIR sensor and whether or not we can see a picture from the camera in HA if the PIR is triggered. Is it possible or am I dreaming?

Not at the moment but it’s on the “to be looked at” list I have. I’ve just bought that sensor from ebay but I haven’t yet connected it to my test powermaster panel.

1 Like

interesting-batman

Thanks Dave,

Moved the mesh wifi access point next to my visonic panel so I hope this solves the problem! Furthermore I made an automation to restart HA when a visonic sensor changes state to unavailable.

Been running the integration for over a week and it has been working well. Just one thing mainly around what happens when Home Assistant is being restarted or the Wifi is being rebooted, is there any way to increase the timeout between the ESP and the Panel? It takes a couple of mins for HA to restart on an update and if my router restarts that is a good 3 mins before connectivity is back up. When it loses comms “BBA Comms Lost” appears and a series of beeps comes from the panel. Is this just how it works or is there any way for a delay to be implemented before the ESP calls back or the integration stops communicating?

Goodnight, i need help, please.
my nodemcu does not communicate with the central visonic powermaxpro

what did I do wrong ?

Thank you very much @davesmeghead ! Really interesting… I have ordered a ESP32 board and I will follow your advice to buy an additional ribbon cable and the voltage converter. I have fooled around a little bit in the past with Arduino programming, I guess I’ll have to recover some pieces of this :slight_smile: .

In my case I also see this as an experimental thing, there is no actual need to have this working but if I can understand how it works there might be some benefits only to be able to see if the alarm is armed or not. I think I can use it to manage other things thru Home Assistant.

I you could pass me the source code for the Arduino program it would be highly appreciated, you don’t think you need to put a lot of effort in cleaning up the code, I’ll try to look into it as it is.

Hi,
I too see it as an experimental thing. For me to be able to support it properly I’d have to have clear and full instructions for everyone to follow, even those with low skill and knowledge and I’m not sure that I want to do that. However, it sounds like you should be OK with the info I’ve already given and the source code below but if you do have any questions then let me know here.

You’ll notice that I have set 38400 baud for the Powerlink UART connection and 9600 baud for the Panel UART. I got better results doing this but feel free to experiment.

As I said previously, I got best results when I “Force Standard” in the HA Integration settings, this way only the real Powerlink is communicating with the Panel using the Powerlink protocol messages. Again though, try experimenting and let me know the results that you get.

Here’s the code I have, I didn’t do any tidying up… so best of luck
As it says in the code the “receiver” variable is very important, it determines from where to receive data for a period of time.

Please update these 2 variables to your Wifi settings
const char *ssid = “MyWifiSSID”;
const char *password = “MyWifiPassword”;

#include <WiFi.h>
#include <HardwareSerial.h>

#define FALSE 0
#define TRUE !FALSE
#define DEBUG

#define ANY_INPUT -1
#define PL_INPUT -2

#define CLIENT_MAX 4

const char *ssid = "MyWifiSSID";
const char *password = "MyWifiPassword";

#ifdef DEBUG
#define DEBUG_PRINT_VAR(...) \
  Serial.print(F(#__VA_ARGS__ " = ")); \
  Serial.print(__VA_ARGS__); \
  Serial.print(F(" "))
#define DEBUG_PRINTLN_VAR(...) \
  DEBUG_PRINT(__VA_ARGS__); \
  Serial.println()
#define DEBUG_PRINT(...) Serial.print(__VA_ARGS__)
#define DEBUG_PRINTLN(...) Serial.println(__VA_ARGS__)
#define DEBUG_PRINTF(...) Serial.printf(__VA_ARGS__)

void printHEX(byte b) {
  char A[17] = "0123456789ABCDEF";
  byte v = b / 16;
  byte w = b % 16;
  Serial.print(A[v]);
  Serial.print(A[w]);
  Serial.flush();
}
#else
#define DEBUG_PRINT_VAR(x)
#define DEBUG_PRINTLN_VAR(x)
#define DEBUG_PRINT(...)
#define DEBUG_PRINTLN(...)

void printHEX(byte b) {
}
#endif

WiFiServer server(30000, CLIENT_MAX);
//WiFiServer monitor(30001);
HardwareSerial SerialPortPanel(1);      // use UART1
HardwareSerial SerialPortPowerlink(2);  // use UART2

// receiver is very important, when:
//    - ANY_INPUT then look at panel first end then the Powerlink and wifi clients
//    - PL_INPUT then look at Powerlink in preference
//    - Greater or equal to 0 --> then look at wifi client receiver in preference
int receiver;
int no_data_count;
uint8_t bluelight;
WiFiClient client[CLIENT_MAX];
bool clientInUse[CLIENT_MAX];
uint8_t dataBuffer[256];

void setup() {
#ifdef DEBUG
  Serial.begin(115200);
#endif
  pinMode(LED_BUILTIN, OUTPUT);

  SerialPortPanel.begin(9600, SERIAL_8N1, 16, 17);      // RX2 and TX2
  SerialPortPowerlink.begin(38400, SERIAL_8N1, 15, 4);  //12,13

  receiver = ANY_INPUT;
  no_data_count = 0;
  bluelight = 0;
  for (int i = 0; i < CLIENT_MAX; i++) {
    clientInUse[i] = FALSE;
  }
}

int getEmptyClientSlot() {
  for (int i = 0; i < CLIENT_MAX; i++) {
    if (!clientInUse[i]) {
      return i;
    }
  }
  return -1;
}

void updateState() {
  if (WiFi.status() != WL_CONNECTED) {
    for (int i = 0; i < CLIENT_MAX; i++) {
      if (clientInUse[i]) {
        client[i].stop();
      }
      clientInUse[i] = FALSE;
    }

    // We start by connecting to a WiFi network
    WiFi.begin(ssid, password);
    delay(5000);
    if (WiFi.status() == WL_CONNECTED) {
      server.begin();
      DEBUG_PRINT("Connected to wifi. My address:");
      IPAddress myAddress = WiFi.localIP();
      DEBUG_PRINTLN(myAddress);
    }
  }

  if (WiFi.status() == WL_CONNECTED) {
    WiFiClient temp_client = server.available();  // listen for incoming clients
    if (temp_client) {
      // Add new clients
      int s = getEmptyClientSlot();
      if (s >= 0) {
        client[s] = temp_client;
        clientInUse[s] = TRUE;
        DEBUG_PRINTF("Client %d Connected\n", s);
      } else {
        DEBUG_PRINTLN("Exceeded the maximum number of Clients");
        temp_client.stop();
      }
    }

    for (int i = 0; i < CLIENT_MAX; i++) {
      if (clientInUse[i] && !client[i].connected()) {
        // Remove disconnected Clients
        DEBUG_PRINTF("Client %d Disconnected\n", i);
        clientInUse[i] = FALSE;
      }
    }
  }
}

void dumpBuffer(int count) {
  Serial.printf(" %3d ", count);
  //DEBUG_PRINT_VAR(count);
  DEBUG_PRINT(" Data = ");
  for (int i = 0; i < count; i++) {
    printHEX(dataBuffer[i]);
    DEBUG_PRINT(" ");
  }
  DEBUG_PRINTLN();
}

void loop() {
  updateState();

  if (receiver == ANY_INPUT) {
    digitalWrite(LED_BUILTIN, bluelight / 16);
    bluelight = (bluelight == 31 ? 0 : bluelight + 1);  // Flash the blue led slowly
    if (SerialPortPanel.available()) {
      DEBUG_PRINT("Panel");
      size_t count = SerialPortPanel.read((uint8_t *)&dataBuffer, (size_t)255);
      // send to powerlink
      SerialPortPowerlink.write((uint8_t *)&dataBuffer, count);
      // send to wifi
      for (int i = 0; i < CLIENT_MAX; i++) {
        if (WiFi.status() == WL_CONNECTED && clientInUse[i] && client[i]) {     // if you get a client,
          client[i].write((const char *)&dataBuffer, count);  // write a s bytes
        }
      }
      dumpBuffer(count);
    } else if (SerialPortPowerlink.available()) {
      receiver = PL_INPUT;
      bluelight = 0;
    } else {
      for (int i = 0; i < CLIENT_MAX && receiver == ANY_INPUT ; i++) {
        if (clientInUse[i] && client[i].available()) {
          receiver = i;
          bluelight = 0;
        }
      }
    }
  }

  if (receiver == PL_INPUT) {
    digitalWrite(LED_BUILTIN, bluelight / 4);
    bluelight = (bluelight == 7 ? 0 : bluelight + 1);  // Flash the blue led slowly
    int count = SerialPortPowerlink.read((uint8_t *)&dataBuffer, 255);
    if (count > 0) {
      SerialPortPanel.write((uint8_t *)&dataBuffer, count);
      if (no_data_count > 0) {
        DEBUG_PRINT("     ");
      } else {
        DEBUG_PRINT("PLink");
      }
      dumpBuffer(count);
      no_data_count = 0;  // zero the no data count as we have data
    }
  }

  if (receiver >= 0 && receiver < CLIENT_MAX) {
    digitalWrite(LED_BUILTIN, bluelight / 4);
    bluelight = (bluelight == 7 ? 0 : bluelight + 1);  // Flash the blue led slowly
    int count = 0;
    if (WiFi.status() == WL_CONNECTED && clientInUse[receiver] && client[receiver]) {       // if you get a client,
      count = client[receiver].read((uint8_t *)&dataBuffer, 255);  // read into buffer, return no of characters in buffer
    }
    if (count > 0) {
      SerialPortPanel.write((uint8_t *)&dataBuffer, count);
      if (no_data_count > 0) {
        DEBUG_PRINTF("     ");
      } else {
        DEBUG_PRINTF("Wifi%d", receiver);
      }
      dumpBuffer(count);
      no_data_count = 0;  // zero the no data count as we have data
      delay(10);
    }
  }

  if (receiver == PL_INPUT || (receiver >= 0 && receiver < CLIENT_MAX)) {
    // if no data has been transferred in X loops then reset it back to allow either source
    no_data_count = no_data_count + 1;
    if (no_data_count >= 2) {  // 2 at 20 mSec = 40 mSec
      //DEBUG_PRINTLN();
      //DEBUG_PRINTLN("Receive from any input");
      receiver = ANY_INPUT;
      no_data_count = 0;
    }
  }

  delay(20);  // delay 20mSec so approx 50Hz and it doesn't need to be accurate
}

I used the Arduino IDE, and I just updated to the latest version so I assume it will still work:
Version: 2.0.3
Date: 2022-12-05T09:30:25.331Z
CLI Version: 0.29.0 [76251df9]
Copyright © 2023 Arduino SA

The Board Type I use is “DOIT ESP32 DEVKIT V1”
You will need to install the esp32 board types from Espressif Systems in the Board Manager
You should be able to use the debug “Serial” monitor in the Arduino IDE to see the print debug messages.
Best of luck and let me know how you get on
:slight_smile:

You cannot use a console to see the output as it is binary data, I assume that is why it displays “X”.
Can you be clear on how you have wired it please and I maybe able to help more.

Essentially this is just how it works. The timeout is in the Panel and I don’t think there’s a Panel setting to change it. When the Panel detects no communication for this timeout then it triggers “BBA Comms Lost”
So this is not something I have any control over, sorry.

@davesmeghead , thank you very much! I will let you know here when I have got the stuff I’ve ordered and started to recap how the Arduino coding is done…

visonic1

flash nodemcu and configure the wifi esp-link

Understood. I have automated in mitigation mechanisms so if there is a blip when the ESP comes back online then it restarts the integration and it all comes back up. The beeps are annoying part… but at least it lets you know something is up!

What do you mean by “Texas”? I assume that you mean “TX” so you have crossed over Tx and Rx.

It looks like from the console image that the X represents binary data so that is good. By using esp-link I assume that you have the IP address and the Port number of the TCP Server?

So what happens when you install my Integration in to Home Assistant, using that IP Address and Port?
Change your Home Assistant logger settings as per this on the wiki and look at the log file. Have you looked through the troubleshooting guide on the wiki here. Perhaps you should try the loopback test in that section on the wiki.

Hi Dave,

First up, thanks for the great work and your dedication to helping everyone, its very cool.

I have a Powermaster G10 which initially (about 9 months ago) was working great, however over time has become more and more unreliable.

I originally had a wemos exactly as per your wiki instructions, however I decided that this could be the source of the instability, so I have changed it out for a Raspberry Pi, with a usb serial adapter and new wiring. Wiring as per your diagram, TX->RX, RX->TX, GND-GND and 3.75->3.3v.

What I’m experiencing is that the connection works great for a short period, after which I start to get errors and it goes into problem mode.

Here’s an excerpt of my logs: visonic logs - Pastebin.com

Edit: And heres a longer version including a reload of the plugin: visonic logs longer - Pastebin.com

As you can see, it seems to error, go out of powerlink, then recover. Even once it’s recovered however it is not able to be used to arm/disarm, instead complaining about PIN (if at all).

A while back I made a noob error and basically wiped the config on the system (I hit the wrong button in the programming software, was a bit of an ordeal as the system is in spanish language). I’m still unsure as to whether there are some specific settings required on the alarm itself to ensure everything works properly.

Any tips you have would be maaaaasively appreciated, I’ve invested an embarrassing amount of hours in this already :smile:

Hi,

How are you powering the Raspberry Pi? You almost certainly should not be connecting the Vcc from the RasPi to the 3.75v on the panel. Connect Tx, Rx and Gnd but not Vcc. If you really have done this and it’s not just a mistake in writing the post then you could have broken your panel or RasPi. If I have this in a diagram then tell me which one and I’ll change it. You should only connect Vcc if you are using the 3.75v from the 10 pin IDE connector to power the “gadget” you’re using. This is the only case where Vcc should be connected.

The connection seems to bounce between PROBLEM and STANDARD as you’re getting missing data

****************************** Response Timer Expired ********************************

The Integration sends a command to the panel and expects a particular response which in your case it doesn’t get, and so after a timeout sets PROBLEM. When the integration does start getting data again (such as periodic state data from the panel) then it assumes everything is OK again and goes to STANDARD mode until the same happens again. I assume that it never gets to POWERLINK mode (in the longer log file) due to the same issue, missing data. In your longer log file, startup never gets the download for the EPROM as I assume the panel doesn’t receive the request command that is sent and so this happens.

********************** Download Timer has Expired, Download has taken too long *********************

To summarise, you have a dodgy connection. This could be due to

  • The Vcc thing above
  • As you’re using USB on a RasPi then it could be lots of things. Have you stopped all devices trying to access that USB port for example.

I suggest that you try the loopback test described here on the wiki.
Let me know what happens.

Cool, thanks for the quick response! I had found more stability when I had the 3.75 / 3.3v connected on between the usb2serial device and the panel, but quickly removed now based on your advice.

To be fair I think it wasn’t your suggestion, but I literally read through the whole of this thread this morning trying to find a way…

Will do the loopback now and see.

OK you were right it’s somehow a dodgy connection. I moved the wiring to exit out of the side of the alarm (which happens to be further away from our main fuse box) and it seems to be working much more stable now.

Thanks so much for pointing me in the right direction!

Just 1 more suggestion in case it helps, you may need a level shifter as the panel is 3.75 (3.3) volts and the RasPi is 5v TTL logic levels. Here’s an amazon link to illustrate what I mean.
RasPi’s are like gold dust at the moment, you could probably sell it on Ebay and get more than you paid :slight_smile:

1 Like