Code Monkey home page Code Monkey logo

alarmserver's People

Contributors

0xjairo avatar gschrader avatar hinathan avatar juggie avatar kholloway avatar leaberry avatar maps2002 avatar rct avatar the-right-solution avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alarmserver's Issues

Event time for zones/partitions

The event time showing how long ago is cool but two requests.

  1. could it be an option in case some people do not like it.
  2. could you do a hover for the alternate. Eg, now if I mouse over '2 minutes ago' could it show the real time. If it was running in the other mode (showing real time) and I hover, it could show, 2 minutes ago. etc.

How does that sound?

Add trigger function to alrmaserver

Hello i am start to use my sensors to trigger actions in my home.
It would be perfect if it possible to add a trigger function to alarmserver

example:
When Zone 1 goes to open execute a script/http request/mail/ and more

Could not get any response -

I am using Jessie OS on raspberrypi3 and also created SSL certificated using given command which is mention in the readme file but when I hit request http://192.168.0.xxx:8111/api I didn't get any response on CLI I got these logs

SSL Error on 12 ('192.168.0.xxx', 33810): [SSL: HTTP_REQUEST] http request (_ssl.c:581)

Understanding plugins, notification system

I want to understand plugins to write my own for Domoticz. So I am trying to configure notification in alarmserver:

1,ifttt:

[ifttt_maker]
enable=True
key=xyxyxyxyxyxyxyxyxyxyx
eventName=alarmserver

Log:

Apr 25 22:24:19 - DEBUG - core/envisalink.py:handle_line@134: RX < 610 - Zone Emelet Restored
Apr 25 22:24:19 - ERROR: Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 307, in wrapper
    yielded = next(result)
  File "/home//domoticz/userscripts/AlarmServer/plugins/ifttt_maker.py", line 29, in iftttMakerRequest
    if iftttMakerRequestType == 'notify':
NameError: global name 'iftttMakerRequestType' is not defined
Apr 25 22:24:20 - ERROR: Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1063, in run
    yielded = self.gen.throw(*exc_info)
  File "/home//domoticz/userscripts/AlarmServer/plugins/pushover.py", line 29, in sendNotification
    res = yield http_client.fetch("https://api.pushover.net/1/messages.json", method='POST', headers={"Content-type": "application/x-www-form-urlencoded"}, body=body)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1055, in run
    value = future.result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
HTTPError: HTTP 400: Bad Request

2, Similar for pushover:

[pushover]
enable=True
usertoken=xyxyxyxyxyxyxxy

Apr 25 22:10:41 - ERROR: Future exception was never retrieved: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1063, in run
    yielded = self.gen.throw(*exc_info)
  File "/home//domoticz/userscripts/AlarmServer/plugins/pushover.py", line 29, in sendNotification
    res = yield http_client.fetch("https://api.pushover.net/1/messages.json", method='POST', headers={"Content-type": "application/x-www-form-urlencoded"}, body=body)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1055, in run
    value = future.result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
HTTPError: HTTP 400: Bad Request

My first question: what I am doing wrong? And I would like to know: in default setup Alarmserver is sending notification about all events (zone open/closed, armed, disarmed, etc...)?

Improve envisalink host not found handling.

Close this issue when a failure resolving the envisalink's host name is handled better. It should be clear to the user from the logs and the UI that the problem is 'host not found'.

It should be also be clear to the user and the API that alarmserver isn't connected to the envisalink / is unable to connect.

When this came up in issue #58, it was due to a configuration file problem.

There are two ways this condition could be handled. Both have some merit

  1. Treat 'hot not found' as a fatal error, log appropriate messages and exit.
  2. Treat this as possibly a transient error, (DNS failure?), and retry indefinitely.

In any case, the behavior to be avoided is having alarmserver keep running, while not connected and not attempting to retry.

How to run on Synology?

