Skip to content
David edited this page May 13, 2020 · 122 revisions

Visonic Alarm Panel for Home Assistant

Custom Integration for integration with Home Assistant

Introduction

Visonic produce the Powermax alarm panel series (PowerMax+, PowerMaxExpress, PowerMaxPro and PowerMaxComplete) and the Powermaster alarm series (PowerMaster 10 and PowerMaster 30). This Home Assistant Integration allows you to control the alarm panel (arm/disarm) and allows you to use the Visonic sensors (movement, door contact, ...) and X10 devices within Home Assistant.

Please note that:

  • After extensive work, the original PowerMax Panel is not able to be used as it does not support the Powerlink protocol that this integration relies on. It only supports EPROM Upload and Download and nothing more.
  • The Visonic 360R Alarm Panel is not fitted with an RS232 connection and cannot have a Powerlink3 fitted, it is therefore not compatible with this HA Integration.

Contents

What my Frontend looks like

This is what my sensors look like

And I have 2 cards in Lovelace, they look like this

Supported Visonic Panel Type

These are the supported Visonic Panel Types (including specific model information).

Panel Type Panel Model Comment
0 (21) Powermax This doesn't work with this Integration, it doesn't support a Powerlink Hardware Module.
1 (47) Powermax+ This will work but needs to be Manually Enrolled (please set force_autoenroll to 'no').
2 (22) Powermax Pro This will work but needs to be Manually Enrolled (please set force_autoenroll to 'no').
3 (?) Powermax Complete This will work and will auto enroll.
4 (17,71,86) Powermax Pro Part This will work and will auto enroll.
5 (18,79) Powermax Complete Part This will work and will auto enroll.
6 Unknown
7 (32,68,153) Powermaster 10 This will work and will auto enroll. You may need to disable the battery saver in your PIR sensors to get motion triggers when the alarm is disabled.
8 (6,53) Powermaster 30 This will work and will auto enroll. You may need to disable the battery saver in your PIR sensors to get motion triggers when the alarm is disabled.
Visonic 360r This doesn't work with this Integration.

The Panel Type determines the main panel model, the number in brackets I assume to be a sub-type that you can see in HA as the "Model Type" and "Panel Name" Attributes after you get it working.

Supported Panel Functionality

This Integration currently connects to the panel and it creates an:

  • HA Sensor for each alarm sensor
  • Alarm Panel integration Entity "alarm_control_panel.visonic_alarm" so you can look at the internal state values
  • HA Switch for each X10 device
  • "alarm_control_panel" badge so you can arm and disarm the alarm.
  • HA service to bypass/re-arm individual sensors
  • HA service to retrieve the event log and save to an xml and/or a csv file

As of version 0.2.0 I have changed the control flow and introduced a new mode "Standard Plus". You know which mode you are in by looking at the Entity "alarm_control_panel.visonic_alarm" and the attribute "Mode".

You do not need to use the Master Installer Code from your panel. To connect in Standard Plus and Powerlink mode, the Integration uses a special Download Code. This defaults to "5650" (for those with ASCII knowledge this is hex for the characters VP for Visonic Panel I believe), but you can override it in the configuration.

What it doesn't do in Home Assistant

  • Partitions, it assumes a single partition.
  • The compatibility of the binding with the PowerMaster alarm panel series is only partial.

Hardware Setup

You have a choice, you can connect to your Visonic Alarm Panel using RS232, USB or Ethernet (Wired or Wireless)

The PowerMax/Master Alarm Panels provide an internal panel connector that is labelled as the Control interface, the PC interface or the RS232 interface, this interface directly supports a TTL logic level based RS232 protocol. Visonic do not provide a specification of the RS232 protocol and, thus, the Integration uses the available protocol specification given at the ​domoticaforum. The binding implementation of this protocol is largely inspired by the Vera and OpenHab plugins.

RS232 "Direct" Option

The panels internal RS232 interface can be connected to an RS232 9 pin "DB9" Type connection on the machine running Home Assistant. However, note that the panel interface is an RS232 connector that uses TTL logic signal levels and not "proper" RS232 voltage levels. The Visonic PowerMax serial interface is not installed by default but can be ordered from any PowerMax vendor (called the Visonic RS-232 Adaptor Kit). This adaptor kit makes the TTL logic levels on the panel connector in to "proper" RS232 signal levels. I have never tried this and I don't know of anyone that has. If you do it like this you're pretty much on your own.

USB Option

You do not need the Visonic RS-232 Adaptor Kit if you use a USB interface with TTL RS232 logic levels. You can then connect the USB cable to a Windows PC, a raspberry pi, or any other linux capable device such as some NAS devices. If you run Home Assistant on any of these devices it will likely appear to the operating system as a USB device but many of the RS232 to USB devices come with drivers to install that make it appear like a serial device in some way (e.g. on Windows it appears as a COM port)

