MattTW / HoneyAlarmServer

Envisalink 2DS/3 Alarm Server for Honeywell or Ademco Vista Security Systems
37 stars 43 forks source link

OpenSSL Issues #1

Closed Sastozki closed 10 years ago

Sastozki commented 10 years ago

I was trying to get this set up and I am getting the following error, any idea what is causing this?

$ python alarmserver.py Traceback (most recent call last): File "alarmserver.py", line 18, in from twisted.internet import ssl, reactor File "/usr/lib/python2.7/site-packages/twisted/internet/ssl.py", line 25, in from OpenSSL import SSL File "/home/Sean/.local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg/OpenSSL/init.py", line 8, in from OpenSSL import rand, crypto, SSL File "/home/Sean/.local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg/OpenSSL/rand.py", line 11, in from OpenSSL._util import ( File "/home/Sean/.local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg/OpenSSL/_util.py", line 3, in from cryptography.hazmat.bindings.openssl.binding import Binding ImportError: No module named cryptography.hazmat.bindings.openssl.binding

MattTW commented 10 years ago

Are you running Linux? It looks like there is a install bug in the initial version of pyOpenSSL 0.14 on that platform where a couple of dependencies were not specified and thus not getting pulled in.

https://bugs.archlinux.org/task/39388#comment120549

Looks like it can be resolved by pulling down 0.14-2 or later of that package or manually installing the cryptography package as discussed in that thread.

Let us know if that works for you!

Sastozki commented 10 years ago

Thanks Matt, when i tried the "fixed" package I am getting this error:

Do you know if there is a work around to get this Honeywell ArlarmServer working?

Downloading https://pypi.python.org/packages/source/c/cffi/cffi-0.8.2.tar.gz#md5=37fc88c62f40d04e8a18192433f951ec Processing cffi-0.8.2.tar.gz Writing /tmp/easy_install-sMWWe0/cryptography-0.4/temp/easy_install-ZxAGkG/cffi-0.8.2/setup.cfg Running cffi-0.8.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-sMWWe0/cryptography-0.4/temp/easy_install-ZxAGkG/cffi-0.8.2/egg-dist-tmp-IMQ0OR cc -c c/checkthread.c -o c/checkthread.o unable to execute cc: No such file or directory the above error message can be safely ignored; will not use '__thread' in the C code unable to execute gcc: No such file or directory error: Setup script exited with error: command 'gcc' failed with exit status 1

MattTW commented 10 years ago

The workaround would be to take SSL support out. It is obviously more secure but not essential. Ideally this would be config flag so people can choose whether they want the web communication to be SSL or not. I will look at adding something like that. In the meantime a couple of quick code changes will remove SSL for the time being so you can keep moving forward.

change the line:

from twisted.internet import ssl, reactor

to be

from twisted.internet import reactor

and change the line

reactor.listenSSL(config.HTTPSPORT, factory,ssl.DefaultOpenSSLContextFactory(config.KEYFILE, config.CERTFILE))

to be

reactor.listenTCP(config.HTTPSPORT, factory)

i.e. reverse this commit that I made a while back that added SSL support: https://github.com/MattTW/HoneyAlarmServer/commit/0474c60d101629b266a44cb175b8a99cfa21ca5b

Sastozki commented 10 years ago

thanks, I am going to give this a try.

Sastozki commented 10 years ago

That worked. Thanks a bunch. Now onto getting this to integrate with Smartthings.

nitinbali60 commented 10 years ago

Hi Matt,

I had the same issues with SSL which are resolved by taking SSL support out. I have a working alarmserver.py reporting events. Could you please direct me how to proceed further so alarmserver can report/talk to smartthings ? Where can we put the callback url's?

Sastozki commented 10 years ago

In the meantime, I am trying to take the code that is working for Smartthings supporting DCSs and build a plug-in for of it. My coding days are long behind me, but giving it a try.

MattTW commented 10 years ago

Hi nitinbali60 -

You will want to take the same route as Sean and create a plugin for it. The readme has a section on the plugin system. It is simple but hopefully useful. I am not familiar with the Smartthings API, however take a look at the plugin-examples directory for some things that I have written for myself to integrate AlarmServer with other systems. The pushoverPlugin is probably a good basic example to start with. If it is a matter of an HTTP POST or GET to a URL and passing some parameters, the python Requests module makes that really easy - there is also good out of the box support for a few different types of HTTP authentication.

kholloway commented 10 years ago

Just FYI I forked the repo and added a plugin for Smartthings, I had to extend the basePlugin.py file but otherwise no changes to the rest of the code base. It's not tested yet but should work for zone status right now, I need to look at partition states a little more in the Ademco/Envisalink TPI first since it's not like my DSC setup.

Sastozki commented 10 years ago

Thanks Guys. I am going to try this out in a few. I will let you know what happens.

MattTW commented 10 years ago

Cool!

Sastozki commented 10 years ago

When I add the smartthings plug in that Kent created to the plugin folder, I am getting this error: I ran easy_install requests, however this didn't fix the issue.

Sean@Office ~/HoneyAlarmServer $ python alarmserver.py Using configuration file alarmserver.cfg Config option pollinterval not set in [envisalink] defaulting to: '300' Config option zonedumpinterval not set in [envisalink] defaulting to: '60' Config option commandtimeout not set in [envisalink] defaulting to: '30' Config option kpeventtimeout not set in [envisalink] defaulting to: '45' Wed, 25 Jun 2014 20:44:57 INFO Alarm Server Starting Wed, 25 Jun 2014 20:44:57 INFO Currently Supporting Envisalink 2DS/3 only Wed, 25 Jun 2014 20:44:57 INFO Tested on a Honeywell Vista 15p + EVL-3 Wed, 25 Jun 2014 20:44:57 INFO Starting factory <main.EnvisalinkClientFactory instance at 0x6ffff5c65f0> Wed, 25 Jun 2014 20:44:57 DEBUG Started to connect to Envisalink... Wed, 25 Jun 2014 20:44:57 INFO Site starting on 8111 Wed, 25 Jun 2014 20:44:57 INFO Starting factory Wed, 25 Jun 2014 20:44:57 DEBUG TCP connection estblished to 192.168.0.140:4025 Wed, 25 Jun 2014 20:44:57 DEBUG resetting connection delay Wed, 25 Jun 2014 20:44:57 DEBUG searching plugins.basePlugin Wed, 25 Jun 2014 20:44:57 DEBUG searching plugins.smartthings Wed, 25 Jun 2014 20:44:57 ERROR Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(_args,kw)


File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 619, in doReadOrWrite why = selectable.doWrite() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 593, in doConnect self.connectDone() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 607, in connectDone self.protocol = self.connector.buildProtocol(self.getPeer()) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1052, in buildProtocol return self.factory.buildProtocol(addr) File "alarmserver.py", line 149, in buildProtocol self.envisalinkClient = EnvisalinkClient(self.config) File "alarmserver.py", line 186, in init pluginClasses = BasePlugin.find_subclasses("./plugins/") File "/home/Sean/HoneyAlarmServer/plugins/basePlugin.py", line 57, in find_subclasses cls.look_for_subclass(modulename) File "/home/Sean/HoneyAlarmServer/plugins/basePlugin.py", line 64, in look_for_subclass module = import(modulename) File "/home/Sean/HoneyAlarmServer/plugins/smartthings.py", line 1, in import requests exceptions.ImportError: No module named requests

Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(_args,kw)


File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 619, in doReadOrWrite why = selectable.doWrite() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 593, in doConnect self.connectDone() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 607, in connectDone self.protocol = self.connector.buildProtocol(self.getPeer()) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1052, in buildProtocol return self.factory.buildProtocol(addr) File "alarmserver.py", line 149, in buildProtocol self.envisalinkClient = EnvisalinkClient(self.config) File "alarmserver.py", line 186, in init pluginClasses = BasePlugin.find_subclasses("./plugins/") File "/home/Sean/HoneyAlarmServer/plugins/basePlugin.py", line 57, in find_subclasses cls.look_for_subclass(modulename) File "/home/Sean/HoneyAlarmServer/plugins/basePlugin.py", line 64, in look_for_subclass module = import(modulename) File "/home/Sean/HoneyAlarmServer/plugins/smartthings.py", line 1, in import requests exceptions.ImportError: No module named requests Wed, 25 Jun 2014 20:44:57 DEBUG Connection failed to Envisalink. Reason: [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instace: Traceback (failure with no frames): : No module named requests ]. ] Wed, 25 Jun 2014 20:44:57 ERROR Unhandled Error Traceback (most recent call last): File "alarmserver.py", line 675, in reactor.run() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1173, in run self.mainLoop() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1185, in mainLoop self.doIteration(t) File "/usr/lib/python2.7/site-packages/twisted/internet/pollreactor.py", line 169, in doPoll log.callWithLogger(selectable, drdw, selectable, fd, event)


File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(_args,kw) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 627, in doReadOrWrite self._disconnectSelectable(selectable, why, inRead) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 263, in disconnectSelectable selectable.connectionLost(failure.Failure(why)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 483, in connectionLost self.failIfNotConnected(error.ConnectError(string=reason)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 460, in failIfNotConnected self.connector.connectionFailed(failure.Failure(err)) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1058, in connectionFailed self.factory.clientConnectionFailed(self, reason) File "alarmserver.py", line 165, in clientConnectionFailed self.currentLoopingCall.stop() exceptions.AttributeError: 'NoneType' object has no attribute 'stop'

Unhandled Error Traceback (most recent call last): File "alarmserver.py", line 675, in reactor.run() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1173, in run self.mainLoop() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1185, in mainLoop self.doIteration(t) File "/usr/lib/python2.7/site-packages/twisted/internet/pollreactor.py", line 169, in doPoll log.callWithLogger(selectable, drdw, selectable, fd, event)


File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(_args,kw) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 627, in doReadOrWrite self._disconnectSelectable(selectable, why, inRead) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 263, in disconnectSelectable selectable.connectionLost(failure.Failure(why)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 483, in connectionLost self.failIfNotConnected(error.ConnectError(string=reason)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 460, in failIfNotConnected self.connector.connectionFailed(failure.Failure(err)) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1058, in connectionFailed self.factory.clientConnectionFailed(self, reason) File "alarmserver.py", line 165, in clientConnectionFailed self.currentLoopingCall.stop() exceptions.AttributeError: 'NoneType' object has no attribute 'stop'

nitinbali60 commented 10 years ago

looks like its failing to import requests module. I used "pip install requests", don't know if that would make any difference. I also replaced basePlugin.py with the one that Kent extended.

Sastozki commented 10 years ago

agree, I will try again.

Sastozki commented 10 years ago

Still no luck. Its odd because when i run without the plug in it works, once I add the Smartthings plug-in is when i get the error.

nitinbali60 commented 10 years ago

try to delete all the python compiled files .pyc and run again. Did you rename the smartthings files to smartthingsPlugin.py and smartthingsPlugin.cfg?

Sastozki commented 10 years ago

i removed the import requests line n the smartthings.py and the code ran. however I am not sure this is going to work with Smartthings.

kholloway commented 10 years ago

Hey guys try this as a debug step:

Launch Python on your system by typing 'python' in an open terminal or shell window. Then type 'import requests' without the quotes and hit enter.

If you get an error message then your Python/requests module is not installed properly, if you get nothing but the prompt back then it should work just fine with the plugin I wrote.

Sastozki commented 10 years ago

yea I got the error. how can I can ensure this install correctly?

kholloway commented 10 years ago

Try pip install requests or easy_install requests.

If either of those succeed then try the import requests bit again until it returns nothing.

nitinbali60 commented 10 years ago

In my case it runs with no problem but there is no activity on smartthings devices. How can see if the correct URL is being posted to smartthings?

MattTW commented 10 years ago

The requests module logs info/debug message when it is making calls that will show that info. The server can generate a lot of debug message for the Envisalink comm traffic so you might have to search a bit for it. If you aren't seeing those log messages from requests, then the call isn't being made.

Sastozki commented 10 years ago

I really appreciate everyone's support on this!

I did the import and it worked fine after install requests. However when i try to run i still get the same error:

Note: If remove the import requests from the smartthings.py plug in the code will work, however I am not sure its working with Smartthings. Also the code works without the smartthings plugin, but it does me no good :)

Any way to find out what this is: Thu, 26 Jun 2014 12:55:48 ERROR Unhandled Error

Sean@Office ~/HoneyAlarmserver $ python alarmserver.py Using configuration file alarmserver.cfg Config option pollinterval not set in [envisalink] defaulting to: '300' Config option zonedumpinterval not set in [envisalink] defaulting to: '60' Config option commandtimeout not set in [envisalink] defaulting to: '30' Config option kpeventtimeout not set in [envisalink] defaulting to: '45' Thu, 26 Jun 2014 12:55:47 INFO Alarm Server Starting Thu, 26 Jun 2014 12:55:47 INFO Currently Supporting Envisalink 2DS/3 only Thu, 26 Jun 2014 12:55:47 INFO Tested on a Honeywell Vista 15p + EVL-3 Thu, 26 Jun 2014 12:55:47 INFO Starting factory <main.EnvisalinkClientFactory instance at 0x6ffff39b2d8> Thu, 26 Jun 2014 12:55:47 DEBUG Started to connect to Envisalink... Thu, 26 Jun 2014 12:55:47 INFO Site starting on 8111 Thu, 26 Jun 2014 12:55:47 INFO Starting factory <twisted.web.server.Site instance at 0x6ffff39b6c8> Thu, 26 Jun 2014 12:55:47 DEBUG TCP connection estblished to 192.168.0.140:4025 Thu, 26 Jun 2014 12:55:47 DEBUG resetting connection delay Thu, 26 Jun 2014 12:55:47 DEBUG searching plugins.basePlugin Thu, 26 Jun 2014 12:55:47 DEBUG searching plugins.smartthingplugin Thu, 26 Jun 2014 12:55:48 ERROR Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(args,kw) --- --- File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 619, in _doReadOrWrite why = selectable.doWrite() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 593, in doConnect self._connectDone() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 607, in _connectDone self.protocol = self.connector.buildProtocol(self.getPeer()) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1052, in buildProtocol return self.factory.buildProtocol(addr) File "alarmserver.py", line 149, in buildProtocol self.envisalinkClient = EnvisalinkClient(self._config) File "alarmserver.py", line 186, in init pluginClasses = BasePlugin.find_subclasses("./plugins/") File "/home/Sean/HoneyAlarmserver/plugins/basePlugin.py", line 57, in find_subclasses cls.look_for_subclass(modulename) File "/home/Sean/HoneyAlarmserver/plugins/basePlugin.py", line 64, in look_for_subclass module = import(modulename) File "/home/Sean/HoneyAlarmserver/plugins/smartthingplugin.py", line 1, in import requests exceptions.ImportError: No module named requests

Unhandled Error Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(_args,kw) --- --- File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 619, in _doReadOrWrite why = selectable.doWrite() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 593, in doConnect self._connectDone() File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 607, in _connectDone self.protocol = self.connector.buildProtocol(self.getPeer()) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1052, in buildProtocol return self.factory.buildProtocol(addr) File "alarmserver.py", line 149, in buildProtocol self.envisalinkClient = EnvisalinkClient(self._config) File "alarmserver.py", line 186, in init__ pluginClasses = BasePlugin.find_subclasses("./plugins/") File "/home/Sean/HoneyAlarmserver/plugins/basePlugin.py", line 57, in find_subclasses cls.look_for_subclass(modulename) File "/home/Sean/HoneyAlarmserver/plugins/basePlugin.py", line 64, in look_for_subclass module = import(modulename) File "/home/Sean/HoneyAlarmserver/plugins/smartthingplugin.py", line 1, in import requests exceptions.ImportError: No module named requests Thu, 26 Jun 2014 12:55:48 DEBUG Connection failed to Envisalink. Reason: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectError'>: An error occurred while connecting: [Failure instace: Traceback (failure with no frames): <type 'exceptions.ImportError'>: No module named requests ]. ] Thu, 26 Jun 2014 12:55:48 ERROR Unhandled Error Traceback (most recent call last): File "alarmserver.py", line 688, in reactor.run() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1173, in run self.mainLoop() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1185, in mainLoop self.doIteration(t) File "/usr/lib/python2.7/site-packages/twisted/internet/pollreactor.py", line 169, in doPoll log.callWithLogger(selectable, _drdw, selectable, fd, event) --- --- File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(args,kw) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 627, in _doReadOrWrite self._disconnectSelectable(selectable, why, inRead) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 263, in _disconnectSelectable selectable.connectionLost(failure.Failure(why)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 483, in connectionLost self.failIfNotConnected(error.ConnectError(string=reason)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 460, in failIfNotConnected self.connector.connectionFailed(failure.Failure(err)) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1058, in connectionFailed self.factory.clientConnectionFailed(self, reason) File "alarmserver.py", line 165, in clientConnectionFailed self._currentLoopingCall.stop() exceptions.AttributeError: 'NoneType' object has no attribute 'stop'

Unhandled Error Traceback (most recent call last): File "alarmserver.py", line 688, in reactor.run() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1173, in run self.mainLoop() File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1185, in mainLoop self.doIteration(t) File "/usr/lib/python2.7/site-packages/twisted/internet/pollreactor.py", line 169, in doPoll log.callWithLogger(selectable, _drdw, selectable, fd, event) --- --- File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "/usr/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext return func(args,kw) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 627, in _doReadOrWrite self._disconnectSelectable(selectable, why, inRead) File "/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 263, in _disconnectSelectable selectable.connectionLost(failure.Failure(why)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 483, in connectionLost self.failIfNotConnected(error.ConnectError(string=reason)) File "/usr/lib/python2.7/site-packages/twisted/internet/tcp.py", line 460, in failIfNotConnected self.connector.connectionFailed(failure.Failure(err)) File "/usr/lib/python2.7/site-packages/twisted/internet/base.py", line 1058, in connectionFailed self.factory.clientConnectionFailed(self, reason) File "alarmserver.py", line 165, in clientConnectionFailed self._currentLoopingCall.stop() exceptions.AttributeError: 'NoneType' object has no attribute 'stop'

nitinbali60 commented 10 years ago

Hi Matt,

Does the requests module shows logs in the command line itself or does it creates some log file. I am not seeing any callbacks happening in the command line. I see other DEBUG entries for zone status and all. How can I make sure the plugins are loaded and processed

Sastozki commented 10 years ago

nitinbali60, what platform are you running this on? I have not been able to get the request issue fix on Cygwin, however I ran it on windows and I was able to get the script to run.

But now I am getting another error when i try to trigger a sensor:

Thu, 26 Jun 2014 15:35:52 ERROR Unhandled Error Traceback (most recent call last): File "C:\Python27\lib\site-packages\twisted\python\log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\context.py", line 81, in callWithContext return func(args,kw) --- --- File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite why = getattr(selectable, method)() File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 214, in doRead return self._dataReceived(data) File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 220, in _dataReceived rval = self.protocol.dataReceived(data) File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 454, in dataReceived self.lineReceived(line) File "alarmserver.py", line 317, in lineReceived handlerFunc(data) File "alarmserver.py", line 443, in handle_partition_state_change plugin.partitionStatus(partitionNumber, partitionState) File "C:\Python27\AlarmServer\plugins\Smartthings.py", line 79, in partitionStatus code = dscCodes[status] exceptions.TypeError: unhashable type: 'dict'

Unhandled Error Traceback (most recent call last): File "C:\Python27\lib\site-packages\twisted\python\log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted\python\context.py", line 81, in callWithContext return func(args,kw) --- --- File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite why = getattr(selectable, method)() File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 214, in doRead return self._dataReceived(data) File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 220, in _dataReceived rval = self.protocol.dataReceived(data) File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 454, in dataReceived self.lineReceived(line) File "alarmserver.py", line 317, in lineReceived handlerFunc(data) File "alarmserver.py", line 443, in handle_partition_state_change plugin.partitionStatus(partitionNumber, partitionState) File "C:\Python27\AlarmServer\plugins\Smartthings.py", line 79, in partitionStatus code = dscCodes[status] exceptions.TypeError: unhashable type: 'dict' Thu, 26 Jun 2014 15:35:52 INFO Disconnected from 192.168.0.140:4025, reason was unhashable type: 'dict' Thu, 26 Jun 2014 15:35:52 DEBUG Cleaning up Envisalink client... Thu, 26 Jun 2014 15:35:52 DEBUG Lost connection to Envisalink. Reason: [Failure instance: Traceback (failure with no frames): <type 'exceptions.Type rror'>: unhashable type: 'dict' ]

kholloway commented 10 years ago

All, the requests module is required for this to work, it's the module that is sending the HTTP GET to Smartthings, without that module nothing will ever happen on the smartthings side. I have the URL being logged to DEBUG level so you should be able to see it if your alarmserver.cfg file has 'loglevel=DEBUG' set.

@Sastozki I just fixed that error, grab the latest copy from my repo. Note: So far I have patched the basePlugin.py file AND the 'alarmserver.py' file to support all this so make sure are replacing both those files if you are not pulling directly from my repo.

@MattTW Do you want a PR for all this stuff or should I just keep it in my fork?

MattTW commented 10 years ago

Makes sense to me to add it in. What you have looks solid - do a PR when ready.

Sastozki commented 10 years ago

Kent, Almost there. did i have to set this to something in the smartthings.cfg? ConfigParser instance has no attribute 'CALLBACKURL_BASE'

MattTW commented 10 years ago

@nitinbali60 There will be a debug messages at startup that show the plugins directory being scanned and listing each valid plugin that it finds and loads.

nitinbali60 commented 10 years ago

Hi Kent,

I just grabbed the latest fork. Please see the results. It is not able to log/debug callback_url's. As you can see the GarageDoor is open but no callback_urls or probably it fails trying. Please advice.

Using configuration file alarmserver.cfg Config option pollinterval not set in [envisalink] defaulting to: '300' Config option zonedumpinterval not set in [envisalink] defaulting to: '60' Config option commandtimeout not set in [envisalink] defaulting to: '30' Config option kpeventtimeout not set in [envisalink] defaulting to: '45' Thu, 26 Jun 2014 14:41:47 INFO Alarm Server Starting Thu, 26 Jun 2014 14:41:47 INFO Currently Supporting Envisalink 2DS/3 only Thu, 26 Jun 2014 14:41:47 INFO Tested on a Honeywell Vista 15p + EVL-3 Thu, 26 Jun 2014 14:41:47 INFO Starting factory <main.EnvisalinkClientFactory instance at 0x03934F08> Thu, 26 Jun 2014 14:41:47 DEBUG Started to connect to Envisalink... Thu, 26 Jun 2014 14:41:47 INFO Site starting on 8111 Thu, 26 Jun 2014 14:41:47 INFO Starting factory <twisted.web.server.Site instance at 0x03951030> Thu, 26 Jun 2014 14:41:47 DEBUG TCP connection estblished to 192.168.1.20:4025 Thu, 26 Jun 2014 14:41:47 DEBUG resetting connection delay Thu, 26 Jun 2014 14:41:47 DEBUG searching plugins.basePlugin Thu, 26 Jun 2014 14:41:47 DEBUG searching plugins.smartthings Thu, 26 Jun 2014 14:41:47 DEBUG Found subclass: SmartthingsPlugin Thu, 26 Jun 2014 14:41:47 INFO Connected to 192.168.1.20:4025 Thu, 26 Jun 2014 14:41:47 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:47 DEBUG RX < Login: Thu, 26 Jun 2014 14:41:47 DEBUG TX > user Thu, 26 Jun 2014 14:41:47 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:47 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:47 DEBUG RX < OK Thu, 26 Jun 2014 14:41:47 INFO Password accepted, session created Thu, 26 Jun 2014 14:41:47 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:48 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:48 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:41:48 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:52 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:52 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:41:52 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:56 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:41:56 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:41:56 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:00 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:00 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:42:00 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:04 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:04 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:42:04 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:08 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:08 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:42:08 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:12 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:12 DEBUG RX < %00,01,0028,10,00,FAULT 10 GARAGE DOOR $ Thu, 26 Jun 2014 14:42:12 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:16 DEBUG ---------------------------------------- Thu, 26 Jun 2014 14:42:16 DEBUG RX < %01,0002000000000000$ Thu, 26 Jun 2014 14:42:16 DEBUG FrontDoor Contact (zone 9) is Closed/Not Faulted Thu, 26 Jun 2014 14:42:16 ERROR Unhandled Error Traceback (most recent call last): File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\python\log.py", line 88, in callWithLogger return callWithContext({"system": lp}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\python\log.py", line 73, in callWithContext return context.call({ILogContext: newCtx}, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\python\context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, _args, _kw) File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\python\context.py", line 81, in callWithContext return func(args,kw) --- --- File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite why = getattr(selectable, method)() File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\internet\tcp.py", line 214, in doRead return self._dataReceived(data) File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\internet\tcp.py", line 220, in _dataReceived rval = self.protocol.dataReceived(data) File "C:\Python27\lib\site-packages\twisted-14.0.0-py2.7-win32.egg\twisted\protocols\basic.py", line 454, in dataReceived self.lineReceived(line) File "C:\Python27\AlarmServer\alarmserver.py", line 317, in lineReceived handlerFunc(data) File "C:\Python27\AlarmServer\alarmserver.py", line 420, in handle_zone_state_change plugin.zoneStatus(zoneNumber, zoneStatus) File "C:\Python27\AlarmServer\plugins\smartthings.py", line 63, in zoneStatus logger.debug("URL: %s" % self._urlbase) exceptions.NameError: global name 'logger' is not defined

nitinbali60 commented 10 years ago

Ok, got it to work. changed "logger" to logging in smartthings.py

Sastozki commented 10 years ago

That is awesome. I think i am just about there.
What do you have CALLBACKURL_BASE' set to in your smartthings.cfg?

nitinbali60 commented 10 years ago

CALLBACKURL_BASE is generic : https://graph.api.smartthings.com/api/smartapps/installations

Have you gone through smartthings setup yet ? You should have your own app_id and access token created.

kholloway commented 10 years ago

@Sastozki Nice catch on the logging issue, I use logger everywhere for my log name so for whatever reason I didn't even look at what @MattTW was using, anyway fixed and pushed, thanks!. Also you need to walk through the REST_API setup in my other AlarmServer repo, that part is all Smartthings related and eventually you will end up with values for those config settings in the plugin.

Sastozki commented 10 years ago

@kholloway it was @nitinbali60 that caught the error.

kholloway commented 10 years ago

Ahh crap.. I got up too early this morning.. Sorry @nitinbali60! Thanks for the fix!

The Rest API instructions are below also:

https://github.com/kholloway/smartthings-dsc-alarm/blob/master/RESTAPISetup.md

nitinbali60 commented 10 years ago

All the thanks to Kent and Matt for helping out us novices.

MattTW commented 10 years ago

You bet - I was a novice not long ago too. :) Glad you are getting it working.

nitinbali60 commented 10 years ago

curious if zone devices can report battery status?

nitinbali60 commented 10 years ago

also, I can see there is a partition status code as well. Is it suppose to report if the panel is armed, ready to arm or not ready?

kholloway commented 10 years ago

@nitinbali60 Look at the Envisalink TPI info to see if battery status is something a zone can report? Also yes you should get partition status updates for the panel device type of Ready/Armed/Not Ready/etc.. You have to have a panel device that matches the partition number the plugin is sending.

If that's not working for some reason send me some of your output for a panel status change from the alarmserver debug or info log along with the URL it's calling on the smartthings side (scrub out your API and access token bits though first).

kholloway commented 10 years ago

@nitinbali60 Looks like the TPI has a single low battery event that the panel can send to the virtual keypad.

Bit Pos: Description 14: LOW BATTERY

I'm not sure though if that's a low battery for the system as a whole or low battery for a zone, it doesn't specify which. Page 3 of the Envisalink Ademco TPI doc.

I suppose you could pull the battery on your main system and see if that event gets sent?

nitinbali60 commented 10 years ago

Thanks Kent. Now its calling back for partition status.In partitionstatus function the url included config

self._config.CALLBACKURL_APP_ID

changed to

self._CALLBACKURL_APP_ID

then it started reporting partition status.

Sastozki commented 10 years ago

For some reason, I still cant get smart things to see anything. I have an app_id and token, etc..

nitinbali60 commented 10 years ago

Although it reports instantly when contact/sensor is open, it takes about 2-3 minutes to report its closed. I also noticed that callbacks are made every minute or two for all the zones regardless of any activity on those zones. Is this normal?

nitinbali60 commented 10 years ago

@Sastozki If you already have DSC Integration app, go to your smartthings app on phone. Go to alarm panel in things and then smartapps and click DSC Integration app. There under DSC Zones, include all the devices you created and try again.

kholloway commented 10 years ago

@nitinbali60 great, I updated the config variables as you said and pushed the code again. Thanks!

This forum posting on Eyez-on seems to indicate that the Ademco panel doesn't know when a zone closes and instead guesses. http://forum.eyez-on.com/FORUM/viewtopic.php?f=6&t=1073

The TPI docs also mention that there is a per zone timer that counts down in 5 second ticks until it hits 0 where 0 means 'too long ago to remember'. The forum post suggests that the Envislink stuff is using those timers to make an educated guess at a zone 'closing' based on it's previous open/countdown timer.

Seems like the Ademco panel is not all that feature rich.. :(

The upside with most of these security panels is the contacts/zones almost always work in a consistent fashion that is not specific to any panel (just using normally open/normally closed logic) so if you ever feel like replacing the Ademco you could make the switch to something else fairly easily without having to replace the zones/sensors themselves.

nitinbali60 commented 10 years ago

@kholloway Is it normal to have long delays in reporting with alarmserver project? First few tries, contact open was instantaneous but contact close took over 5 minutes even though I can see the logs reporting that zone has been closed for 4 min 30 sec then why it didnt trigger callback for close. My Honeywell touch panel on wall reports open/close within 5 seconds of the event which is still acceptable. Not sure where to look for a fix.

kholloway commented 10 years ago

The DSC stuff I use reports open and close within a half-a-second of it doing the event, the only delay is calling the Smartthings REST API.

So you see the alarmserver log outputting that the zone was closed but you don't see the corresponding Smarttthings URL/push until 5 minutes later? If that's the case that seems odd... Can you post some of your alarmserver info and debug logs here so I can take a look at them? Please include a zone open and the zone close for the same zone, you can strip out most of the smartthings URL but include the zone number and event number that gets sent (609, 610 for example).

nitinbali60 commented 10 years ago

You are right Kent. I checked the envisalink web page and panel doesnt report zone closed until 2-3 minutes although the partition status goes "Ready" right away. What Alarm Panel do you have?