Visonic Powermax and Powermaster Component

Hello, I’d like to add my thanks too for this. It has the potential of being really useful in our house.
A (probably daft) question if I may… can you are the alarm from an automation?
I’ve tried several things and thought I was close with…
service
alarm_control_panel.alarm_arm_home

and service data…
“entity_id”: “armed_home”

I’ve Googled and read this thread several times but I’m stuck.
Any ideas where I am going wrong?

Cheers
Mark

11 replies up is an example script from robertf

Well that’s embarrassing… I could have sworn I read this through several times.
Thank you!

Hi again!
I am still loving this component. Even my brother is going to buy a Visonic alarm and install Home Assistant only for this :slight_smile:

I have a question: I was making some tests triggering the alarm and I could not see that the state changed to “triggered”. Am I right?
Is that possible to get? It would be easy to make more automations when the alarm is triggered.

I am also install the manual component alarm of Home Assistant. I am beginning with it but I think we can have good things like a better (for me) armed home mode, for example, using Visonic sensor and others.
Have someone tried that? I will share when I have more done :slight_smile:

Best regards!!

I’ve just set and then triggered the alarm to see what happens and you’re correct, the state does not change to triggered in HA.

So, I started to update the code to support this and found the bug … and then my problems started.
I noticed in the code that there is no way to get the siren status when in Standard mode. I changed my config so my setup was forced in to Standard mode (not Powerlink) to test that and now I can’t get it back in to Powerlink mode, I guess I’ll wait a couple of days and try it again.

Anyway, there’s an issue in Standard mode in that there is no way to tell when the siren is sounding, this is only available for Powerlink mode (through the A7 message, in standard mode we do not get these). In standard mode we get A5 messages that tell me the state of the panel (Disarmed, Armed Home etc) and it tells me that there’s been a “Panel Alarm Event” which seems to be set when the siren starts to sound. The problem is that I don’t know when the siren stops sounding. I can assume that if the panel is Disarmed then the siren stops but what about when the siren just times out (20 minutes on my panel) and the panel remains armed. Even though the siren has stopped, in standard mode I have no way of getting this for sure.

So, in Standard mode I have 2 issues:

  1. I am guessing that when the panel is Armed and there is a “Panel Alarm Event” that means the siren is sounding
  2. I have no way of telling when the siren stops sounding, other than the panel being Disarmed

I think I’ve fixed the original problem (alarm triggering in HA) for Powerlink mode but I also cannot test it at the moment, until I get my panel back in to Powerlink. :disappointed: :roll_eyes:

Excellent work on this component Dave. It seems very promising. I am hoping to test it quite soon. I just have a question. In the description of the component you say “This allows you to connect your alarm panel to your ethernet home network”. Does this mean that the ethernet connection has to go through the router, or can it be connected directly to the RPI3 running HA?

The connection to the panel itself is serial. You can put a serial<-> ethernet or wifi converter in there if you want, that is supported, but you can also directly connect it to a raspberry pi or other device.

I’ve just updated the code to version 0.0.6.2 to indicate when the alarm is sounding but like I said earlier in this thread, I’m not 100% happy with it in “Standard” mode i.e. not Powerlink.

In Standard mode I know when the panel is armed and that there’s been a “Panel Alarm Event” which seems to happen when the siren is sounding. I assume that this results in a “Triggered” state for HA.

Oh yeah, I managed to get my panel back in to Powerlink :slight_smile:
In Powerlink mode it seems to work well

Thanks! I have bought a USR-TCP232-E2 to connect the alarm panel, but I was wondering if the ethernet cable can be connected to the ethernet contact on the RPI3 where I run HA, or does it have to go through the router?

When you say “ethernet contact” I assume that you mean the ethernet connector on the RasPi. If so then yes. In the olden days, many decades ago, you would need an ethernet crossover cable but they auto negotiate these days so you can use a normal ethernet patch cable (not crossover).

Anyway, you can directly connect an ethernet cable between the USR-TCP232-E2 and the RasPi ethernet connector, you do not need to go through a router. If you already have both hardware, give it a try.

Just to edit this post and add the link
Read to the end about Auto-MDIX

Excellent! Many thanks - both for your helpful reply and for all the hard work with the component. I look forward to testing it.

If you’re connrecting it directly to a raspberry pi you could as well have gone for a TTL to USB cable, those are about 5 euros or less and also work. That’s what I am running here without problems, and the Raspberry is not even running HA, I user ser2net to forward the traffic to my HA installation, just because this is what I had on hand.