Anyone know how to run this on a Synology? Ideally I'd like to see a pre-built package but I'm not opposed to a manual install... I'm not a Linux guy but I can edit cfg files and use SCP :)

thanks for the help!

Questions/Comments

The ui looks like a great start... I have a couple of comments/questions.

-Does it show multiple partitions? If multiple have names?
-On the zone list on the left, can you make it more like tabs on the side, eg create a default zone called 'All' (with no light) and that should be selected by default and show all events. Rather then have the events as a pop up, how about putting them in all that white space to the right of the list of zones. Then make the rest of the zones vertical tabs if you click each zone it would filter the main box down to just that zone's events.
-How do you think we should implement authentication?

disarm code as a rest parameter

the /api/alarm/disarm endpoint should have an optional code param which could be used if one didn't want to store the code in the config file.

Handle Zone Bypass Status Message TPI Code 616.

Recently TPI response 616 - Zone Bypass Status was added to the TPI. See See http://forum.eyez-on.com/FORUM/viewtopic.php?f=6&t=301&start=80. NOTE: Envisacor has released DSC TPI 1.07 on June 1st, 2016

Bypassed Zones Bitfield Dump
This command is issued upon leaving Zone Bypass programming (_1 on the keypad). It is a 16 character HEX string representing an 8 byte bitfield. This bitfield indicates which zones are currently in bypass. A “1” indicates the zone is in bypass. The lower 8 zones are in the first position of the bitfield. The developer can force this dump by using the keystring commands to enter and leave zone bypassing. i.e. “_1#”

That description isn't terribly clear. 1st byte is zones 1-8 bitmap, 2nd byte is 9-16,

00 00 00 00 00 00 00 00
00 00 62 06 00 00 00 00
|| || || || || || || ||
|| || || || || || || ||
|| || || || || || || 57-64
|| || || || || || ||
|| || || || || || 49-56
|| || || || || ||
|| || || || || 41-48
|| || || || ||
|| || || || 33-40
|| || || ||
|| || || 25-32
|| || ||
|| || 17-24
|| ||
|| 9-16
||
1-8

To trigger the Zone Bypass response for Partition 1 send 0711*1#

Note: this only works for partition 1.

Not loading conffile in new Tornado Version

I found that the new Tornado version doesn't properly load the conffile. I took from the old branch and simplified and added this code to the main function right after the set default config line:

#set default config
conffile='alarmserver.cfg'

try:
    opts, args = getopt.getopt(argv, "c:", ["config="])
except getopt.GetoptError:
    sys.exit(2)
for opt, arg in opts:
    if opt in ("-c", "--config"):
        conffile = arg

Now it loads with the -c option when not in the same folder.

Attached fixed file.

alarmserver.zip

Handle unknown TPI response codes gracefully. (tornado)

AlarmServer should handle unknown TPI codes gracefully.

Currently with the feature/tornado branch, an unknown code generates a KeyError and then AlarmServer is broken but still running.

See #46 for an explanation of the 616 code which was added to TPI 1.07.

Jul 01 09:48:04 - ERROR: Future exception was never retrieved: Traceback (most recent call last):
  File "alarmserver/python/tornado-4.3-py2.6-linux-i686.egg/tornado/gen.py", line 282, in wrapper
    yielded = next(result)
  File "alarmserver/juggie/AlarmServer/core/envisalink.py", line 105, in handle_line
    event = getMessageType(int(code))
  File "alarmserver/juggie/AlarmServer/core/envisalink.py", line 17, in getMessageType
    return evl_ResponseTypes[code]
KeyError: 616

Implementing custom Keystroke command

I really want to implement custom Keystroke command.

So I started to search in this topic and I found that I need to send '071' command to Envisalink:

'071' Keystroke String 1-6 Characters - [1-6 ASCII Character String] Envisalink

I started with httpslistener.py:

elif request == 'disarm':
            #if parameters['alarmcode'] == None: raise tornado.web.HTTPError(404)
            response = {'response' : 'Request to disarm partition %s received' % parameters['partition']}
