Visonic Powermax and Powermaster Component

I’ve just updated the event log processing and uploaded version 0.3.4.15 to Github, please make sure you’re using this new version for the following explanation.

To trigger the retrieval of the event log, please call the service visonic.alarm_panel_eventlog with an optional code parameter that is only needed when in Standard Mode. This gets the panel log and passes it through one at a time to __init__.py line 189. This simply dumps it to the log file at the moment. I get a total of 250 log entries but your panel may be different.

In __init__.py line 189. visonic_devices is of type LogPanelEvent. LogPanelEvent is available at pyvisonic.py line 872 but essentially consists of the variables current, total, partition, time, date, zone and event.

I’m not keen to start adding parsers and filters as different users will want different things. If you want to filter it then, as I said before, I can easily create an HA event from the data and your automations, scripts etc can decide what to do. The only concern I have, and why I haven’t done it, is pushing through 250 events (for my panel) on to the HA event bus, would this be OK? I guess that I could give it a try :smile: and see what happens

I don’t have a GSM module so it’s difficult to test, I read it from the EPROM and the address value I use was obtained from another Component so I can’t verify that it is correct.

Is it a worthwhile idea to convert the strings to XML, and publish the text to a file for an RSS card to view ?

Well I gave it a go, it wasn’t that difficult to implement an event in HA, the code to add it is only a few lines. In __init__.py line 187, you should see what I mean.

        elif type(visonic_devices) == visonicApi.LogPanelEvent:
            # This is an event log
            _LOGGER.info("Panel Event Log {0}".format( visonic_devices ))
            # Fire event visonic_alarm_panel_event_log
            hass.bus.fire('visonic_alarm_panel_event_log', {
                'current': visonic_devices.current,
                'total': visonic_devices.total,
                'date': visonic_devices.date,
                'time': visonic_devices.time,
                'partition': visonic_devices.partition,
                'zone': visonic_devices.zone,
                'event': visonic_devices.event
            })
     

I have 2 web browser pages open, one on “developer tools, services” and the other on “developer tools, events”. I set it to listen for my new event visonic_alarm_panel_event_log and triggered the service. On the events page it took about 45 seconds for all 250 events to come through.

I can do, do you have a preference on xml file name, format and file location? There are 2 numbers in each event “current” and “total”. When current==1 I can create a file and then when current==total I can close it. I could then generate a single event in HA when the file is closed.

What about during the file writing, would that cause any problems as it takes tens of seconds?
Edit: Scratch that question, I can create the xml structure in memory and write it all out at the end. The RSS card would still need to reload the file though.

Hi Dave. Attached is a log with a few motion events. It is still about 30- 60 seconds from motion to actually showing in home assistant. I triggered about 10 sensors but only about 4 come through to home assistant.

At the moment the setting I have for B0 are…

b0_enable_motion_processing: ‘yes’
b0_min_time_between_triggers: 2
b0_max_time_for_trigger_event: 1

I get more motion events using the above setting. But I still get the 30- 60 sec delay no matter what I set it at.

Could not upload to pastebin as its too large so will add to dropbox

https://www.dropbox.com/s/8z5u4qw6c08pwa8/log2.txt?dl=0

Well, I have no immediate need; it was a suggestion for @barsamgr’s request.

For the format, I’d have to look at examples of the RSS files I’ve been using for an ecobee feed. I’ve been using two HA components: the Freedparser integration and the the List Card plugin.

https://community.home-assistant.io/t/lovelace-rss-feed-parser-plugin-list-card/64637/

In the meantime, here’s a link to a format template:

https://en.wikipedia.org/wiki/RSS#Example

I’m guessing the feed can be a local file. The location would be something like “/www/community/visonic/rss/file_name.xls” which would be referenced as “/local/community/visonic/rss/file_name.xls”.

Is the www directory exposed to the network via a non-routable local IP address (e.g. 172.x.x.x)? If so, a browser with an RSS add-on might be an easier and more elegant way to view the data. The Firefox add-on I use, Feedbro, keeps a running history of the feed, although I’ve been using the ATOM formatted content. I’m not sure RSS can do that by design, or if it’s a feature of the add-on.

I’m not sure what triggers a reload, but there is a mechanism for it. New content automatically replaces the last feed content, but the referenced URL for Feedparser and Feedbro is static.

Me neither, I’ve got it to the point now where I think I’ll just add some configuration.yaml parameters. I can generate HA events and/or generate an xml file.

We can make the filename (including the location path) a config parameter and therefore can be put wherever the user wants it. The current working directory seems to be the HA config directory. I just created an xml file like this open("visonic_event_log.xml", "wb") and that’s where it appeared.

This is the proposed xml file content (using my panel logs)

<?xml version='1.0' encoding='UTF-8'?>
<data>
  <log>
    <event partition="1" current="1" total="250" date="10/01/2020" time="13:00" zone="Fob  01">Disarm</event>
    <event partition="1" current="2" total="250" date="10/01/2020" time="07:43" zone="Fob  02">Arm Away</event>
    <event partition="1" current="3" total="250" date="09/01/2020" time="20:21" zone="User 01">Disarm</event>