Ethernet Option

Ethernet Option 1

If you want to connect your panel to your home ethernet network then you have 2 further options, this is option 1. This option uses a small Linux based device such as the raspberry pi to run the ser2net program to turn it into a network connected device.

Install ser2net on the linux device. edit the ser2net config file like this:

10628:raw:600:/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A700eRHw-if00-port0:9600 8DATABITS NONE 1STOPBIT

Be sure to change it to the proper serial port (/dev/ttyUSB0 in most cases). After editing, restart the ser2net service.

Now setup the Integration in Home Assistant like the ethernet setup, using the raspberry pi IP as IP address and 10628 as the port. Of course you can use any other port you like, but be sure to also change it in the ser2net config file also and to restart ser2net. There are users that have this setup and can help in the forums, one main advantage is that you can use the WiFi capability of the raspberry pi.

Ethernet Option 2

If you want to connect your panel to your home ethernet network then you have 2 further options, this is option 2. I can help a bit more with this set up as that is what I have. I have a device that connects to the RS232 TTL interface inside the panel (without using the Visonic RS-232 Adapter Kit) and creates an Ethernet TCP connection with a web server to set it up. I bought this

There is a newer version out called a USR-TCP232-E2. There is also a wifi version available like this that's a bit more expensive but essentially it's the same. Although you will need to also buy an aerial for it remember!

This allows you to connect your alarm panel to your Ethernet home network. There is a webserver running on this and you need to set it up for TCP in STA (station) mode as transparent. The RS232 side is 9600 baud, disable control flow i.e CTS/RTS, no parity and 1 stop bit. In the HA configuration you set the IP address and port for this device. I suggest that you avoid port numbers below 1024 as they tend to be special.

One user has also been successful in using an iTach IP2SL and using its PoE capability to power it.

Wiring it all up

You do not need to buy anything else apart from 4 wires. For some panels you can buy a connector with a cable that you can use to make it easier. I bought an "IDC 10-pin ribbon cable" for my panel but remember that the panels and connectors can be different. I then split the wires to use the 4 that I needed.

You connect it in to your Visonic alarm panel like this

I connected the 3.75v pin on the panel to the Vcc (3.3v) on my device, gnd to gnd and Tx to Rx, Rx to Tx. 4 wires and that's it. It just worked!

Some users have found that they only have 5 volts available and they need 3.3 volts and so need to use a DC supply regulator (with 2 10uF Capacitors) to generate the 3.3 volts and then they also need a logic level shifter between the 5 and 3.3 volt TTL levels.

Baud rate

A quick note on Baud rates. This is relevant for all connection types as it determines the connection to the panel itself (i.e. all connection alternatives need to connect to the panel using RS232 in some way)

Different panel firmware versions uses different baudrates. This needs to be set in either the Ethernet/RS232 connection or the USB/RS232 connection. I believe that these are:

17.133 and below - baudrate is 9600 18.XXX and above - baudrate is 38400

Installing the Software in to HA

This section tells you how to install the software part of the Integration in to Home Assistant.

There are 2 ways to do this

  1. Direct download. When you download the github zip file, extract it in your main HA configuration directory. This will create this directory hierarchy custom_components/visonic/**** where `****``` are all the files of the Integration
  2. Using HACS. Add the Github http website page for this Integration to the HACS repository.

Note that I have included the python library REQUIREMENTS statement but in case that doesn't work you would need to install some python libraries yourself (although this is unlikely):

sudo pip3 install pyserial
sudo pip3 install python-datetime
sudo pip3 install pyserial_asyncio

The Different Connection Modes

There are different ways to connect to the Panel and each gives it's own advantages and disadvantages. One persons advantage is another persons disadvantage so there are configuration settings to support this. Also, the highest level of interaction is with Powerlink Mode but that cannot always be achieved.

Standard Mode

This is the basic mode where the alarm panel provides an indication of its state and the information about the sensors and X10 devices. However, not all information is available for the Sensors, critically the sensor type is missing. You can arm and disarm the panel by either setting the override_code in the HA configuration or by entering the code each time manually. The EPROM data is not downloaded from the alarm panel.

Standard Plus Mode

As per Standard mode, but in addition the EPROM data has been obtained from the panel. This provides more detailed information about the sensors and X10 devices and it also provides the user code for the panel. You can arm and disarm the panel without entering any user code as the HA Integration already knows it. You do not need to use the override_code in the HA configuration.

Powerlink Mode

As per Standard Plus mode, in addition the interaction with the panel is more robust with continual "Powerlink Alive" messages from the Panel. From a functionality view point, there isn't much difference between Standard Plus and Powerlink.

You can force it in to Standard mode.

This Integration tries to connect in Powerlink mode by default, unless you set force_standard to 'yes'.

If the Integration connects in Standard Plus or Powerlink mode then it automatically gets the user codes from the panel to arm and disarm.

If the Integration connects in Standard mode then you must provide the user code to arm and disarm. You can either use 'override_code' in the HA configuration or manually enter it each time. Some panels allow arming without the user code. Note that to arm and disarm you must also set the configuration settings to permit this.

Why would I want to force Standard Mode?

It all comes down to trust and security versus flexibility. Do you trust your home network and the HA connection to it?

  • For those that have no trust then force Standard Mode and disable remote arm and disarm through this Integration.
  • For those that have some trust but not too much, then force Standard Mode and enable remote arm and disarm through this Integration (you're presented with a keypad). Perhaps just enable remote arm but not disarm.
  • For those that have a bit more trust, then force Standard Mode, enable remote arm and disarm through this Integration and set the override_code in your configuration (no keypad needed).
  • For those that have full trust, get the connection to at least Standard Plus (but hopefully Powerlink) and enable remote arm and disarm through this Integration (no need to set the override_code in your configuration and no keypad needed).

The Home Assistant Integration

This section looks at how you set up the integration within HA. By now you should have the hardware setup and the software for this integration installed. You also need to know which mode you are trying to get to: Standard, Standard Plus or Powerlink.

Home Assistant have added the ability to configure integrations (components) from within a running Home Assistant installation i.e. without having any configuration in the configuration.yaml file.

configuration.yaml settings Integration settings Description
No No Nothing happens. You can create an integration from within HA yourself, look down the list for "Visonic Alarm Panel".
Yes No The visonic configuration will be imported from the configuration.yaml file. An Integration will be created for you.
No Yes The Integration settings are used.
Yes Yes The Integration settings are used. The configuration.yaml settings are ignored.

The last table row is an important point to emphasise as the HA core developers have completely changed the configuration system to set up the components (integrations). The old way is to use the configuration.yaml file but this is seen to be too difficult and complex for new users and users who don’t have any software skills. The new way is via the integrations page in the frontend, a simpler way for non-technical people to set up the integrations (components) they wish to use. I have updated this visonic component/integration to migrate the settings from the configuration.yaml file to the HA integration by reading the configuration.yaml file only when there is not a visonic integration already in HA. Therefore, after the first time the configuration.yaml file is read, it is then ignored as this first time creates an integration in HA. If you delete the integration from within HA and then restart HA, it will read the configuration.yaml file again to get the settings.

Note also that the HA terminology has changed, components are now called integrations so I try to use component for the old way and integration for the new way, please understand that they are pretty much the same thing (and I still get them mixed up when I write about them). I have changed the terminology on this wiki to Integration.

You can delete the integration from within HA (select the 3 vertical dots and then delete) and optionally restart HA. Note that deleting the integration stops everything working and terminates the connection with the panel but it does not remove all the frontend.

You can edit (and this is the clever bit) some of the settings for the integration by selecting the "options" in the integration. Some of the settings are only used at startup and you cannot subsequently edit those. Specifically for PowerMaster users, by default it does not ask you for the experimental B0 settings. If you have a PowerMaster panel and want to use this you can edit an existing integration that is in Powerlink mode and the settings will be there to set/change.

One last thing about the integration, you can only have 1 Visonic Panel integration in HA (connected to a single physical panel). If you try to create a new visonic integration and you already have one, then it will tell you that you that you cannot create a second.

The configuration.yaml file

This is an example from my configuration.yaml file showing an Ethernet connection to the panel:

visonic:
  device:
    type: ethernet
    host: !secret visonic_ip
    port: !secret visonic_port
  motion_off: 120
  language: 'EN'
  force_standard: 'no'
  sync_time: 'yes'
  allow_remote_arm: 'yes'
  allow_remote_disarm: 'yes'
  exclude_sensor: '2,3'
  exclude_x10: '1'
  panellog_logentry_event: 'yes'
  panellog_csv_add_title_row: 'yes'
  panellog_xml_filename: 'panel_log.xml'
  panellog_csv_filename: 'panel_log.csv'
  panellog_complete_event: 'yes'
  arm_away_instant: 'no'
  arm_home_instant: 'yes'
#  force_numeric_keypad: 'yes'
#  override_code: '1234'
#  download_code: '9876'
#  arm_without_usercode: 'yes'

You can also have a USB (for RS232) connection instead of Ethernet:

  device:
    type: usb
    path: '/dev/ttyUSB1'

The complete list of options are defined below with their default and full list of settings:

Name Default Description List of values
motion_off 120 The time to keep the zone trigger True after it is triggered. There will not be another trigger for that sensor within this time period. Integer Seconds
language 'EN' Set the Langauge. 'EN' for English, 'NL' for Dutch or 'FR' for French. 'EN', 'NL' or 'FR'
force_standard 'no' Determine whether it tries to connect in Standard Plus & Powerlink mode or just goes to Standard. 'no' or 'yes'
force_autoenroll 'yes' Determine the ability for this Integration to autoenroll prior to the panel type being known. Powermax+ panels cannot autoenroll and need to set this to 'no'. 'no' or 'yes'
sync_time 'yes' Attempt to synchronise the time between the device you run HA on and the alarm panel. Powermax only, not Powermaster. 'no' or 'yes'
allow_remote_arm 'no' Determines whether the panel can be armed from within HA. 'no' or 'yes'
allow_remote_disarm 'no' Determines whether the panel can be disarmed from within HA. 'no' or 'yes'
override_code '' If in Standard mode, then this is the 4 digit code used to arm and disarm. See note 1 below 4 digit string
download_code '5650' This is the 4 digit code used to download the EPROM and to Enroll for Powerlink. 4 digit hex string
arm_without_usercode 'no' If the Panel is Disarmed, then Arm without the usercode (not all panels support this). See note 2 below. 'no' or 'yes'
force_numeric_keypad 'no' Display the numeric keypad to force the user to enter the correct code (in any Mode). The only exception is the use of arm_without_usercode. 'no' or 'yes'
exclude_sensor '' A list of Zone sensors to exclude e.g to exclude zones Z02 and Z03 then use '2,3' '1,2 ... ,64'
exclude_x10 '' A list of X10 devices to exclude e.g to exclude devices X02 and X03 then use '2,3'. For PGM use 0 in the list. '0,1,2 ... ,15'
panellog_logentry_event 'no' Generate an event within HA for each panel log entry (potentially hundreds). 'no' or 'yes'
panellog_xml_filename '' If this is set to something other than an empty string, create an xml file with the content of the panel event log using an xml template (Note 3 and 4) '' or 'validpath/filename.xml'
panellog_csv_filename '' If this is set to something other than an empty string, create a csv file with the content of the panel event log (Note 4) '' or 'validpath/filename.csv'
panellog_csv_add_title_row 'no' If creating a csv file, then do or do not include a title row at the top 'no' or 'yes'
panellog_complete_event 'no' Generate an event within HA at the end of the log retrieval. As this could take tens of seconds, this HA event marks the end. 'no' or 'yes'
panellog_reverse_order 'no' Reverse the order of the entries in the saved file(s) 'no' or 'yes'
panellog_max_entries 10000 Retrieve at most this number of log entries. For example, set this to 1 to get the most recent, etc... Integer
arm_away_instant 'no' If set to 'yes' then arm away instant is used instead of a normal arm away (Note 5) 'no' or 'yes'
arm_home_instant 'no' If set to 'yes' then arm home instant is used instead of a normal arm home (Note 5) 'no' or 'yes'
allow_sensor_bypass 'no' If set to 'yes' then allow individual sensors to be bypassed (using the HA service) 'no' or 'yes'
siren_sounding ["Intruder"] A list of reasons that the siren is sounding see Note 6

Note 1: If in Standard Plus or Powerlink mode then this is not used. If in Standard mode and the override_code is not set then you will have to enter your 4 digit code every time you arm and disarm. It depends on how secure you make your system and how much you trust it.

Note 2: This is only used when in Standard mode. Some panels will arm without entering the 4 digit user code but some will not. So if your panel does not need a user code to arm then set this to 'yes' in your HA configuration files.

Note 3: This creates an xml file from the xml template defined in a file called 'visonic_template.xml'. There is a default 'visonic_template.xml' file with this Custom Integration that it uses unless it finds the file in the following directory locations, in order: templates, xml, www, '.' (where '.' is your configuration directory). The dictionary variables entries total and available are passed in to the jinja2 xml file for processing. Take a look at the default file and you should see what I mean.

Note 4: Be careful with the filename path, especially putting a leading "/". By default, if you do not specify a path, the file is created in your configuration directory.

Note 5: Arming Instant has an exit delay as normal but does not have an entry delay. Once armed, any detection will trigger an immediate alarm. Arm home instant is the most useful for me when setting an alarm overnight.

Note 6: The complete list of reasons that the siren may be sounding are ["Intruder","Tamper","Fire","Emergency","Gas","Flood","X10","Panic"]

Home Assistant device_class

In Standard Plus & Powerlink Modes, I try to set the device class correctly by default however I don't know if a particular perimeter sensor "magnet" is on a door or window for example. By default I set all:

  • "PIRs" to device_class "motion"
  • "magnet" to device_class "window"
  • "wired" to device_class "door"

You can change this in your customize configuration like this for example

    "binary_sensor.visonic_z04":
      friendly_name: 'Kitchen Door'
      device_class: door

Home Assistant Panel Services

The Integration responds to some of the built in HA Alarm Panel Services. The first 3 are HA built in, the other 5 I have added.

In the first 6 services the "code" service data is optional, depending on the mode that we're connected as i.e. in Standard mode then you will need to set the code.

Name Description
alarm_control_panel.alarm_arm_away Arm the panel away e.g. "entity_id":"alarm_control_panel.visonic_alarm"
alarm_control_panel.alarm_arm_home Arm the panel home e.g. "entity_id":"alarm_control_panel.visonic_alarm"
alarm_control_panel.alarm_disarm Disarm the panel e.g. "entity_id":"alarm_control_panel.visonic_alarm"
visonic.alarm_sensor_bypass Bypass/Arm individual sensors (must be done when panel is disarmed). e.g. "entity_id":"binary_sensor.visonic_z01", "bypass":"True"
visonic.alarm_panel_eventlog Retrieve the panel event log and process it.
visonic.alarm_panel_command Send Arm / Disarm commands to the panel (Note 1) e.g. "Command":"Stay"
visonic.alarm_panel_reconnect Reconnect following a previous problem.
visonic.alarm_panel_download Download the EPROM data again to refresh parameters.

Note 1: The "Command" is set to one of "Disarmed", "Stay", "Armed", "StayInstant", "ArmedInstant". These are all case insensitive. The Pin code is optional and is only needed in Standard Mode. Just to note that alarm_control_panel.alarm_arm_away has the same effect as visonic.alarm_panel_command with different service data. This is similar for alarm_control_panel.alarm_arm_home and alarm_control_panel.alarm_disarm. Also, "Night" and "NightInstant" have been removed. You probably never saw these anyway as the panel can't do anything with them, they are used in HA, use "Stay" and "StayInstant" instead. Some panels may have a "Night" but I do not know what value to send to the panel.

Home Assistant Panel Events

The Integration generates these events on the HA event bus. Events are part of HA and I generate an HA event for many things such as changes in the panel or sensor states. My implementation for sensor states is really basic. For Panel events though release 0.3.7.0 includes the detailed panel state data. To see them in action in your own HA, go to “Developer Tools”, “Events” and in the bottom where it says “Listen to events” paste alarm_panel_state_update and click “start listening”. Then do things with your alarm panel such as trigger sensors, arm and disarm, you should see what I mean.

Name Description Event Data
visonic_alarm_panel_event_log_entry When the event log is being downloaded, an HA event for every panel log entry (if enabled in config) see Note 1 below
visonic_alarm_panel_event_log_complete When the event log from the panel has been downloaded (if enabled in config) None
alarm_panel_state_update An HA Event is sent through HA for various panel and sensor events condition (see Note 2 below)

Panel Event Log HA Events (Note 1)

The list of HA event data parameters for each log entry (that you can also use in the jinja2 xml settings file)

Data Type Description
current Integer The current event log entry
total Integer The total number of event log entries
data Date The date of the event in the historical log
time Time The time of the event in the historical log
partition Integer The panel partition
zone String The Zone of this log
event String The detailed Panel Event

Panel and Sensor HA Events (Note 2)

This describes the HA event data associated with the alarm_panel_state_update HA event.

The data that appears in every alarm_panel_state_update HA event is condition: X where X is 0 to 14.

condition 11 to 14 have 2 additional data items described in this table as "Command" and "Reason"

X Meaning Command Reason Data Set
0 Problem with the Integration itself (Note 1)
1 Zone update
2 Panel update A
3 Panel update AND the alarm is active A
4 Panel reset A
5 Pin rejected
6 Panel Tamper alarm
7 EPROM download timeout, go to Standard Mode
8 Watchdog timeout, staying in current mode
9 Watchdog timeout, going to try to get a better mode
10 There has not been any data received from the panel
11 Arm/Disarm feedback "disarmed", "stay", "armed", "stayinstant", "armedinstant" 0,1,2,3,4 B
12 Bypass feedback "Bypass" 0,1,2,3 B
13 Event Log feedback "EventLog" 0,1,2 B
14 X10 feedback "X10" 0,1,5 B

Note 1 : This is usually a communication failure with the panel

I may add more information to the event later if required

Data set A

This represents the Panel State and is used when the event condition is set to 2, 3 or 4

Name Description
'Zone' The Zone in this panel state
'Entity' The Entity in this panel state. You can use this to directly get the sensor entity data in automations
'Tamper' Panel Tamper (True or False)
'Siren' Is the siren sounding (True or False)
'Reset' Has the panel had a system reset (possibly by exiting installer mode on the panel) (True or False)
'Time' The creation time
'Count' How many messages in the Type, Event, Mode and Name lists
'Type' A list of integers representing an action that has taken place
'Mode' A list of the string representations of the Type list
'Event' A list of integers representing the event that has taken place
'Name' A list of string representations of the Event list
Data set B

This represents the Panel State when the event condition is set to 11, 12, 13 or 14 This represent the feedback in to HA when this components Services are used

Name Type Description
'Command' String Depends on which event, one of "disarmed", "stay", "armed", "stayinstant", "armedinstant", "bypass", "eventlog" or "x10" (See Note 1)
'Reason' Integer Depends on which event 'Command', one of 0, 1, 2, 3, 4 or 5 (See Note 1)
'PanelReady' Boolean The Panel Ready state (True or False)
'OpenZones' String List A list of Zones that are open (not closed)
'Bypass' String List A list of Zones that are bypassed
'Tamper' String List A list of Zones that have the 'raw' tamper set
'ZoneTamper' String List A list of Zones that have the "logical" tamper set

Note 1: The Reason is an integer 0 to 5 inclusive, each command has the following reasons.

Command Reason
disarmed 0,1,2,3,4
stay 0,1,2,3,4
armed 0,1,2,3,4
stayinstant 0,1,2,3,4
armedinstant 0,1,2,3,4
bypass 0,1,2,3
eventlog 0,1,2
x10 0,1,5

Reasons 0 to 5 are:

Reason Meaning
0 Success, Sending Command to Panel
1 Not sending command to panel, Request only supported when not downloading EPROM
2 Not sending command to panel, not allowed without valid pin
3 Not sending command to panel, user configuration setting prevented access
4 Not sending command to panel, invalid state requested
5 Not sending command to panel, general X10 Problem

Home Assistant Automation Examples

- alias: Alarm Armed So Turn Lights Off
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: alarm_control_panel.visonic_alarm
    to: armed_away
  action:
  - service: script.alarm_armed

- alias: Alarm Disarmed So Email Me
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: alarm_control_panel.visonic_alarm
    to: disarmed
  action:
  - service: script.alarm_disarmed

- alias: 'Alarm Siren Triggered Action'
  initial_state: true
  trigger:
    platform: event
    event_type: alarm_panel_state_update
    event_data:
      condition: 3
  action:
    service_template: persistent_notification.create
    data_template:
#      notification_id: "alarm_panel_state_update"
      title: "Alarm Siren"
      message: "{% set ety = trigger.event.data['Entity']|string %}
                {% if ety == 'None' %}
                    Alarm siren from unknown sensor
                {% else %}
                    The Sensor that triggered the Siren is the {{ state_attr(ety, 'friendly_name') }}
                {% endif %}"

- alias: 'Alarm Panel Arm/Disarm Request Action'
  initial_state: true
  trigger:
    platform: event
    event_type: alarm_panel_state_update
    event_data:
      condition: 11
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.reason in [1,2,3,4] }}
  action:
    service_template: persistent_notification.create
    data_template:
      notification_id: "alarm_panel_state_update_failed"
      title: "Alarm {{ trigger.event.data.Command|title|string }} Request Failed"
      message: "{% set st = trigger.event.data.OpenZones %}
                {% if st|length > 1 %}
                    There are open zones, check the following
                    {% for ent in st %}
                        {{ '\n' ~ ' '|safe*30 ~ state_attr(ent, 'friendly_name') | string }}
                    {% endfor %}
                    \n
                {% elif st|length == 1 %}
                    The {{ state_attr(st[0], 'friendly_name') | string }} is open \n
                {% endif %}
                {% set ta = trigger.event.data.Tamper %}
                {% if ta|length > 1 %}
                    There are zones with Tamper alarms, check the following
                    {% for ent in ta %}
                        {{ '\n' ~ ' '|safe*30 ~ state_attr(ent, 'friendly_name') | string }}
                    {% endfor %}
                {% elif ta|length == 1 %}
                    The {{ state_attr(ta[0], 'friendly_name') | string }} has Tamper set 
                {% endif %}"

- alias: 'Alarm Panel Arm/Disarm Reject Action'
  initial_state: true
  trigger:
    platform: event
    event_type: alarm_panel_state_update
    event_data:
      condition: 12
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.reason|int in [1,2,3,4] }}
  action:
    service_template: persistent_notification.create
    data_template:
      notification_id: "alarm_panel_state_update"
      title: "Alarm {{ trigger.event.data.Command|string }} Request Failed"
      message: "{% set st = trigger.event.data.OpenZones %}
                Could not make the request to your alarm panel \n {{ trigger.event.data.Message|string }}
                {% if st|length > 1 %}
                    Also there are open zones, check the following
                    {% for ent in st %}
                        {{ '\n' ~ ' '|safe*30 ~ state_attr(ent, 'friendly_name') | string }}
                    {% endfor %}
                {% elif st|length == 1 %}
                    Also, the {{ state_attr(st[0], 'friendly_name') | string }} is open 
                {% endif %}"

Of course you'll have to write your own scripts!

Attributes of the Alarm Panel Entity

This section shows the attributes that are created for the alarm_control_panel.visonic_alarm Entity.

Most of the attributes are created directly from the downloaded EPROM data that you can use in Automations etc. For attributes that start with a lower case letter, these are built-in HA attributes.

The following attributes are created from the data that is obtained from the panel using the various message data

Name Type Description
'Panel Status Code' Integer This is an integer representation of the main panel state. See Note 1
'Comm Exception Count' Integer Counts how many comms disconnections there has been
'Download Timeout' Integer Counts how many failed attempts to download the panel EPROM data
'Watchdog Timeout' Integer Counts how many watchdog timeouts there has been (interruptions but not disconnected)
'Mode' String Set to one of "Unknown", "Problem", "Starting", "Download", "Standard", "Standard Plus", "Powerlink"
'Model' String The model type of the alarm panel (or "Unknown")
'Panel Name' String The alarm panel name, type number and model number
'Door Zones' List of Strings A list of the Magnetic sensor names
'Motion Zones' List of Strings A list of the Motion sensor names
'Smoke Zones' List of Strings A list of the Smoke sensor names
'Other Zones' List of Strings A list of the Other sensor names
'Devices' List of Strings A list of the X10 switch names
'Power Master' String The Integration is connected to a PowerMaster series Panel, set to 'yes' or 'no'
'Panel Status' String See Note 2
'PluginVersion' String Set to the current plugin version
'Panel Ready' String Is the Panel Ready, set to 'yes' or 'no'
'Panel Ready' String Is the Panel Ready, set to 'yes' or 'no'
'Panel Alert In Memory' String Is there an alert in panel memory, set to 'yes' or 'no'
'Panel Trouble' String Is the Panel in the Trouble state, set to 'yes' or 'no'
'Panel Bypass' String Is the Panel Bypass set, set to 'yes' or 'no'
'Panel Armed' String Is the Panel armed, set to 'yes' or 'no'
'Panel Status Changed' String Has the panel state changed, set to 'yes' or 'no'
'Panel Alarm Event' String Has there been a Panel Alarm event, set to 'yes' or 'no'
'Panel Siren Active' String Is the Panel Siren Active, set to 'yes' or 'no'
'Panel Last Event' String Shows the last Panel Event, set to a mode string, a forward slash and then the zone string
'Panel Alarm Status' String The Panel Alarm Status, set to "None", "Intruder", "Tamper", "Panic", "Fire", "Emergency", "Gas", "Flood"
'Panel Trouble Status' String The Panel Trouble Status, set to "None", "Communication", "General", "Battery", "Power", "Jamming", "Telephone"
'Panel Last Event Data' Structure This is a data dictionary that contains a lot of information representing the state of the Panel

Note 1

  • -1 = Panel State Undefined (during Startup)
  • 0 = Disarmed
  • 1 = Arming Home
  • 2 = Arming Away
  • 3 = Entry Delay
  • 4 = Armed Home
  • 5 = Armed Away
  • 6 = Special ("User Test", "Downloading", "Programming", "Installer")

Note 2: Set to one of "Unknown", "Disarmed", "Home Exit Delay", "Away Exit Delay", "Entry Delay", "Armed Home", "Armed Away", "User Test", "Downloading", "Programming", "Installer", "Home Bypass", "Away Bypass", "Ready", "Not Ready", "Disarmed Instant", "Home Instant Exit Delay", "Away Instant Exit Delay", "Entry Delay Instant", "Armed Home Instant", "Armed Away Instant"

Extra Hidden Functionality

There are 2 extras that I include in the release

Using Powermaster Remote Programmer

If you connect to your panel using USB then you can plug that USB in to your Windows PC and use the Visonic Remote Programmer software directly

Download the software here

The user manual is here

You'll find the login username and password in the user manual.

"Powermaster Remote Programmer" Bridging

You can use the "Powermaster Remote Programmer" (PRP) from a Windows PC to connect to your panel if using the Ethernet option

  • Download and setup com0com on your PC with a Virtual RS232 connection using COM1 and COM2 (assuming these aren't existing real devices on your Windows PC)
  • Run bridge.py from a command prompt and connect to COM1 like this
python3 bridge.py -address 192.168.X.Y -port YourPort -usb COM1
  • Run PRP and connect to COM2

You can then use PRP with your panel, the bridge command prompt displays the messages going to/from the panel

The bridge can also be used to connect to COM ports together like this

python3 bridge.py -coma COM1 -comb COM2

For Testing without HA

Disable the Integration in HA (or disable HA altogether) and use the test.py script from a command line like this

python3 test.py -address 192.168.X.Y -port YourPort
On Linux:   python3 test.py -usb /dev/ttyUSB1
On Windows: python3 test.py -usb COM1

It will perform as it does in HA but from the command line. Note that the other settings from the configuration can be changed by editing test.py

Also note that if you have just installed python3 on to your Windows PC then it may be missing a few libraries. Use "pip3 install libname" to install them.

Troubleshooting

OK, so you've got it partially working but it's not quite there.... what can you do.

The first thing to say is that it's a PITA to get it in to Powerlink mode from within HA. I believe the problem is to do with timing issues and the way HA works with asyncio. Is this ideal, No. Do I have a choice, No. From experience, if the panel isn't doing what you think it should then leave it alone for a few hours. I believe, although I am not sure, that it has some kind of antitamper in the software for the RS232 interface and it stops allowing Powerlink connectivity.

  • I try to get it in to Standard Plus or Powerlink mode but it only goes in to Standard mode

    • Check that force_standard is set to 'no'
    • If you have had anything connected to the panel in the past that has been in Powerlink mode then Do a Full Restart (see below what I mean *).
  • I try to get it in to Powerlink mode but it only goes in to Download mode

    • Has it been like this for less than 4 minutes, then wait as it can take a long time with some devices and panels
    • So it's more than 4 minutes, OK. Do a Full Restart Sequence as defined below.
    • Send me a log file (see below)

(*) Full Restart Sequence for Powerlink:

  • Stop HA
  • Restart the panel: Restart your Visonic panel by going in to and out of installer mode. Do not do any panel resets, the act of exiting installer mode is enough.
  • Wait for a couple of minutes for the panel to restart
  • Start HA.

Logger settings

If there are problems then set your logger: to output debug data to the log file for the visonic integration. You'll have to upload your log file to pastebin, dropbox (or another) and put a link in your post so I can get it. Also, give me a bit of a description as to what you have tried and what goes wrong, what do you see in the frontend.

In your configuration.yaml file do it exactly like this so I only get logged data from my Integration. You may have to comment out your existing logger: entry and replace it with this temporarily.

logger:
  default: critical
  logs:
    custom_components.visonic: debug
    custom_components.visonic.pyvisonic: debug
    custom_components.visonic.alarm_control_panel: debug
    custom_components.visonic.binary_sensor: debug
    custom_components.visonic.switch: debug
    custom_components.visonic.client: debug
    custom_components.visonic.config_flow: debug
    custom_components.visonic.create_schema: debug
    custom_components.visonic.__init__: debug

Other Useful Information

Tamper setting for the Zones

I’ve done some experimenting and I think there are 3 tamper values. The first is the Main Panel Tamper, this is an attribute of alarm_control_panel.visonic_alarm called Tamper (the panel sends this through in the panel settings PDU A7).

Each zone then has 2 Tamper values, a zone tamper and a device tamper (through the zone settings PDU A5 message). I think that the device tamper is the raw data and the zone tamper is more like a logical setting.

The Startup Control Flow

I have worked on the control flow for release 0.2.0 (instead of copying the control flow from other plugins used in other devices) and have altered it so it is more reliable for my panel, I believe that it removes some (or all?) of the timing dependencies. For those interested in the startup control flow.....

  • At Integration start, it checks the "Force Standard" user setting. If set it goes directly to Standard Mode and stays there.
  • If "Force Standard" is not set then it tries to Download the EPROM data from the panel.
    • If this fails immediatelly then it keeps retrying every 4 minutes.
    • If it fails part way through the download there is something more seriously wrong and it goes to Standard Mode and stays there.
    • The Download step itself takes about 40 seconds on my panel,
  • When EPROM Download succeeds is goes to Standard Plus mode.
    • I get Standard Plus Mode within a minute or so of starting HA.
    • I expect that most people will be happy to get it to Standard Plus mode.
  • It then starts trying to Enroll as a Powerlink device,
    • Trying every 4 minutes.
    • It can't try too often as the panel just blocks the communication, thinking that it's an attack I think, so 4 minutes seems OK
    • I get Powerlink Mode within 2 minutes of starting HA
    • Sometimes it fails the first time (fails to Enroll) and it works the next time around, so about 5 minutes after starting HA
    • For some older panel, you need to manually enroll a powerlink module in your control panel menu

In other words, the Integration continues to try and do the best it can and doesn't give up like previous versions. Previous versions attemped Powerlink enrollment (3 times) and if that failed did not then attempt to Download the EPROM. It now does it the other way around and keeps trying. If I get problems with it trying too often then I may need to limit it.