Visonic Powermax and Powermaster Component

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 ?

OK @davesmeghead thank you for your reply
I will certainly test your proposition but when I will be on vacation, because I need times.
@olijouve, thank you for the link, but I check the URL and the project seems very old (2011 ?) and it required to flash the powerlink2 ?

I have uploaded version 0.3.5.1 to Github.

This release updates 0.3.5 from yesterday with better panel event log file processing.

To summarise the Retrieval and Processing of the Panel Event Log … here goes

There are 7 configuration.yaml items to configure the output of the panel event logs so please take a look at the Github page and read it carefully (and point out any mistakes I’ve made :slight_smile:)

The following represents my last test set of parameters

  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'
  panellog_reverse_order: 'yes'
  panellog_max_entries: 10

To retrieve the event log from your panel you need to call the service visonic.alarm_panel_eventlog

Please leave at least 60 seconds between subsequent calls to this HA service

For testing I’ve been using the Developer Tools - Services from the HA Frontend.

There are 3 main ways to process the panel log file events:

  1. XML File. The xml generation uses a jinja2 xml template file 'visonic_template.xml' so you can generate your own xml files in the way you want, including RSS, ATOM etc file formats.
  2. CSV File. Create a Comma Seperated Variable file
  3. HA Events on the event bus that you can include in automations etc

For XML, if you do not define your own jinja2 'visonic_template.xml' template file, the default file is part of the Component download in the custom_components/visonic directory. Please do not change this as when you update this Component your file will likely be overwritten. Copy this file and alter it. See the Github page for the possible locations of the 'visonic_template.xml' file.

Edit: The dictionary variable entries is passed in to the jinja2 xml file for processing. Take a look at the default file and you should see what I mean.

I have uploaded version 0.3.5.2 to Github, a few minor tweaks including the xml template.

Yes, it makes perfect sense. That said, here’s a potential barrier to making such a thing work. I can make an RSS template that works, and I’ve pared down the original version, which didn’t quite work because of some mistakes during editing the post. I’ve also made an HTML file for the table which works on its own. When I combine the two, they fail–likely because I’m not making an HTML that’s compliant to the RSS 2.0 requirements. Consequently, unless you or I can come up with the magic sauce for a compliant HTML piece, we shouldn’t expend much effort.

This link allows us to test the RSS XML content:

https://www.w3schools.com/xml/tryrss.asp?filename=rss_ex_title_link_description

This link allows us to check the HTML:

https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro

These two links capture my current state of progress:

https://pastebin.com/vPjKrvEd
https://pastebin.com/zKFNy0Qt

Thanks for humoring me. If I knew it was going to be so frustrating, I would’ve kept the idea to myself.:wink:

Haha yeah, that occurs to me sometimes after the event as well.

Try using this as your xml template

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
    <channel>
        <title>Visonic Event Log</title>
        <description>Event Log has {{total}} Entries</description>
        <link>https://github.com/davesmeghead/visonic</link>
        <item>
            <description><![CDATA[        
<html>
 <table>
        {%for entry in entries %}
  <tr>
  <td>{{entry.zone}}</td><td>{{entry.event}}</td>
  </tr>
        {%endfor%}
 </table>
</html>
            ]]></description>
        </item>
    </channel>
</rss>

Spacing and indentation seems to be important so be careful how you copy / paste

Just a note on this link, it looks like it can only be used for a small number of rows, if the test xml is too big it fails so make your test RSS xml small

I removed your HTML and pasted mine between the brackets. It almost works. I wonder if the HTML engine on the site is a bit ‘crippled’. It doesn’t do much with <table style="width:100%">.

Here’s the rendering:

image

Edit: FYI, this is what it looks like in a browser:

image
I’m encouraged, but I hope saying so doesn’t blacken any clouds. Can you try a pared down version of your HTML output?

Hi Dave. have tested with your suggested setting and a log is attached.

It has reduced the delay down slightly to maybe 45 secs. I triggered about 8 sensors during the walk around over about 10 mins but only about 4/5 show in home assistant.

https://www.dropbox.com/s/t8l07m7v6wa142s/log%20with%20new%20settings.txt?dl=0

Nah it’s not stable, i lost connection a couple of days ago and now i only reach standard mode.
If you would be so kind to take a look at my log, i would be very happy.
HA log visonic…standard mode.

Now im making my PM powerless again to see if i can reach powerlinkmode once again…