.... 244 more i.e. current 4 to 247 inclusive. Sometimes partition="Panel"

    <event partition="1" current="248" total="250" date="12/10/2019" time="17:30" zone="Fob  01">Disarm</event>
    <event partition="1" current="249" total="250" date="12/10/2019" time="14:29" zone="Fob  01">Arm Away</event>
    <event partition="1" current="250" total="250" date="11/10/2019" time="12:52" zone="Fob  01">Disarm</event>
  </log>
</data>

The possible values in the body (“Disarm” etc) are contained in pyvisonic.py line 293 in pmLogEvent_t

The possible values in the zone (“Fob 01” etc) are contained:

  • for PowerMax in pyvisonic.py line 377 in pmLogPowerMaxUser_t
  • for PowerMaster in pyvisonic.py line 420 in pmLogPowerMasterUser_t

Me neither, but again I think I’ve gone as far as I can. I can update the format / structure of the xml file in future but that’s risky if someone is already using it. So, comments on the xml structure soon please :slight_smile:

Oh that’s cool, thank you @davesmeghead !
Would i ask too much saying that both CSV and XML would just be perfect. CSV can be easily been read by every one when there’s not much fields.
I haven’t read last 7 posts yet, it might have been already asked for or even already done.
Anyway thanks again for that.

The only way that I know of doing this with a PowerMaster is when then panel sends:

  • message 3/57 - I assume that this means that the panel has activated something
  • I then ask what that is
  • message 3/4 - contains the sensor data, including PIRs (or maybe only PIRs I’m not sure)

This takes more than a second back and forth. I then need 2 of these sequences to happen to look at the differences.
Also, with your panel we’re getting the response back but in more than 1 second and they’re not being paired together in the code.

Because of these 2 issues, in other words, it looks like b0_max_time_for_trigger_event needs to be set to at least 3 seconds. It was a good test to see how quickly the panels react, but they’re not that quick. So can you set this to 3 seconds please. I also in my code assume that b0_min_time_between_triggers is larger than b0_max_time_for_trigger_event so can you set b0_min_time_between_triggers to something like 5 seconds.

Again, can you please give it a try and upload another log file. It has taken me quite a while to go through this one but they are useful.

OK, I’ve just implemented a Comma Seperated Variable (CSV) file, like this

1, 250, 1, 10/01/2020, 13:00, Fob  01, Disarm
2, 250, 1, 10/01/2020, 07:43, Fob  02, Arm Away
3, 250, 1, 09/01/2020, 20:21, User 01, Disarm
.......
248, 250, 1, 12/10/2019, 17:30, Fob  01, Disarm
249, 250, 1, 12/10/2019, 14:29, Fob  01, Arm Away
250, 250, 1, 11/10/2019, 12:52, Fob  01, Disarm

Nothing uploaded to Github yet :slight_smile:
I need to add some config parameters to enable/disable them

Impressive,@davesmeghead you‘re just too good to us and so fast implementing every of our wishes ! would be even more perfect with field names on first header line :wink:

If anyone is still interested in a local RSS feed, I have some inputs on how to create the RSS version of XML. This would be useful for viewing log text in a card on the Overview page. Otherwise, what’s already implemented can work well enough.

While i’m on with it i would rather get it right so please fire away. If they are too different I can create a unique file output just for RSS.

I finally received my Powermax Pro and my USR-TCP232-E2.
I am still waiting for the breadboard and the Dupont cables to try to connect to Home Assistant.
Where have you put the USR-TCP232-E2 in the panel to make it easy to operate ?
It seems that I will have to make some holes in the panel ?

Thanks !

Before I get ahead of my skis, here are some relevant links:

The first is the specification for RSS 2.0. It’s the version with which I have the most experience as a content consumer. Note I did not say “publisher.” I’m navigating the spec as I type this reply. The second is for <item>< description>, the data table we’re trying to view.

http://www.rssboard.org/rss-specification
http://www.rssboard.org/rss-profile#element-channel-item-description

The overall template is pretty straightforward. There are options that we might want to use later, but are not necessary now. One of these is ‘ttl’, which is time to live. The definition is in the spec. Another is ‘guid’, which is a unique identifier to allow the RSS reader application to determine if the most-recently-posted item is being viewed for the first time.

So, here’s the template I cobbled together:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
 <title>Visonic Event Log</title>
 <description>Event Entries</description>
 <link>'/local/community/visonic/rss/visonic_event_log.xml'</link>  # I don't know how a file path would be treated by an RSS reader app.  
 <pubDate>Fri, 10 Jan 2020 03:05:29 -0500</lastBuildDate>  #Example publish date, eg file create date/time.

 <item>
  <title>Log</title>
  <description>Insert column-formatted text here</description>  #Formatted using HTML without child elements.
  <link>http://www.example.com/blog/post/1</link>  #You might put in the GitHub link.
  <guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>  #optional
  <pubDate>Same as above unless each string is listed as separate item</pubDate>
 </item>

