DSC -> EVL-3(4) -> Alarmserver -> Smartthings

There are a million threads about this, and I figured I should start my own. I’ve compiled code from 3-4 people here and will give them credit. This set up allows arm/disarm via local LAN so you do not have to worry about https, security, and port forwarding. It creates all devices, you only need device types for contact, motion, smoke, and co2. Very simple, and easy. If you have a raspberry pi you can host alarmserver on it and have this running much much quicker and easier than any other dsc integration method.

This is from @sanity, @xero, @ethomasii, @jtt, @rfish8u, @mattmartz, and countless others I"ll name as I remember. If you’re experienced in setting this up you can skip directly to the devices, smartapp, and alarmserver and be good to go. For new users, view the advanced readme for how to set up.

Here are my files, along with stolen readme’s of @xero and @sanity. I did it this way because as they change/move/upgrade/edit I wanted to ensure i saved the version I was currently on and using.

(removed until my dsc is back online)

You can see all of that is a duplicateof @xero repo https://github.com/LXXero/DSCAlarm

This method includes all fault, zone bypass, switches that can be used in routines, night, instant, reset, chime, etc etc, every feature envisilink supports.




10 Likes

Interesting… I am using alarmserver from @ethomasii for long time and nice to see that you have implemented arm disarm buttons. Was looking for that long time to integrate with SHM.

question - i see motion sensor is commented out. I was wondering if you are still testing motion sensor.

it looks like you can just uncomment out the motion sensor and use that device type.

originally i commented out all the other sensors from the smartapp because when i installed it, it was telling me i must choose motion, lock, and other sensors. so i couldn’t get past the authenticate page. once i commented out things i didn’t actually have, it let me install the app.

the edits from rfish8u came from arm and stay switch types. those do the local hub action.