elif request == 'keystroke':
             response = {'response' : 'Custom keystroke for partition %s received' % parameters['partition']}
...
(r'/api/alarm/(arm|stayarm|armwithcode|disarm)', ApiAlarmHandler),
(r'/api/(refresh|pgm|keystroke)', ApiAlarmHandler),
   

envisalink.py, I added:

elif type == 'keystroke':
                self.send_command('071', str('*106#1234'))

(*106#1234 === *1 bypass 06 zone # usercode).

Then I tried:

$ curl "https://192.168.x.xx:8111/api/keystroke"
{"response": "Custom keystroke for partition 1 received"}

but nothing happens on the alarm. Is there anything that I am missing? 👍

(I have Envisalink 4 with DSC alarm).

Edit:

Oh, in the log I see:

May 05 23:03:10 - INFO: 200 GET /api/keystroke (192.168.xx.xx) 20.26ms
May 05 23:03:11 - DEBUG - core/envisalink.py:handle_line@134: RX < 502 - System Error 021

Verbose Trouble Status handling

Verbose Trouble Status should be "better" handled to track bit field, display status in html, make bits available in JSON.

The test/use case (at least for me), Wireless Keypad Low Battery, generates a trouble LED on, and a verbose trouble status. However, no other zone messages are sent, there is no zone message. If you manually parse out the verbose trouble status bits, you can see the trouble condition is 0x40 Sensor/Zone Low Battery.

Note: My personal goal is to be able to tell as much as possible remotely in case I can't get to a keypad. I don't see a way to tell which zone has the problem, but I think that's a DSC problem for not sending the right zone message.

Currently, I'm not sure I understand the design of the code base well enough to figure out where/how the various system status bits should be handled.

Currently, the web interface does indicate trouble, but:

  • The verbose trouble message is absent from the all/partition logs.
  • the web interface needs a place to show what the trouble is.

mobile view (index.html) issues

  • the page refreshes have noticeable flicker
  • on iOS the events aren't reversed for some reason
  • mobile.html disables the auto refresh, not sure if I should add that to index.html or not

I'm looking for more feedback on this view to see if it can replace mobile.html, let me know what you guys think.

plugins

Any documentation on how to get started with the plugins?

Tornado version for SmartThings?

I am a novice at this and seem to be spiraling down the rabbit hole. Now that I have spent days to figure out how to deploy all the prerequisites, host VMs on my desktop, and register SSL certificates, I am now get the following error when I try to run alarmserver.py from the SmartThing branch.

Print sys.exc_info()[0]
The error is on line 415

Is the new Tornado version compatible with SmartThings? Any idea how to resolve this issue?

Zone labels

I only have 8 zones but I still can't remember what they are. It would be nice if you could specify them in the config file and they are returned as part of the json.

Docker support

Hello, is there any reason why this project can't work in a Docker container? I created one, which is admittedly simple, but I can't seem to get it to work. Perhaps my Docker kung fu is insufficient or there are some limitations I don't appreciate.

Disconnected after login sequence

I always get disconnected after the login sequence. Any idea why? I am able to telnet into my Envisalink and send/receive commands fine. I'm running AlarmServer on Python 2.7.3 on Debian Linux kernel 3.8.13 on a beaglebone black.

Mar 31 21:52:00 alarmserver INFO: Using configuration file alarmserver.cfg
Mar 31 21:52:00 alarmserver INFO: ------------------------------
Mar 31 21:52:00 alarmserver INFO: Alarm Server Starting
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: Staring Envisalink Client
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: Connecting to 192.168.1.100:4025
Mar 31 21:52:00 alarmserver INFO: AlarmServer on HTTPS port 8111
Mar 31 21:52:00 alarmserver.EnvisalinkClient INFO: Connected to 192.168.1.100:4025
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: RX < 505 - Login Interaction
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: TX > 005[PASSWORD]D5
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: RX < 500 - Command Acknowledge
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: RX < 505 - Login Interaction
Mar 31 21:52:00 alarmserver.EnvisalinkClient DEBUG: TX > 00191
Mar 31 21:52:00 alarmserver.EnvisalinkClient ERROR: Disconnected from 192.168.1.100:4025
Mar 31 21:52:00 alarmserver.EnvisalinkClient WARNING: Connection failed, retrying in 10 seconds
Mar 31 21:52:10 alarmserver.EnvisalinkClient DEBUG: Connecting to 192.168.1.100:4025
Mar 31 21:52:10 alarmserver.EnvisalinkClient INFO: Connected to 192.168.1.100:4025
Mar 31 21:52:10 alarmserver.EnvisalinkClient ERROR: Disconnected from 192.168.1.100:4025
Mar 31 21:52:10 alarmserver.EnvisalinkClient WARNING: Connection failed, retrying in 10 seconds

feature req/help: TZ configurable (tornado branch)

Timezone awareness?

So far I've done the following:
alarmserver.cfg, line 11:
logurlrequests=True

## Timezone, UTC default
timezone="America/Chicago"

config.py, line 18:
config.LOGURLREQUESTS = ....
config.ASTZ = config.read_config_var('alarmserver', 'timezone', 'UTC', 'str')
config.HTTPSPORT = .....

state.py, line 1:
**#**import datetime
from datetime import datetime
import pytz

alarmserver modules

import logger
from config import config
from events import events

##config.ASTZ='America/Chicago'
utc_now = datetime.now()
if config.ASTZ != 'UTC':
logger.debug('Timezone set to' + config.ASTZ)
tz = pytz.timezone(config.ASTZ)
now = tz.localize(utc_now)
else:
now = utc_now

class state():

running it like this gives me "AttributeError: class config has no attribute 'ASTZ'", uncommenting the ASTZ above works.

The API call shows the proper time using the timezone ("datetime": "2016-05-11T13:17:00Z"}), however the JS on the index page still shows UTC (Today at 8:17 AM).

So, 2 questions...
1)why isn't it reading in the config file as expected?
2)why isnt the index html/js/ajax page showing the API time?

Logging

@rct

I cleaned up the logging to be what I think is a little better. Let me know what you think and if it works ok for yo.

Shows incorrect time/date

Playing with the new Tornado version and found that on startup my events were always "in 4 hours". I am EST timezone.

I found that by changing the lines in state.py to:

              'datetime' : str(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")), 

By Adding a T inbetween and adding the Z on the end, this builds a proper ISO standard which indicates UTC timezone. Now the web page automatically adjusts to my timezone and shows "few seconds ago", etc.

Fixed file attached.

state.zip

Send Notification

Hi,
I did a little modification in order to have the pushing notification used.
I was wondering if I can send it to you in some way.

Michele

Contributors

I notice most pull requests add a line to the alarmserver.py to add themselves to the contributors. I think this is probably redundant since github has a nice page already that keeps track of that.

Should that section in the file be removed, or should we add everyone else that is missing?

New tornado version doesn't work as iOS Homescreen Web App

I just upgraded to the new tornado version (master branch) of AlarmServer, but this version doesn't seem to work as web app on an iDevice home screen. Used to work before.

I already deleted the icon and re-added it, but when launched as web app, it just shows the black "Alarm Server" banner on top, but otherwise an empty/blank page.

It all works fine in the Safari browser, just not as home screen web app icon.

Smartthings - Where should I put it?

I'm going to be adding more functionality to the AlarmServer in the form of SSDP/UPNP stuff specifically for Smartthings but could be used for something else. Specifically this will make discovery of zones easy for a revamped DSC Smart App I'm working on which will completely remove the manual configuration I previously had to use. This will also include registered callbacks which the smart app can use to hook into each zones status without requiring any of the messy oAuth crap I have to currently use with Smartthings (the hub can be used to talk directly to the local LAN).

I'm hoping most of the new features won't require smartthings in any way but instead can be used by it or any other system using SSDP/UPNP and registered callbacks.

I'm guessing some of this will likely end up increasing the python module requirements which I know you were avoiding (I'm already using requests module in the current Smartthings branch).