Edit: spelling as if I was drunk

I’m looking through the log now and I’ve only got about 40 lines in and I’ve spotted that there is no communication from your panel for the first 4 minutes or so. I send data but get nothing back.

For log line:

  • 18 to 21 it establishes a valid TCP connection to your gadget (ESP Link I think you said). This indicated that the problem is not with the TCP but it might still be network related (i.e. it doesn’t rule out network problems).
  • 24 to 33 it tries to trigger the panel to download the EPROM.
  • 34, this is 3 minutes later and the download timer has kicked in to force standard mode.
  • 47, this is when your panel sends its first piece of data
  • 79, this message from your panel indicates that Zones 1, 2, 3, 9, 10 and 11 have a battery low indication. But at that point in time (I didn’t ask the panel to send me the battery status) I do not know about any zones so I ignore the message. Although it looks like you have battery low issues this is also a minor bug when in standard mode so I’ve fixed it for the next release.
  • 172 and several more “Response Timer Expired”, a total of 27 of these in a 15 minute period . This indicates that communication to/from your panel is not reliable.
  • 160, 177 and 192 the panel sends the same information. Each time with a “Response Timer Expired” between them.

Going back to lines 24 to 29 there should be, at the very least, an acknowledge message back from the panel for the Exit command. This is the handle_msgtype02 line in the example below. This is the equivalent bit from Chris Jones log file (I hope you don’t mind but it’s from a PowerMaster panel and so Nicklas should see the same).

2020-01-10 16:36:59 INFO (MainThread) [custom_components.visonic.pyvisonic] [Start_Download] Starting download mode
2020-01-10 16:36:59 DEBUG (MainThread) [custom_components.visonic.pyvisonic] [pmSendPdu] Resetting expected response counter, it got to 0   Response list length before 0  after 1
2020-01-10 16:36:59 DEBUG (MainThread) [custom_components.visonic.pyvisonic] [pmSendPdu] Sending Command (Exit)    raw data 0d 0f f0 0a    waiting for message response ['0X3C']
2020-01-10 16:36:59 DEBUG (MainThread) [custom_components.visonic.pyvisonic] [pmSendPdu]          Command has a wait time after transmission 1.5
2020-01-10 16:36:59 DEBUG (MainThread) [custom_components.visonic.pyvisonic] [handle_msgtype02] Ack Received  data = 
2020-01-10 16:37:00 DEBUG (MainThread) [custom_components.visonic.alarm_control_panel] code format called *****************************
2020-01-10 16:37:00 DEBUG (MainThread) [custom_components.visonic.alarm_control_panel] code format number *****************************

To summarise, I still think that you have a communication problem, all the data doesn’t seem to be getting through. The question is, why don’t we get partial and fragmented packets? We always seem to get complete packets of data from the panel, it’s just periodically we miss out whole packets or the panel is not sending them.

Did you managed to take a look at my log? TIA

Yeah :slight_smile: been looking through it and previous logs. I’m looking for a pattern in the B0 messages, something that I could use to make it better. Nothing so far though :frowning:

I copied the algorithm (to request 2 subsequent B0 3/4 in the space of 3 to 5 seconds and look at the differences in the values where there’s a PIR sensor) from another plugin from a different system and they said at the time on their forum it didn’t work well so they gave up a few years ago. This algorithm just seems too convoluted and complex, what would a real hardware powermax3 do with this?

I think that Visonic have added some complex algorithm to the production/consumer B0 messages, specifically for a PowerMaster connection to a powerlink3. Visonic couldn’t change any of the existing message as that would mean all previous alarm systems would need a firmware update so they’ve just made the B0 more cryptic. Of course, I’m postulating this, I can’t prove or confirm this in any way.

In hexadecimal, the states of the sensors go between 04, 08, 11 and 15. There don’t seem to be any other values. There doesn’t look like any pattern to this either. In binary these are,
04 00000100
08 00001000
11 00010001
15 00010101

Again, I can’t spot a pattern.
Also, these values change in all sensors, not just the motion (PIR) related ones and the values don’t coincide with A5 messages that would normally be associated with sensors being triggered.

So, still working my way through, I haven’t quite given up yet :smile:
D

EDIT:

Forgot to mention, the 45 seconds might have something to do with “motion_off” being set to 45, could be a coincidence but you could try changing it to see if it makes a difference