Would this also work for a Honeywell device? I get the same issue I get with all the other implementations. Can’t login due to this… first line on a connect is “Login:” and the first thing this does is try to convert input[:3] to an int. You can’t convert Login to an int. If you telnet directly to 4025, does it prompt you for login?

       if input != '':
        for client in CONNECTEDCLIENTS:
            CONNECTEDCLIENTS[client].send_command(input, False)

        code=int(input[:3])
        parameters=input[3:][:-2]
        event = getMessageType(int(code))
        message = self.format_event(event, parameters)
        alarmserver_logger('RX < ' +str(code)+' - '+message)`

2016-01-21 15:37:20 Alarm Server Starting
2016-01-21 15:37:20 Currently Supporting Envisalink 2DS/3 only
2016-01-21 15:37:20 Tested on a DSC-1616 + EVL-3
2016-01-21 15:37:20 and on a DSC-1832 + EVL-2DS
2016-01-21 15:37:20 and on a DSC-1864 v4.6 + EVL-3
2016-01-21 15:37:20 Envisalink Proxy Started
2016-01-21 15:37:20 Connected to 192.168.1.18:4025
error: uncaptured python exception, closing channel <main.EnvisalinkClient connected 192.168.1.18:4025 at 0x7fbde5ce2098> (<type ‘exceptions.ValueError’>:invalid literal for int() with base 10: ‘Log’ [/usr/lib/python2.7/asyncore.py|read|83] [/usr/lib/python2.7/asyncore.py|handle_read_event|449] [/usr/lib/python2.7/asynchat.py|handle_read|158] [./alarmserver.py|found_terminator|250] [./alarmserver.py|handle_line|282])
2016-01-21 15:37:20 Disconnected from 192.168.1.18:4025
2016-01-21 15:37:20 Connection failed, retrying in 10 seconds
^CCrtl+C pressed. Shutting down.

Thanks! I’ve been looking for an up-to-date DSC alarm-to-ST connection. Everything else I found was a couple of years old.

I’m really new at this, so please forgive the questions…

When I enter the URL in the first step (using the client_ID generated from the smartapp), I get the authorization page, select my hub from the drop down, check all of the boxes to allow the endpoint to control my existing switches and contact sensors, then when I click the authorize button, an error message says “Please select at least one device to authorize”. Do I need to add device related to my alarm system first (door sensors, window sensors, etc…)?

Thanks in advance for your help.

hmm, maybe try another browser? smartapp works fine for me. also read kent holloways oauth process, mine is mostly just notes for me to remember the steps.

decided to give this code a try, I was using a combination of khalloway and the original alarmserver by juggie, this is definitely a lot different…

I noticed something a little funny with how it reports Away / Stay status. It seems that an event “656” is triggering stay and “652” triggers away, but this makes no sense because 656 is just the exit delay in progress, and that can happen during away or stay, so it’s not a useful indicator of status. I ended up changing some code around to properly report status, now when I’m in stay mode, “away” mode shows off and “stay” mode shows armed, or vice versa when I’m in away mode. I wonder if these can just be combined into a single switch or something kind of like that DSC command center 2?

                    #Exit Delay, not stay mode.
                    #elif str(code) == "656":
                    #        try:
                    #                response = urllib2.urlopen(str(self._config.ALARMSTAY))
                    #                html = response.read()
                    #                alarmserver_logger(str(self._config.ALARMSTAY))
                    #        except:
                    #                alarmserver_logger("Failed to connect to SmartThings")
                    #Alarm Armed
                    elif str(code) == "652":
                            if message.endswith("Away"):
                                    # Turn off stay and turn on away
                                    try:
                                            response = urllib2.urlopen(str(self._config.ALARMOFF[2]))
                                            html = response.read()
                                            alarmserver_logger(str(self._config.ALARMOFF[2]))
                                            response = urllib2.urlopen(str(self._config.ALARMAWAY))
                                            html = response.read()
                                            alarmserver_logger(str(self._config.ALARMAWAY))
                                    except:
                                            alarmserver_logger("Failed to connect to SmartThings")
                            elif message.endswith("Stay"):
                                    # Turn off away and turn on stay 
                                    try:
                                            response = urllib2.urlopen(str(self._config.ALARMOFF[1]))
                                            html = response.read()
                                            alarmserver_logger(str(self._config.ALARMOFF[1]))
                                            response = urllib2.urlopen(str(self._config.ALARMSTAY))
                                            html = response.read()
                                            alarmserver_logger(str(self._config.ALARMSTAY))
                                    except:
                                            alarmserver_logger("Failed to connect to SmartThings")

I also feel like the whole way that URLs are being handled should get redone, we should just be able to use a access token variable and have the URLs filled in for us…my motion sensors actually needed a slightly different url as well, it was “motionsensors” instead of “contactsensors” and you have to use “active/inactive” as the command to send.

Thanks. That’s all beyond my skills though. Remember the evl supposedly always reports stay status until you open a door during exit delay. I don’t have a link for that but remember reading something like that. I’m just a user here not a coder so I have to hack everything up just to get it to work usually.

Hmmm, in my testing it definitely correctly reports away/stay status regardless of opening a door. I wonder if this behavior varies depending on the panel you have? I just upgraded myself from a PC1555 to a PC1864 as I wanted more zones, but i honestly can’t remember if the PC1555 was any different…I’m using an EVL-4, if that makes any difference.

From what I can tell it’s not an official status code - it reports code 652 for both. It’s actually a parameter it passes along with the code, and it generates a message that’s something like “Partition 1 Armed Stay” from that parameter. It only puts the away/stay status in the message and the current code never does anything with that information otherwise. So my update above is looking at the message and checking if it ends with “Stay” or “Away” and it then it sends the “off” url for the opposing mode, and the “on” url for the mode you selected. this provides a way to tell if you’re in stay or away mode - as the opposing mode will be “disarmed” and the chosen mode will be “armed” It’d probably by better to use the parameter directly, but i don’t think it gets passed along in the current code.

I feel like there’s gotta be a way to turn all this into just a single panel instead of two separate panels for stay/away though…I’m still somewhat new at smartthings code - I’m a little bit more familiar with python so I am able to work on alarmserver a little. I’d really like to re-do the URL handling in the config file and make it so you don’t have to completely fill in the URLs anymore, just specify the zone deice tokens and whether it’s motion, contact, or smoke, and the zone name. Maybe if I find some time this weekend…

i think i’m gonna try to see if i can get alarmserver to update the panel here by JTT which has arm/stayarm/disarm already:

if i can make that work, i can ditch the separate stay/away panels and i’ll pretty much have almost everything i need (though i think this version of the dsc integration is still missing smoke detector support? prolly not hard to add…)

Oh yeah! I got it working!

I modified JTT’s code a bit so that there’s 3 more commands you can send it, and added dummy commands that flip the smartthings tile status without sending any alarm commands, so now it can receive updates correctly via the urls in alarmserver.py

Now i’ve got a single device that shows Arm/StayArm/Disarm status all in one. I needed to change around alarmserver.py as well, but this new setup I’ve got working seems much nicer than the separate devices for stay/away from before! I just tested everything from both directions - receiving updates after activating the alarm myself, as well as pushing the updates correctly. This is probably the nicest i’ve had this working to date…

Now i’m tempted to see if there’s some way to report the “Exit/Entry delay” status without having to make it a button that doesn’t do anything…maybe another tile that just shows exit/entry delay on or off…

I’ve also cleaned up the python code and made it so you don’t need to use URLs like I was mentioning before…the config file looks kinda like this now:

`smartthingsurl=https://graph.api.smartthings.com/api/smartapps/installations/
apptoken=
accesstoken=
alarmtoken=