Anyway my real question is should I keep adding this stuff to the Smartthings branch, the master branch or my own fork (IE don't add it at all to this repo)?

Thoughts/comments/whatever?

Update

Bonjour,

I have been away for a while (funny how life gets busy) but i'd like to clean this project up a little and start doing some more things with it. Authentication is definitely a priority, and there are other items as well. I'll be away for a few weeks on vacation but I will pick this up again when I return.

Armed Status

Hey guys,

The Armed status still does change when arming the from the page ?

Any ideas ?

Used chrome as well as Safari

Logging in Tornado version doesn't write to file

Noticed that after I setup this server on my router (running Tomato by Shibby) and running this as a service in the background I had no way to figure out why my pushover alerts were not working (turns out that was because I didn't have the updated CA certs so SSL filed, a quick opkg install ca-certificates fixed that).

So, I made some updates to the attached files to NOT use the logger class for config loading (that always uses print now to to go stdout) and moved the importing of classes to after the config is loaded so that all other classes can now write to the configured output file in the cfg file.

Use this if you like, I do think this tweak makes logging when running as a service usable. Attached is the code diff.

Thank you.

logtofilechanges.zip

Plugins do not load if current working directory is not the folder with alarmserver.py

One more quick one. If the current working directory is not the same as the folder with alarmserver.py, then the plugin code doesn't find the plugin folder and no plugins work.

This occurs when you run the python script as a service (using start-stop-daemon).

The fix is to get the current directory of the alarmserver.py file (not the current working directory) and to build the search for plugins based on that. Code is updated below:

#load plugins - TODO: make this way better
currpath = os.path.dirname(os.path.abspath(__file__))
plugins = glob.glob(currpath+"/plugins/*.py")
for p in plugins:
    if str.find(p, '__init__.py') != -1: continue
    name = p[p.rfind('/')+1:p.find('.')]
    exec "from plugins import %s" % name
    exec "%s.init()" % name

install core import httpslistener

I have the server running on one machine just fine, but trying to install on another machine. [windows 10] w/ python 2.7.14 and get this error when trying to load.

C:\AlarmServer>AlarmServer.py
Traceback (most recent call last):
File "C:\AlarmServer\alarmserver.py", line 17, in
from core import httpslistener
File "C:\AlarmServer\core\httpslistener.py", line 5, in
import tornado.ioloop
ImportError: No module named tornado.ioloop

Enabling TPI Time stamps breaks response parsing.

Tested with Tornado branch, probably somewhat expected:
Enabling TPI time stamps through the proxy breaks parsing, leaving alarm server in a broken state.

core/envisalink/handle_line generates a ValueError trying to parse 'HH:' with int().

If TPI timestamps are enabled, they stay enabled even after a disconnect/reconnect cycle.

The response format when them enabled is 'HH:MM:SS 500....'

Send a '0550CA' to turn them back off.

Template engine

I'm thinking that some people will probably want different web pages depending on their use. Using a template engine to server the html would make it easy for people to customize. I know you said you didn't wanted to limit the modules you're using but maybe this is still worth the added dependency.

I'm thinking pystache might be a good choice: https://github.com/defunkt/pystache

Mustache seems pretty popular and seems simple enough.

Envisalink 4 compatibility

I have DSC alarm and Envisalink 4 and I am trying to run your project.

All I got is an empty page at root and on /api
{"version": 0.3}

Do you have any idea how to get this work?
output.log.txt

Tooltips are buggered

Something is wrong with the bootstrap tooltips, the one I added to the auto-refresh doesn't appear at all and the one for the timestamps look to be drawn twice or something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.