Visonic Powermax and Powermaster Integration

I’m pleased that you got it working.

This is not normal but I’ve seen it many times before.
Please see the very first post in this thread. To quote:

The remaining lines are part of the fallout of the sudden disconnection and me trying to tidy up. Although I will look in to the line that says Detected blocking call to sleep inside the event loop. etc etc

I have some issues with lost connection/reconnect, which causes state change. It would be nice if the code could do at least 1 retry before changing state to unavailable.

I am using an ESP32 with the Wemos sample code. I have a PowerMax Pro. HomeESP log further down. Looks like both ends blame the other.

One more comment, HomeESP shows it occasionally going offline/online as well. But log channel is not interrupted (or reconnect happens hehind the scenes)

2023-01-03 19:21:23.295 DEBUG (MainThread) [custom_components.visonic.client] Visonic update event panel=4  event=1 {'Zone': 1, 'Event': 5, 'Description': 'Violated (Motion)', 'condition': 1}
2023-01-03 19:27:17.005 ERROR (MainThread) [custom_components.visonic.pyvisonic] ERROR Connection Lost : disconnected because the Ethernet/USB connection was externally terminated.
2023-01-03 19:27:17.009 ERROR (MainThread) [custom_components.visonic.pyvisonic] ERROR Connection Lost : disconnected due to exception [Errno 104] Connection reset by peer
2023-01-03 19:27:17.014 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for visonic doing blocking calls at custom_components/visonic/pyvisonic.py, line 1512: sleep(5.0)  # a bit of time for the watchdog timers and keep alive loops to self terminate
2023-01-03 19:27:22.021 ERROR (MainThread) [custom_components.visonic.pyvisonic]                         Calling Exception handler.
2023-01-03 19:27:22.025 DEBUG (MainThread) [custom_components.visonic.client] PyVisonic has caused an exception [Errno 104] Connection reset by peer
2023-01-03 19:27:22.031 DEBUG (MainThread) [custom_components.visonic.client]  ........... terminating connection and setting up reconnection
2023-01-03 19:27:23.630 DEBUG (MainThread) [custom_components.visonic.client]           ........... Closing down Current Task
2023-01-03 19:27:25.632 DEBUG (MainThread) [custom_components.visonic.client]           ........... Current Task Done
2023-01-03 19:27:28.634 DEBUG (MainThread) [custom_components.visonic.client]  ........... attempting reconnection
2023-01-03 19:27:28.634 DEBUG (MainThread) [custom_components.visonic.client] ........... attempting connection
2023-01-03 19:27:28.635 DEBUG (MainThread) [custom_components.visonic.client] Visonic Connection Device Type is ethernet {<PyConfiguration.DownloadCode: 0>: '9999', <PyConfiguration.ForceStandard: 9>: False, <PyConfiguration.ForceAutoEnroll: 1>: False, <PyConfiguration.AutoSyncTime: 2>: True, <PyConfiguration.PluginLanguage: 3>: 'EN', <PyConfiguration.MotionOffDelay: 4>: 120.0, <PyConfiguration.SirenTriggerList: 5>: ['intruder'], <PyConfiguration.B0_Enable: 6>: False, <PyConfiguration.B0_Min_Interval_Time: 7>: 5, <PyConfiguration.B0_Max_Wait_Time: 8>: 30}
2023-01-03 19:27:30.679 DEBUG (MainThread) [custom_components.visonic.client] ........... connection made
2023-01-03 19:27:40.928 DEBUG (SyncWorker_26) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.055 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.319 DEBUG (MainThread) [custom_components.visonic.client] Visonic update event panel=4  event=2 {'Zone': 0, 'Entity': None, 'Tamper': False, 'Siren': False, 'Reset': False, 'Time': datetime.datetime(2023, 1, 3, 19, 27, 41, 318722), 'Count': 1, 'Type': [97], 'Event': [0], 'Mode': ['Installer Programming'], 'Name': ['System'], 'condition': 2}
2023-01-03 19:27:41.376 DEBUG (SyncWorker_23) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.379 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)
2023-01-03 19:27:41.381 DEBUG (MainThread) [custom_components.visonic.client] isPanelConnected: code format none as armcode is none (panel starting up or is there a problem?)

HomeESP log