Today I did connect a USR-TCP232-E2 to my very old Powermax. It’s not a Powermax Pro, Express or Plus, it’s just a Powermax. I think it’s the very first model from 2001. The problem is, that the USR is powered only when the Powermax is in installation mode. If I leave installation mode, the LED’s on the ethernet connection of the USR die and its webserver is no longer available on the LAN.

Do I need a setting on the Powermax to power the RS-232 interface beyond installation mode? Or is this first series of Powermax to limited to work with the HA component?

EDIT: Never mind, I found a second hand Powermax Pro on the internet, which is a hardware upgrade of 12 years for me. :smiley: :smiley: I’m sure I’ll get that one running with this splendid component.

Well, after many hours trying to configure direct connection between the USR-TCP232-E2 and the RPI ethernet port, I gave up… The USR-TCP232-E2 works fine when connected through a router, but I could not figure out what host and gateway IP’s to use for connecting directly to RPI Ethernet. I use the WiFi on the pi to connect to HA, and don’t have any free USB ports. The router is normally not very close to the Visonic, and I would rather not set up a wired connection all the way to the router, so I guess the only solution would be to go for a USR WIFI232-D2 instead. What type of aerial do you use for this unit?

The WIFI 232 came with a 15cm rubber antenna. I used double sided tape to mount the board and the antenna inside the Power Max case

Mark

I assume that you tried giving each (USR-TCP232-E2 and RPi) a static IP address in the same range, that is also different to your router range i.e if your router DHCP range is 192.168.0.X then you should try a static range of 10.10.10.X for example.

Although both devices say they follow the Auto-MDIX part of the protocol, Auto-MDIX is really only for gigabit ethernet (I think) which I don’t think the USR-TCP232-E2 is so I know it’s more expense but you could buy a crossover ethernet cable to try it.

You could also follow WWolkers advice and use a USB ↔ Serial adaptor, you could then have the RPi physically local to the alarm box.

Best of luck and let us know how you get on and if you resolve it

It’s finally up and running! :smiley: Thanks for your support. Yes, I did try to set a static IP for the RPI earlier, but it did not work. These last days I have read through a lot of webpages in my quest to find clues to how I can manage to get this connection working. I run HA as hassio on resin OS, and tried to set a static IP on the RPI according to the instructions at Network Setup on balenaOS - Balena Documentation

However, when I plugged in the ethernet cable from the serial to the RPI, HA stopped responding. It was just cycling through the animated “busy” icon whenever I tried to do anything, such as restart HA from the UI. When I unplugged the ethernet cable from the RPI, HA started behaving normally again.

This morning when I woke up I remembered reading this in the resin OS network instructions (same as URL above): “To set WiFi as the default route to the internet, you need to force eth0 to have a low route metric and set the never-default option”, and it got me thinking that eth0 taking over ALL communication, even the communication that normally goes through wifi in my setup, such as the HA UI, might be the cause of my problem. When I added:

never-default=true
route-metric=2000

to the [ipv4] configuration for eth0 in addition to the static IP, everything worked smoothly. :smiley: I haven’t managed to get it into powerlink mode yet, but I understand this might take some time to accomplish. All the sensors seem to be working, though, so not a huge problem.

So, once again, thanks a mil for all the hard work you have put into this component! I look forward to exploring the possibilities this opens for my system.

Many thanks for this component. I got it running with HassIO (0.84.6) and a USR-TCP232-E2 in my fresh second hand PowerMax Pro. Only using standard mode so far, because powerlink mode didn’t succeed yet.

I saw some errors when trusting on the default values of the parameters. Later when I added this 3 parameters explicitly, the errors went away. Could it be that the default value of e.g. the language isn’t set well?

There also were some errors on this component not using id's for sensors. But they also disappeared when using the parameters explicitly.

I hope this info is welcome to improve the component. But as said, you can work around it.

visonic:
  device:
    type: ethernet
    host: 'SOME_IP'
    port: SOME_PORT
#  motion_off: 180
#  language: 'EN'
  force_standard: 'yes'
#  sync_time: 'yes'
  allow_remote_arm: 'yes'
  allow_remote_disarm: 'yes'
2018-12-30 19:45:18 DEBUG (MainThread) [custom_components.pyvisonic] [handle_msgtypeA5]      Zone Event sysStatus 0x0   sysFlags 0x21   eventZone 10   eventType 5   x10status 0x0
2018-12-30 19:45:18 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport
Traceback (most recent call last):
  File "uvloop/handles/stream.pyx", line 827, in uvloop.loop.__uv_stream_on_read_impl
  File "/config/custom_components/pyvisonic.py", line 1004, in data_received
    self.handle_received_byte(databyte)
  File "/config/custom_components/pyvisonic.py", line 1085, in handle_received_byte
    self.handle_packet(self.ReceiveData)
  File "/config/custom_components/pyvisonic.py", line 1961, in handle_packet
    self.handle_msgtypeA5(packet[2:-2])
  File "/config/custom_components/pyvisonic.py", line 2347, in handle_msgtypeA5
    log.debug("[handle_msgtypeA5]      Event {0} in zone {1}".format(pmEventType_t[self.pmLang][eventType] or "UNKNOWN", eventZone))
KeyError: None
2018-12-30 19:45:18 ERROR (MainThread) [custom_components.pyvisonic] ERROR Connection Lost : disconnected due to exception  <None>
NoneType: None
2018-12-30 19:45:23 ERROR (MainThread) [custom_components.visonic] PyVisonic has caused an exception None
2018-12-30 19:45:33 ERROR (MainThread) [custom_components.visonic]  ........... attempting reconnection
2018-12-30 19:45:35 DEBUG (MainThread) [custom_components.pyvisonic] [pmSendPdu]      waiting for message response ['0X2']
2018-12-30 19:45:36 INFO (MainThread) [custom_components.pyvisonic] [QueueMessage] Getting Status
2018-12-30 19:45:36 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: alarm_control_panel.visonic_alarm. Platform visonic does not generate unique IDs
2018-12-30 19:45:36 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: switch.visonic_alarm_panel. Platform visonic does not generate unique IDs
2018-12-30 19:45:45 INFO (MainThread) [custom_components.pyvisonic] [SendCommand] Re-Sending last message  Initializing PowerMax/Master PowerLink Connection
2018-12-30 19:45:49 INFO (MainThread) [custom_components.pyvisonic]                         Zone name for 1 is Front door
2018-12-30 19:45:49 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport
Traceback (most recent call last):
  File "uvloop/handles/stream.pyx", line 827, in uvloop.loop.__uv_stream_on_read_impl
  File "/config/custom_components/pyvisonic.py", line 1004, in data_received
    self.handle_received_byte(databyte)
  File "/config/custom_components/pyvisonic.py", line 1085, in handle_received_byte
    self.handle_packet(self.ReceiveData)
  File "/config/custom_components/pyvisonic.py", line 1959, in handle_packet
    self.handle_msgtypeA3(packet[2:-2])
  File "/config/custom_components/pyvisonic.py", line 2196, in handle_msgtypeA3
    self.pmSensorDev_t[offset+i].pushChange()
  File "/config/custom_components/pyvisonic.py", line 695, in pushChange
    self._change_handler()
  File "/config/custom_components/sensor/visonic.py", line 46, in onChange
    self.schedule_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 317, in schedule_update_ha_state
    self.hass.add_job(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'add_job'
2018-12-30 19:45:49 ERROR (MainThread) [custom_components.pyvisonic] ERROR Connection Lost : disconnected due to exception  <'NoneType' object has no attribute 'add_job'>
NoneType: None
2018-12-30 19:45:54 ERROR (MainThread) [custom_components.visonic] PyVisonic has caused an exception 'NoneType' object has no attribute 'add_job'
2018-12-30 19:46:04 ERROR (MainThread) [custom_components.visonic]  ........... attempting reconnection
2018-12-30 19:46:10 DEBUG (MainThread) [custom_components.pyvisonic] [handle_msgtypeA5]      Zone Event sysStatus 0x0   sysFlags 0x1   eventZone 0   eventType 0   x10status 0x0
2018-12-30 19:46:10 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport
Traceback (most recent call last):
  File "uvloop/handles/stream.pyx", line 827, in uvloop.loop.__uv_stream_on_read_impl
  File "/config/custom_components/pyvisonic.py", line 1004, in data_received
    self.handle_received_byte(databyte)
  File "/config/custom_components/pyvisonic.py", line 1085, in handle_received_byte
    self.handle_packet(self.ReceiveData)
  File "/config/custom_components/pyvisonic.py", line 1961, in handle_packet
    self.handle_msgtypeA5(packet[2:-2])
  File "/config/custom_components/pyvisonic.py", line 2367, in handle_msgtypeA5
    if 0 <= sysStatus < len(pmSysStatus_t[self.pmLang]):
KeyError: None
2018-12-30 19:46:10 ERROR (MainThread) [custom_components.pyvisonic] ERROR Connection Lost : disconnected due to exception  <None>
NoneType: None
2018-12-30 19:46:15 ERROR (MainThread) [custom_components.visonic] PyVisonic has caused an exception None
2018-12-30 19:46:25 ERROR (MainThread) [custom_components.visonic]  ........... attempting reconnection

If needed I can supply complete logs, but I’m hesitating because of possible secure information.

I hope this info is welcome to improve the component.

Any bugs or problems that you find are more than welcome.

I think I’ve fixed the problem about not setting the values in the config file, they should stay at their defaults now when not defined. This should fix the 2 issues where you get “KeyError: None”
I’ve uploaded version 0.0.6.3

I’m also interested in the other 2 issues

I think for this one:

homeassistant.exceptions.HomeAssistantError: Entity id already exists: alarm_control_panel.visonic_alarm. Platform visonic does not generate unique IDs

I need to look in to this as it has just started happening with a version update of HA itself, so HA has been changed in some way and I need to find out what I need to do now to make unique IDs. When the sensors are first created in HA (i.e. the first time you run this component) I create IDs in HA for each sensor, each time the component is rerun I recreate the same IDs and HA was OK with this but not any more it seems.

For this one:

AttributeError: 'NoneType' object has no attribute 'add_job'

I need to try and reproduce this somehow, or add more debug code and ask you to try it and provide me with the log file if that’s OK. I won’t need complete logs, just the relevant fragments.

Hi @davesmeghead,
I installed version 0.0.6.3 and tried with minimal settings:

#  motion_off: 180
#  language: 'EN'
  force_standard: 'yes'
#  sync_time: 'yes'
  allow_remote_arm: 'yes'
  allow_remote_disarm: 'yes'

Most errors are gone now. Great. The add_job error didn’t occur a first time, but after another restart, there was (only one) occurrence:

2019-01-04 19:46:32 DEBUG (MainThread) [custom_components.pyvisonic] [pmSendPdu]      waiting for message response ['0XA3']
2019-01-04 19:46:32 DEBUG (MainThread) [custom_components.pyvisonic] [data receiver] Received message 0XA3   data SOME_DATA
2019-01-04 19:46:32 DEBUG (MainThread) [custom_components.pyvisonic] [handle_packet] Parsing complete valid packet: SOME_DATA
2019-01-04 19:46:32 INFO (MainThread) [custom_components.pyvisonic] [handle_MsgTypeA3] Wibble Packet = SOME_DATA
2019-01-04 19:46:32 INFO (MainThread) [custom_components.pyvisonic]                         Zone name for 1 is Front door
2019-01-04 19:46:32 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport
Traceback (most recent call last):
  File "uvloop/handles/stream.pyx", line 827, in uvloop.loop.__uv_stream_on_read_impl
  File "/config/custom_components/pyvisonic.py", line 1004, in data_received
    self.handle_received_byte(databyte)
  File "/config/custom_components/pyvisonic.py", line 1085, in handle_received_byte
    self.handle_packet(self.ReceiveData)
  File "/config/custom_components/pyvisonic.py", line 1959, in handle_packet
    self.handle_msgtypeA3(packet[2:-2])
  File "/config/custom_components/pyvisonic.py", line 2196, in handle_msgtypeA3
    self.pmSensorDev_t[offset+i].pushChange()
  File "/config/custom_components/pyvisonic.py", line 695, in pushChange
    self._change_handler()
  File "/config/custom_components/sensor/visonic.py", line 46, in onChange
    self.schedule_update_ha_state()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 317, in schedule_update_ha_state
    self.hass.add_job(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'add_job'
2019-01-04 19:46:32 ERROR (MainThread) [custom_components.pyvisonic] ERROR Connection Lost : disconnected due to exception  <'NoneType' object has no attribute 'add_job'>
NoneType: None
2019-01-04 19:46:37 ERROR (MainThread) [custom_components.visonic] PyVisonic has caused an exception 'NoneType' object has no attribute 'add_job'
2019-01-04 19:46:47 ERROR (MainThread) [custom_components.visonic]  ........... attempting reconnection