[zone1]
description=Front
type=contact
token=

[zone2]
description=Garage
type=contact
token=

[zone3]
description=Back
type=contact
token=

[zone4]
description=Front Motion
type=motion
token=
`

On a further note, i went a bit more crazy and I actually just added support for all the following states and the ability to define multiple alarm panel/switch devices in the config file, now you can have individual switches for away/stay, or combined ones, and/or status-only panels that can show way more than I anticipated…now i’ve got all the following working on my status-only panel (which is based on kent halloway DSC single panel’s but i ripped out all the logic and just made it a dumb actuator that only takes rest api calls from alarmserver and now it can do proper away/stay reporting), the alarm server config looks like this for it:

combined stay/away/disarm panel

[alarm1]
token=xxxxx
away=armstatus
stay=staystatus
off=disarmstatus
ready=disarmstatus

single away switch

[alarm2]
token=xxxxxx
away=away
stay=disarm
off=disarm
ready=disarm

single stay switch

[alarm3]
token=xxxxxx
away=disarm
stay=stay
off=disarm
ready=disarm

multi-status panel actuator

[alarm4]
token=xxxxxxxx
type=actuators
away=away
stay=stay
off=disarm
exitdelay=exitdelay
entrydelay=entrydelay
notready=notready
ready=ready
alarm=alarm

As you can see - you can map commands any number of ways. I map ready to disarm because if the alarm is disarmed while alarmserver is activated, it never sends the signal for “Disarm” but it does send the “ready” state. For the dumber panels, I just let it activate disarm. For the multi-status panel, when you actually do disarm, you’ll see it go “disarmed” then “ready” which is kinda cool. That panel has no switches for now - it’s just providing a place for full status. If i learn a little more about how all these tiles work maybe i can figure out how to combine the stay/away/disarm multi-switch into the multi-status panel thing…then you wouldn’t need a separate multi-switch (but you may still want the separate stay/away switches as i’ve realized the simple on/off switches make it way easier to use in routines or whatnot…)

I didn’t expect to be digging that deep into it but i’ve already pretty much modified alarmserver, the alarm integrator, jtt’s switch panel and kent’s status panel, so needless i’ve made a few changes ! I’ll try to polish all this up and get it onto github somewhere…

OK and one last update…I did manage to combine the multi-status panel with the multi-switch, so now you really only need one panel to show all the statuses and let you switch from away/stay/disarm. However you can still have a separate dedicated stay/away switch as well which is still nice for some things…it will update the status of all of them too with my new config format!

wow.

so i understand the changes to alarmserver.py is cosmetic mostly right? what changes did you do to devices and smartapp in ST?

here is the link for evl-3 and how it reports stay/away althought it may only be contained to their gui and not the actual api.

http://forum.eyez-on.com/FORUM/viewtopic.php?f=6&t=2109&sid=422685197707ba1eb620e6fac77a1d43

So basically, i added an “actuator” type to the alarm integrations app, but I ended up not needing it, instead I just redid the multi-switch device from JTT to support all the extra status modes to it (entry delay, exit delay, ready, etc…) now i have one device that can show all the various alarm statuses as well as set stay,away,or disarm mode.

the alarmserver.py changes are slightly more than cosmetic, on top of simplifying the URL structure, I’ve also redone the handling of the alarm panel triggering - and you can now specify as many alarm panels to update as you like. this part is crucial for allowing those extra statuses to work. The old code just supporting sending away, stay, and two off statuses, and that’s it, it was all hard-coded.

Ahh, that link, i think what he’s saying is that there’s no difference between stay and away if you don’t have any interior motion zones, like, DSC zone type 5 or what not…that makes sense because all “stay” does is bypass any zones that are type 5 or any other stay/away zones. I do have motion zones so this doesn’t apply.

would updating alarmserver.py make it a requirement to update anything in ST? I’d like to try your code and devices when you get time.

nope, you shouldn’t have to change anything in ST, well, except adding the new panel device I made, which is really optional. You can still use all the existing panels too, you just won’t see all the additional statuses and modes that the new panel can show.

The new device i made is a whole new device - you just select is as another switch in alarm integration. hopefully i’ll get a chance to post it! I just got a new wireless camera to play with so i’ve been a little distracted!

Sounds good thank you. I found the panel from jtt you used but you created a better one?

so i added jtt panel and it works, but like you said i can’t add the switches to routines it seems. good luck with your camera, i wired my home with cat5 and installed hikvision poe cameras because i hate my spotty wifi.

Here it is.

Use my modifed version of JTT’s panel from the devicetypes folder as a general status dashboard. You can still use it to arm/disarm/etc, but you can use the existing Stay/Away arm buttons, too. Just define the 3 alarm panels in your alarmserver.cfg (the examples for this setup is already in there - just fill in the token for my new panel and the two existing stay and away panels and you should be good. Note this will also have my new behavior where when you’re in stay mode, “stay” switch will be armed, and “away” switch will be disarmed. You can still have the old behavior too, if you want them to both arm/disarm in parallel regardless, all you’d have to do is flip around the values in the config file for those panels, using the panel type’s mode instead of “disarm” for the opposing mode…I’m not even sure whether this behavior even matters now since you can always view the actual status from the new panel i made, it only might matter if your routine somehow depended on the original behavior which was kinda unusual to me, but ya never know…in either case the options are there so it’s flexible.

I wish my house was wired with cat5/6, I’d totally just do that, and use POE cameras all around. I actually bought a few spools of cat6 planning to do it - but I’m gonna need some flexible drillbits and some fancy snakework, still have no idea how i’m gonna get to the 2nd floor from the basement either. I wanted to add some more hard-wired alarm sensors too, I may end up hiring an expert to run some of it just cause I’m a bit afraid of cutting up my walls! still haven’t integrated the camera with smartthings, but it’s at least setup and on my network now! it’s actually my 2nd camera but it’s a dlink 5222 which supposedly has smartthings support, my other one is a foscam and i don’t think the support is quite as good, I haven’t looked into either yet though…

quick question before i start, i see you have devices/zones and ask for a token. wouldnt’ the oauth token be the same for every device? Or is that the device ID of the contact sensor?

that’s the device ID of the contact sensor (or the alarm panel/switch device for alarm1/2/3) apptoken and accesstoken are the two that get re-used for every URL.