[19:26:53][D][sensor:127]: 'visonicinterface WiFi Signal': Sending state -57.00000 dBm with 0 decimals of accuracy
INFO alarm.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO alarm.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for alarm.local
WARNING Disconnected from API
INFO Successfully connected to alarm.local
[19:27:28][D][streamserver:106]: New client connected from 192.168.1.203
[19:27:57][D][sensor:127]: 'visonicinterface WiFi Signal': Sending state -53.00000 dBm with 0 decimals of accuracy

I agree but it could also be your router/network breaking the connection so each end would blame the other end. Just something to consider.

To clarify something about the connection between the panel and the integration, once the connection is broken in this way (i.e. external to Home Assistant) it is not simply a matter of “retrying” as the Ethernet IP connection has to be re-established in the hope that it reconnects. When this happens I have difficulty in knowing precisely where in the data exchange the connection broke and whether data corruption occurred. I considered adding functionality to record this but I took the decision early on to just restart the connection from the beginning every time when a disconnection occurred, I considered both the time taken to do this (a few minutes) and the likely occurances of the disconnections (should be never but lets say an average of once per week). If your disconnections happen more frequently than this then I suggest you consider alternative connection mechanisms.

I don’t think that this is something that I’d consider doing, for the reasons stated above and that I prefer to send “truth” data to Home Assistant and then users write automations accordingly. Where you use the panel mode and/or state, or the generated events, in your automations then consider using the time or using counters to defer certain actions that you have.

Now it has been stable for 14 hours.
I changed the DHCP lease time to 1 day. Guess it should be 30 days or more. Or static.

So DHCP renew - even to same address is a possible explanation. But I powercycled my HA as well as it had lost by zigbee stick after I connected a semis board. Maybe a combination.

heya - is it possible to grab temperature and lighting conditions data from MP-802 PG2 sensors to HA? From what I see they are damn accurate!

Hi, did you manage to set-up an automation to notify off low battery? If yes, can you please share it?

It’s a good idea and I’ll add it to my list of things to look at. I know for sure that the temperatue does not come through with the normal message data from the panel so it must be encoded within the B0 messages. I have a PowerMaster 30 that i use to experiment with and compare to my house alarm which is a PowerMax. If I ever buy that sensor I’ll try to decode the temperature data but there’s a lot of information in these B0 messages that I simply can’t decode at the moment.
Thanks for the suggestion.

if anything I’m happy to share logs

OK we can give it a try but please realise this might not be possible as we don’t know if the panel outputs the tempeature information at all.

Within HA go to the integrations page and click “configure” on the visonic integration. Click “submit” for the existing settings until you get to the B0 experimental processing page and enable it. As you have a PowerMaster panel this config page should be available to you.

I can decode a small part of the B0 messages but I’m not 100% certain of some of the data so this may show triggered sensors in a very slightly different way in HA, if you notice any differences then please tell me about it.

Please also enable “debug” for this integration to output lots of data to the HA log file. This is described on the wiki here

The integration already saves any B0 message it receives to the log file when debug logging is set. By enabling B0 processing it also asks the panel for a sensor data update.

Anyway, restart HA and let this run for 24 hours or so and then upload the log file to dropbox/pastebin somewhere and I can then take a look through to see if anything is obvious. By restarting HA I can see the sensors that you have in the log file and so I can work out what I’m looking for. I could also do with knowing the approximate temperature values I’m looking for and is it in degrees C or F.

Keep me updated :slight_smile:

Cheers! All done -logging in progress :slight_smile: (I Have Powermaster30 and 2 temp sensors enrolled)

Hi, does anyone have an automation to send a notification when a battery of any of the sensors is low?
Thanks!

logs sent - check you inbox :stuck_out_tongue_winking_eye:

Apologies for the silly question here… I am finally getting around to connecting up Visonic Powermax Complete alarm to my ESP device (after a year). Some posts imply that disconnecting the power to the main panel is needed. If I do that and also remove the battery backup will this clear all the settings on the device? It was installed ages ago and I dont really want to have to go through setting everything back up from scratch.

I’ve just had another look through the log file to make sure, I can’t see anything that would indicate temperature or lighting conditions, sorry.

Disconnecting power to the panel is not necessary as long as the mains power connection is not exposed inside the panel (just in case you accidentally touched it and electrocuted yourself). Even so, removing mains power and the battery will not clear the settings, they are held in EEPROM inside the panel so removing power does not do a hard reset. So it’s up to you which way you want to do. It’s all low voltage DC, if you do it when power is applied the only suggestion I would make is to connect the low voltage DC power connections to your ESP device last i.e. connect the data first.
:slight_smile:

