Visonic Powermax and Powermaster Component

Thanks based on your idea I ended up simply creating a new sensor with the zone friendly_name:

sensor:
  - platform: template
    scan_interval: 5
    sensors:
      visonic_exception_count:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Comm Exception Count') | int }}"
        friendly_name: 'Panel Exception Count' 
      visonic_panel_status:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Status') | title  }}"
        friendly_name: 'Panel Status' 
      visonic_panel_mode:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Mode') | title  }}"
        friendly_name: 'Panel Mode' 
      visonic_panel_last_event:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event') | title }}"
        friendly_name: 'Last Event'
      visonic_panel_alarm_status:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Alarm Status') | title }}"
        friendly_name: 'Panel Alarm Status'
      visonic_panel_trouble_status:
        value_template: "{{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Trouble Status') | title }}"
        friendly_name: 'Panel Trouble Status'
      visonic_panel_last_event_zone:
        value_template: >
          {% set zones_friendly_names = [
            state_attr(states.binary_sensor.visonic_z01.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z02.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z03.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z04.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z05.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z06.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z07.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z08.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z09.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z10.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z11.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z12.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z13.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z14.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z15.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z16.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z17.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z18.entity_id,'friendly_name'),
            state_attr(states.binary_sensor.visonic_z19.entity_id,'friendly_name')
           ] %}
          {% if 'Zone' in state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event') %}
            {% set zone = state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event') .split(' / Zone ')[1]|int - 1 %}
            {{ zones_friendly_names[zone] }}
          {% endif %}
        friendly_name: 'Zone Friendly Name'

That way I can use the zone friendly name of the last event where I want.
I am not sure if there is a cleaner way to achieve this because it seems that the array with all the friendly names are always created for each update.
I suppose I would need some kind of global variable, but it doesn’t seem to be easy (I am really starting with Home Assistant, YAML and template).
If somebody has a better idea…

I’ve tidied up the code to support the manual enroll of the Powermax+ and Powermax Pro panels and uploaded it to Github as version 0.3.5.8

Any problems then as usual, let me know here :smile:

If you need me to create a new attribute then please describe what you want it to do

Hi Dave. All is well. I think we can conclude your adjustments fixed the issues. Thanks for the great help.

The core idea is to communicate clearly in case of alarm what exactly happened.
The current ‘Panel Last Event’ gives the zone number but it is not really usable, as it is just a number.
If I am out of town and the alarm triggered, I would like to call a neighbor or the police to come to investigate a particular zone.

We have perhaps 2 options:
A) an attribute which contains the friendly name of the zone which is specified in the ‘Panel Last Event’
=> It will immediately fulfill the use case but not much more

B) 2 new attributes:

  • one having the number (as integer) of the zone which is specified in the ‘Panel Last Event’
  • one having the array of visonic sensors
    => So I should be able to get the zone friendly_name of the last event by using something like visonic_sensors[last_even_zone].friendly_name but it could also be useful for other purposes

Let me know if something is not clear.

Thanks

I’ve just uploaded a new version 0.3.6.0 to Github to add an attribute called “Panel Last Event Data”. It’s quite complex when you see it but hopefully you can use it somehow :smile:

The “Count” Value
The Panel State Data (A7) that the panel sends contains between 1 and 4 sets of panel state at a time. On my Powermax Pro Part I only get 1 at a time but I noticed that you get more than 1 sometimes. This is the “Count” value. The 4 arrays then contain the up to 4 message data.

The 4 arrays are
“Type” array matches the “Mode” array. The type is the integer and the mode is the string. Note that the type will be different between powermax and powermaster panels so be careful.

“Event” array matches the “Name” array. The event is the integer and the name is the string. Note that the event will be different between powermax and powermaster panels so be careful.

“Zone” and “Entity” are only set if there is a specific zone referred to in the 1 to 4 message data. If “Zone” is 1 or more then the “Entity” is valid. You don’t need to check “Count” if you use “Zone” (“Zone” will always be 0 if “Count” is 0).

“Tamper”, “Siren” and “Reset” represent the panel states.

And finally, “Time” is the time :slight_smile:

Note also that this data is also sent as part of the event on the HA event bus so it can be used either as a state or an event. Only when the condition value in the event data is set to 2 or 3 though.

1 Like

Thanks. That’s a lot of information now available. I can surely easily get the friend name of the zone in case of event now. Thanks.
However I am confused by the Count value. Does that mean we can have 4 modes or 4 events sent at the same time?
In that case, to which event is related the Zone/Entity?

I am also not sure if I understand your last note (conditional value). Can you perhaps give an example?

Thanks a lot

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 this latest release includes the detailed panel state data. I refer you to the wiki here

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 this alarm_panel_state_update and click “start listening”. Then do things with your alarm, trigger sensors, arm and disarm, you should see what I mean.
Oh yeah, it was a typo in my previous post, it should be “condition” and not “conditional”.

The Alarm Panel sends through an A7 PDU for panel status. This contains between 1 and 4 pieces of information about the state of the alarm panel. There is only more than 1 if something happens at exactly the same time, like the alarm being triggered and the siren sounding, then it also might contain the sensor data that triggered it. I say might because it all depends on timing.

So to answer your question, yes there can be up to 4 type/event combinations at the same time. However it is unlikely that there will be more than 1 sensor reported at exactly the same time in the same A7 message, I’ve never seen it in all the logs I’ve looked at.
Also, if there were to be multiple zones reported in the same A7 PDU, the “Zone”, “Entity” information represents the last one of the 4 and puts info in the HA log file “Oops - multiple zone events in the same A7 Message”. You would get all 4 in the arrays anyway :slight_smile:

Hope all this makes sense but please ask if you have more questions.

OK I think I got it.
What values can take the condition value in the Event data though?
And what are the associated meanings?
For instance, see a lot of condition value 1 but I am not sure what that means.
Same for 2,3,4,etc.
Thanks

Check out the wiki link and note 1, it tells you what the number represents
D

I’ve had a go at updating my own automations, try this

- alias: 'Alarm Panel 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:
      title: "Alarm detected"
      message: "Sensor that triggered this alarm was: 
                {% set ety = trigger.event.data['Entity']|string %}
                {% if ety == 'None' %}
                    Undefined
                {% else %}
                    {{ ety }} with the friendly name {{ state_attr(ety, 'friendly_name') }}
                {% endif %} "

The event condition 3 means that the alarm has been triggered, I refer you to the wiki here
The action puts a notification in to the HA Frontend so click on Notifications to see it.

Note: I deleted my previous post as I had a condition in to test the “Zone” being greater than 0 but if the “Event” string is set correctly then the “Zone” will always be greater than 0 so there’s no point in having the condition test (I can just test for ‘None’).

Hello @davesmeghead,

I tried with a Flood and it seems that it is not being detected by your trigger:
https://pastebin.com/MT2ErAUu

However it is detected by mine (see below), so this is not an issue.
I think this is because a Flood is not considered as an alarm and is not triggering the siren.

Anyway I manage to use your new attribute in the message of my automation without any issue:

  - alias: 'Alarm Triggered'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.visonic_panel_alarm_status
      - platform: state
        entity_id: sensor.visonic_panel_trouble_status
    condition:
      condition: template
      value_template: "{{ trigger.to_state.state != 'None' }}"
    action:
      - service: notify.email_notify
        data:
          title: 'Alarme déclenchée : {{ states.sensor.visonic_panel_last_event.state }}'
          message: >
            {{ states.sensor.visonic_panel_status.attributes.friendly_name }} : {{ states.sensor.visonic_panel_status.state }}
            
            {{ states.sensor.visonic_panel_mode.attributes.friendly_name }} : {{ states.sensor.visonic_panel_mode.state }}
            
            {{ states.binary_sensor.visonic_panel_ready.attributes.friendly_name }} : {{ states.binary_sensor.visonic_panel_ready.state }}
            
            {{ states.binary_sensor.visonic_siren_active.attributes.friendly_name }} : {{ states.binary_sensor.visonic_siren_active.state }}
            
            {{ states.sensor.visonic_exception_count.attributes.friendly_name }} : {{ states.sensor.visonic_exception_count.state }}
            
            {{ states.sensor.visonic_panel_last_event.attributes.friendly_name }} : {{ states.sensor.visonic_panel_last_event.state }}
            {% set visonic_panel_last_event_data = state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event Data') %}
            
            Last Event Time : {{ visonic_panel_last_event_data['Time'] }}
            {% if visonic_panel_last_event_data['Zone'] > 0 %}
            
            Last Event Zone: {{ visonic_panel_last_event_data['Zone'] }}
            
            Last Event Zone Friendly Name : {{ state_attr(visonic_panel_last_event_data['Entity'], 'friendly_name') }}
            {% endif %}
           
            {{ states.sensor.visonic_panel_alarm_status.attributes.friendly_name }} : {{ states.sensor.visonic_panel_alarm_status.state }}
            
            {{ states.sensor.visonic_panel_trouble_status.attributes.friendly_name }} : {{ states.sensor.visonic_panel_trouble_status.state }}

It also seems that the ‘Panel Siren Active’ attribute is not reporting the siren in case of Fire. But I am not sure: I have to test this week again while activating the logs.

Thanks a lot for your support.

OK, as long as you’ve got it working. There are many ways to achieve the automation.

Yes, that’s correct. The Component generates an event with the condition set to 2 and not 3. See line 56 in the log file you uploaded. It means that Z19 (your flood sensor) was triggered.

You’re correct. Does your siren sound when it is triggered by a fire sensor? If you can mimic it and upload a log file I could check which messages are sent and include it in the siren indication in HA.

Ok thanks for the hints.
I have then decided to use 2 automations.
One for Panel issues (all conditions above 4):

  - alias: 'Alarm Panel Issue'
    initial_state: true
    trigger:
      platform: event
      event_type: alarm_panel_state_update
    condition:
      condition: template
      value_template: "{{ trigger.event.data.condition in [4,5,6,7,8,9,10] }}"

One for standard alarm:

  - alias: 'Alarm Triggered'
    initial_state: true
    trigger:
      - platform: state
        entity_id: sensor.visonic_panel_alarm_status
      - platform: state
        entity_id: sensor.visonic_panel_trouble_status
    condition:
      condition: template
      value_template: "{{ trigger.to_state.state != 'None' }}"

For instance if I disconnect the Ethernet cord, the first automation is triggered by Condition 9.
If I simulate a flood, the second automation is triggered.
I will try to simulate a Fire this week to get the debug log. But yes the panel is definitely using the siren in case of Fire.

The final issue I have is being unable to Arm the panel because of any issue (for instance because a door is opened).
I have opened a door and tried to arm away the panel:
https://pastebin.com/F9KsXwRR

When I click on the arm away button on the frontend, nothing is happening (no visual indication that something is wrong, it just does not result in anything).
Is there some way to use an automation there to notify why it doesn’t work (for instance which zone is opened, if the panel is not responding, etc.) ?

The use case if to automatically arm the alarm at night or during the day. In some case it won’t work (if a zone is opened) and I would like to send a notification with the precise reason.

Thanks again for your support.

I’ve been looking at your log file for ages and I’m really confused. It looks like no messages are getting through to the panel but we are receiving and decoding messages from the panel. This in itself is confusing as I didn’t think that could happen. Can you restart HA so I get a log file from the beginning and try what you did again please. Thanks.

Also, you’re missing condition 0 from your list :slight_smile:

At least for open zones :

Ok here is the log when I trigger a fire:
https://pastebin.com/NJgrBFDc

The Siren is reported as being “Off”

Here it is again:
https://pastebin.com/4tAYcPKP

I opened the door and tried to Arm Home and Arm Away. Nothing is happening and nothing is reported.

OK, I’ve looked at this one first :slight_smile:
You need to look at the “Panel Ready” attribute of the panel entity. If it is “No” then you cannot set the alarm, one of the sensors is stopping it. The panel doesn’t directly tell me why, the only thing I could do is walk through them all and find the 1 or more that are “open” (but there could be other reasons that I’m not aware of). You could write an automation to step through the sensors and check for each being open or closed as part of your message.

Ok so I suppose the automation should look like this:

  1. Everyday at 11pm, check the Panel Ready attribute to be OK
  2. If this is OK call the service alarm_control_panel.alarm_arm_home, otherwise send an error notification
  3. After 1mn, check that the panel status is armed
  4. If it not armed, then send an error notification

In the error notification, I can loop through the zone to check if one is preventing the alarm panel to be armed.

I don’t know if there is a better way to handle this ?
Otherwise I’ll go with that.

Thanks