</channel>
</rss>

Note: I’ve commented some lines with “#”; these comments should be stripped from the template. Others use placeholder text which should be changed as described.

I’ve made some guesses for element content based upon other RSS files I’ve seen. The one that I have not defined is the <item><description>. Since the log data is being presented as a table, the requirement is to use HTML to properly render the object. I’d have to dig deeper to find the appropriate tags for a table.

I envision two ways of presenting the table. One makes the whole table a single object. The other way would be to create a separate <description> for each time-tagged <item> using the <pubDate> for each time tag. I think the first method would be easier. Moreover, time can be rendered per our (or Dave’s) preference.

So, is this sufficiently confusing?

Hi Rob,
I have a proposal that I’ve cobbled together and I could do with some advice. I’m proposing to use the jinja2 python library to create an xml file. jinja2 is available on pypi so we should be able to use it in HA.
I would not need to know the format of an RSS file in my proposal. The user (you) could create a template file which jinja2 fills in for you.

So what happens. The user (you) creates an jinja2 template file such as this:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <author>Author's name</author>
    <title>Feed title</title>
    {%for entry in entries %}
    <entry>
        <title>Partition {{entry.partition}}</title>
        <link href="{{entry.current}}"/>
        <content type="html">{{entry.date}}</content>
    </entry>
    {%endfor%}
</feed>

This is the content of feedtemplate.xml in the example code below.

jinja2 has variables, for example {{entry.partition}} so I provide the data for entries and each entry has the alarm panel attributes: current, total, partition, date, time, zone and event

My test code looks like this:

import jinja2
from jinja2 import Environment, FileSystemLoader

alarmstate = [
    { "partition":"1", "current":"1", "total":"250", "date":"10/01/2020", "time":"13:00", "zone":"Fob  01", "event":"Disarm"},
    { "partition":"1", "current":"2", "total":"250", "date":"10/01/2020", "time":"07:43", "zone":"Fob  02", "event":"Arm Away"},
    { "partition":"1", "current":"3", "total":"250", "date":"09/01/2020", "time":"20:21", "zone":"User 01", "event":"Disarm"}
]

file_loader = FileSystemLoader('.')
env = Environment(loader=file_loader)
template = env.get_template('feedtemplate.xml')
output = template.render(entries=alarmstate)
print(output)

When I execute the python code it produces this as its output:

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <author>Author's name</author>
    <title>Feed title</title>

    <entry>
        <title>Partition 1</title>
        <link href="1"/>
        <content type="html">10/01/2020</content>
    </entry>

    <entry>
        <title>Partition 1</title>
        <link href="2"/>
        <content type="html">10/01/2020</content>
    </entry>

    <entry>
        <title>Partition 1</title>
        <link href="3"/>
        <content type="html">09/01/2020</content>
    </entry>

</feed>

I know that the output content isn’t correct html but I’m just showing you an example of how it could be achieved.

In this way I don’t need to know the structure of the xml output file, that structure is in the template that you create.
I hope this makes sense :slight_smile:

I have a similar setup and I didn’t make holes in the panel. Just fix the USR gadget somewhere that has enough space and either mount or tape it in place.
Edit: I’m not sure what you mean by “easy to operate”. Once it’s setup you don’t need to touch it anymore

Hi,
I have a powermax-pro with a powerlink 2 . I wonder if i can use this powerlink component to control my alarm with HA. It seems that you use a custom USB or USB/ethernet component to control the alarm, whereas the powerlink 2 is a visonic component for the powermax-pro that implements a web server and requires user account and password to connect.
I also use JEEDOM, a french home automation software based on php, that has a plugin to interface with the web server of the powerlink 2. As I move to HA, I wonder if I can find a HA component for the powerlink 2, because even if the interface is very old, the reliability of the alarm is extraordinary.
Thanks !

OK so here goes…
To use this component you would need to remove your powerlink2 device from the panel. Since you’re using a powerlink2, I assume that you have a wired ethernet cable to your panel from your router.

You would need to buy:

  1. A USR-TCP232-E2 here, the same can be found here and here. It costs around £20 or $20.
  2. You would also need to buy either:
    • an IDC 10 pin ribbon cable like this. You would cut one end of the connectors off and use the correct 4 cables on the USR-TCP232-E2.
    • Use 4 individual wires. Buy Female/Female Jumper Wires like this and you can just push on the wires, no soldering :slight_smile:

You then wire it together, the USR-TCP232-E2 uses 3.3 volts and the panel provides 3.7. I admit that I just wired mine in and it works (I also have a PowerMax Pro) but you should probably convert the voltage or step it down with a diode that has a 0.4 voltage drop.

I realise after writing this, it sounds complicated but it isn’t really.

There may be an HA Component that interfaces with the powerlink2, you would need to search.

1 Like

@davesmeghead have you already read this ?
http://voksenlia.net/powerlink/

Would it worth giving it a look with @mbuffat to gather more technical informations before he might change its integration ?