Thanks. Managed to connect it all up and the ESP communicate very briefly with the panel (which has appeared in HA). However I got a number of errors in HA that its getting no response and the integration has now reported that it has stopped comms. I have taken a cut of the error log which occurs which I have pasted below. Any ideas?

Source: custom_components/visonic/alarm_control_panel.py:229 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 14:11:32 (1 occurrences) 
Last logged: 14:11:32

[547338807056] Visonic Integration Visonic Alarm Panel 1 not connected to panel.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 958, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/alarm_control_panel/__init__.py", line 161, in async_alarm_disarm
    await self.hass.async_add_executor_job(self.alarm_disarm, code)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/visonic/alarm_control_panel.py", line 229, in alarm_disarm
    raise HomeAssistantError(f"Visonic Integration {self._myname} not connected to panel.")
homeassistant.exceptions.HomeAssistantError: Visonic Integration Visonic Alarm Panel 1 not connected to panel.

The error about no comms says that it has not responded:

[Controller] Visonic Plugin has suspended all operations, there is a problem with the communication with the panel (i.e. no data has been received from the panel)

My guess is something isnt connected right but I am convinced and I have double checked I have TX connected to RX. Thoughts? I will spend a bit more time debugging.

Ok I am an idiot… I had TX and RX backwards. It now seems to be connected and when I use my keyfob the status within HA updates which is great.

I did however get this error regarding a PIN number not being found:


Logger: custom_components.visonic.client
Source: custom_components/visonic/client.py:1042 
Integration: Visonic Intruder Alarm (documentation, issues) 
First occurred: 15:05:46 (7 occurrences) 
Last logged: 15:05:47

Warning: Valid 4 digit PIN not found

This is likely something I havent set up correctly in the integration so will have a play and report back if I get it working.

All working perfectly. Glad I finally got this ticked off my list of things I should have done ages ago! thanks @davesmeghead this works great.

I’m using the visonic integration for quite a while now, very pleased with it, but lately I had an issue with the integration not being available after 2 days, as the period of availability become shorter and shorter I decided to upgrade HA to the lastest stable release (Home Assistant 2023.2.0
Frontend-versie: 20230201.0 - latest) and delete and re-install the integration. I run HA in a docker container on a Synology NAS. A restart og HA solves the problem for a short time but than the integration is unavailable again.

I’m using a Wemos D1 R2 to connect to my powermaster 10 panel.

A copy of my log is available here: HA Visonic unavailbe 3-2-23 - Pastebin.com

What I see in the log is that a valid 4-digit code is missing.

I hope someone can help me, this integration is the way we arm and disarm our alarm, I’ve already tried a number of things but unfortunately to no effect :frowning:

Greetings Niels

Hi, I would like to know your insites in this matter… I have a Powermaster -10 with Powerlink already connected. It I could try to add a ESP32 module to enable connection to HA as well it would be great! I will purchase an ESP32 unit.

Hi,
There’s not much more that I can add really, other than what is in the original post.
I keep my notes in Onenote and this is the diagram that I made last October.

I suggest that you remove and keep your existing ribbon cable and buy a new cable, these are the links to Amazon for the things I bought.
ESP32
12vDC Conv
Ribbon cable

I did not deploy this setup though, I just used it to experiment.

Determine which 2 wires in the new ribbon cable are Tx and Rx and carefully use a craft knife to split them out. Cut these 2 cables and connect all 4 wires to the UARTs on the ESP32. The ESP32 needs quite a bit of power so I decided to provide power from the 12V DC terminals on the Visonic Expansion Board, stepping them down to 3.3v DC. This also provides a common Gnd line so do not use the Gnd from the ribbon cable.

The ESP32 has 3 UARTs but 1 of them is connected to the USB, I can’t remember which is which but I used the 2 that are available, I think UART1 and UART2. And of course, the HA integration connects over wifi. So there are 3 paths to send/receive data: Powerlink, Panel and the HA Integration.

I used Arduino to create, run and test the code but it’s over 200 lines long and it’s a bit of a mess, like I said I was experimenting. When I tried the HA integration in “powerlink” mode the panel seemed to get confused, it worked when I “Forced Standard”. This means that you only get basic sensor information in HA and you will need to either enter the arm/disarm code every time or set the override code in the config.

If you want to progress this and you feel confident that you can wire it up, and you have a decent knowledge in Arduino and programming, then I can tidy up and pass you the source code I used.
:slight_smile: