Paxton Net2, meet Slack.

December 2017 : As of recent versions of net2, the way SMS messages are sent has been changed, which breaks this hack, an update will follow. The advice below may still help you with other hard-coded SMS solutions.

This is my (somwhat hacky) attempt to make Paxton net2 talk to Slack, however the basic principles will work with a lot of hard-coded SMS solutions

I like Slack, I use it for work and more personal use - even the team behind this blog engine Ghost have their own slack team for their community, sharing information and providing support in a unique - but very effective way.

I also use the Paxton net2 system to control doors, and receive notifications by eMail when various things of interest happen. It would be so much easier to have these in a Slack channel, and would enable instant push notifications to iPhone.

Net2 API

Paxton net2 also has an 'API', but not a nice HTTP-based thing, it's a collection of cryptic functions in a language I don't understand (.net), written for an OS I avoid using (Windows).

There's a great collection of scripts by net2-solutions that use Python, but I don't really know - or have any desire to learn - Windows well enough to make daemons to connect to net2 and expose it in a sensible way (if someone does this, please, please share the source)

Built-in SMS

Paxton supports SMS out of the box, however they only support one provider - textanywhere.net - and choosing who to notify is cumbersome (if you've spent much time managing "Triggers and Actions" in Net2, you'll know what I mean)

However, short messages are exactly what I want in Slack, and it turns out there's a really easy way to achieve this in net2, as long as you don't currently use SMS.

Remapping Hosts

Most operating systems provide a 'hosts file', a simple way of hardcoding a hostname to an IP address, negating the need for a DNS lookup - this allows you to hijack traffic intended for somewhere else.

The net2 software uses a simple HTTP API to connect to the SMS provider, and makes a call to http://ws.textanywhere.net/ta_SMS.aspx to send messages.

By adding the following line to C:\Windows\System32\Drivers\etc\hosts, we can redirect this traffic to a server of our choice;

10.0.7.30 ws.textanywhere.net

In my case 10.0.7.30 is a Linux host on the local network (actually a Raspberry Pi, I use these for practically everything!) running a simple web server.

See what's being sent

If you're using this with net2, there is no need to do this, just see the example below which details the request format. You can also consult the API documentation of the SMS provider.

You could use Wireshark or similar, but sometimes the simplest means are the best. I configured the web server to send all requests to a simple PHP script as follows;

Unfortunately this particular provider uses an XML request in the body, a simpler API would use HTTP POST requests, so you could just use print_r($_REQUEST,true) instead of the stream_get_contents() function

Send a test message and you'll get a file in your /tmp directory showing the variables that you need to process later.

Configure net2

This is simple, just configure it as if it was an SMS, and put anything at all in the To line (we'll ignore this), rather than formatting a sensible message I've used the same format for every event, this makes it easier to parse later.

The script

On our server we need a simple ta_SMS.asmx script to receive the requests from net2, in my case I've used php so needed a simple .htaccess file containing the following;

<Files ta_SMS.asmx>
ForceType application/x-httpd-php
</Files>

This forces Apache to treat ts_SMS.asmx as if it was a php file (even though it has a .asmx extension)

The script itself can be quite simple (ours also takes advantage of the data and logs it to MySQL)

Try it!

Extending this

Slack's bots are incredibly powerful, you can write one to ask who's in the building, or if you've got a large campus, where someone was last seen.

Also, you can create rules so that if alarm events are received (e.g. door forced, alarm activation etc) they go into your company's #general room so someone can investigate.

net2 API

I really want to do more with the dedicated net2 API, if I could find a way to hook into that with a script in Python or Node that just passed all the events across into 0MQ or redis or something that'd be perfect, but I expect that there won't be much more development on net2 now that the new net10 is out.