scudre / alarm-central-station-receiver

Python daemon for receiving events from a home alarm system via Contact ID protocol
Apache License 2.0
36 stars 10 forks source link

Project Configuration #41

Open ljsanchez opened 6 years ago

ljsanchez commented 6 years ago

I have been trying to install and configure this project on a Raspberry Pi 3. I have gotten it to install successfully with python setup.py install But I'm not sure how to configure and use since I haven't been able to find any Installation and Configuration documentation. A short run down of the process would be helpful to understand how to use the project. Thanks.

scudre commented 6 years ago

Hello I'm currently traveling so I only have my smartphone. I'll be able to update the documentation in a week. I the mean time to start you can run the command 'alarm-ctl --help' in the help output there is an option to write out the initial config file. Once created you can edit it, it includes comments explaining the various options. If you save it to the default location under /etc then once the config is filled out you can simply start the daemon by executing 'alarm-ctl' or 'alarm-ctrl --no-fork' to have it run without daemonizing.

ljsanchez commented 6 years ago

Thanks for the reply. I tried what you suggested, but I didn't find any options with the help command to write out the initial config. The options that the help command showed could be run were: -h, --offset, --limit, arm, disarm, auto-arm, auto-disarm, status, history.

I also tried running 'alarm-ctl' but I received a message that alarmd was not running. I wasn't able to run it as root or start it as a service either.

When you get a chance, it would be great if you could clarify running alarm-ctl a bit since it seems like a great program and just what I need. Thanks.

scudre commented 6 years ago

I'm heading back from vacation tomorrow so I'll be able to update the documentation this week with details on getting started. Thank you for being patient!

scudre commented 6 years ago

@ljsanchez I created a PR which includes instructions on how to install and get it up and running. It's still very much a WIP, and as you walk through the instructions I'd love to get your feedback to make sure everything makes sense for future users. Feel free to add comments to the PR.

The rendered version can be found here.

ljsanchez commented 6 years ago

Thanks for the installation walk-through!

I did have a chance to try it today, but when I got to the command to generate a config file, I received the following message, it looks like a Traceback error:

Traceback (most recent call last): File "/usr/local/bin/alarmd", line 11, in load_entry_point('alarm-central-station-receiver==1.0.0', 'console_scripts', 'alarmd')()

File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 561, in load_entry_point return get_distribution(dist).load_entry_point(group, name)

File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2631, in load_entry_point return ep.load()

File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2291, in load return self.resolve()

File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 2297, in resolve module = import(self.module_name, fromlist=['name'], level=0)

File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 29, in from alarm_central_station_receiver.contact_id import handshake, decoder, callup

File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/contact_id/decoder.py", line 18, in from alarm_central_station_receiver.contact_id import dsc

File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/contact_id/dsc.py", line 4, in from alarm_central_station_receiver.config import AlarmConfig

File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/config.py", line 16, in import configparser

ImportError: No module named configparser

From the error message, I'm not sure why I received it, maybe some dependency is missing?

I can try reloading Raspbian on the Pi, but I wanted to post the error so you could see it before I did that.

I'll keep notes when going through a full install and add to the PR if I come across anything useful.

scudre commented 6 years ago

Thanks for finding this! There was a dependency missing for Python2.7 installs which caused the import to fail. I updated the code to ensure configparser is installed on installations below python 3, see issue #43.

You can either update to the latest code, or simply 'sudo pip install configparser' to install the needed module.

By the way, the daemon should work perfectly fine on python 2.7. I initially wrote it on python2.7, and then switched to running everything myself on python 3 about 6 months ago. Ideally I'm trying to keep it compatible for both python2.7 and python3.

ljsanchez commented 5 years ago

Sorry for the delay in responding, I just had enough time to test the installation some more. I updated to Python 3 since that's what you're using and I reinstalled the application from scratch like you had it written in the PR just so I could test the entire instructions. The config file generated properly now and I was able to edit it with my information.

But, when I got to running alarmd through the command sudo alarmd --no-fork, I got quite a few errors, the log is below:

ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.front.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
connect(2) call to /tmp/jack-0/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Oct 03 18 10:30:23 PM alarmd[837]: [main.INFO] Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516]
Oct 03 18 10:30:23 PM alarmd[837]: [main.INFO] Starting in no-fork mode
Oct 03 18 10:30:23 PM alarmd[837]: [status.INFO] Loading config from /var/lib/alarmd/alarmd.db
Traceback (most recent call last):
  File "/usr/local/bin/alarmd", line 11, in <module>
    load_entry_point('alarm-central-station-receiver==1.0.0', 'console_scripts', 'alarmd')()
  File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 266, in main
    alarm_main_loop()
  File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 182, in alarm_main_loop
    alarm_system = AlarmSystem()
  File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/singleton.py", line 29, in __call__
    self._instance = self._klass()
  File "/usr/local/lib/python2.7/dist-packages/alarm_central_station_receiver-1.0.0-py2.7-linux-armv7l.egg/alarm_central_station_receiver/system.py", line 67, in __init__
    self.pin = AlarmConfig.config.getint('RpiArmDisarm', 'gpio_pin')
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 834, in getint
    return self._get_conv(section, option, int, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 822, in _get_conv
    return self._get(section, conv, option, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 814, in _get
    return conv(self.get(section, option, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 792, in get
    d = self._unify_values(section, vars)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 1162, in _unify_values
    raise NoSectionError(section)
backports.configparser.NoSectionError: No section: 'RpiArmDisarm'

Then I ran 'sudo alarm-ctl status' just to see if it ran anyway, but I got:

Exception: [Errno 2] No such file or directory
Unable to open socket, is alarmd running?

I'm sure a few of those errors are piaudio related like you mentioned in the PR, but it also seems like it's not detecting the Magicjack. I tried booting the Pi with the Magicjack and plugging it in after booting, but I get the same result. Also, I noticed the error mentions Python 2.7, and I'm not sure why since I updated it to the latest version available. Can you shed some light on the cause of the errors?

Thanks for all your help so far!

scudre commented 5 years ago

1) RpiArmDisarm exception:

@ljsanchez I fixed the RpiArmDisarm error. The code wasn't gracefully handling when that optional config section is missing, and blew up. Try running it again after pulling the latest from master, you'll be good to go.

2) Python2.7 still being used:

How did you install the package? If you did 'python setup.py install', make sure the version of python that is used is python3, e.g. you can do 'python3 setup.py install' to force it to use python 3. The 'python' command will always symlink to the default python version for the system, which in many cases is python2.7.

3) Magic jack detection:

If alarmd cannot find the MagicJack device you'll see either one or both of these Runtime exceptions: "Unable to find TigerJet device" and/or "TigerJet audio output device not found!". The MagicJack device is searched for during initialization and that happens before the 'RpiArmDisarm' config is loaded. So you should be good.

ljsanchez commented 5 years ago

Thanks for the tips and the fix!

But, I encountered something else during the reinstall that I didn't see before. I'm not sure what changed, but it seems like there's an issue with the pyaudio install.

What I received was:

Processing dependencies for alarm-central-station-receiver==1.0.0
Searching for pyaudio
Reading https://pypi.python.org/simple/pyaudio/
Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz#sha256=93bfde30e0b64e63a46f2fd77e85c41fd51182a4a3413d9edfaf9ffaa26efb74
Best match: PyAudio 0.2.11
Processing PyAudio-0.2.11.tar.gz
Writing /tmp/easy_install-94584oql/PyAudio-0.2.11/setup.cfg
Running PyAudio-0.2.11/setup.py -q bdist_egg --dist-dir /tmp/easy_install-94584oql/PyAudio-0.2.11/egg-dist-tmp-1l0gpi1h
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
 #include "portaudio.h"
                       ^
compilation terminated.
error: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

I'm not sure why I received this now because the install was working fine after you fixed the Python 2.7 issue. I tried a new Raspbian install and received the same error. I also tried installing portaudio with apt-get install libportaudio-dev but I tried the install again and received even more errors, so I probably installed some incompatible version of portaudio.

Let me know what you make of this when you have a chance. Thanks!

scudre commented 5 years ago

@ljsanchez it's attempting to compile the PyAudio python3 bindings for portaudio. Your best bet is to install the pre-built python3 PyAudio. You can do this via:

sudo apt-get install python3-pyaudio

Once that is installed, try to do the install of the alarm-central-station-receiver again, and it will see the dependency on PyAudio is already installed, thus skipping the download of the source code from pypi and attempting to compile it.

scudre commented 5 years ago

@ljsanchez thanks again for going through the install and sharing feedback. My plan is to use your questions for an installation FAQ which will help future people get their own systems setup.

ljsanchez commented 5 years ago

@scudre No problem! I'm happy to help with at least some notes on how the install attempts go so you can get any install issues worked out. I feel it's a great project and should be accessible to more people. Hopefully the notes I can give you will help make it easier for others to deploy on their own systems. Sorry for the amount of time between updates here, sometimes I just don't have time to sit down and test further, although I am very interested in getting this working with my setup.

On that note, I'm still getting the same error when I try to install both before and after installing the python3 PyAudio. I'm going to include the full output when running the install command sudo python /home/pi/alarm-central-station-receiver/setup.py install. It's slightly different error output than when running sudo pip install as above but I believe it stems from the same issue: I think that the "arm-linux-gnueabihf-gcc" command is looking for an input file that it thinks is in alarm_central_station_receiver/tigerjet/ but is actually in alarm_central_station_receiver/alarm_central_station_receiver/tigerjet/ But please take a look yourself as you might see something different.

running install
running bdist_egg
running egg_info
writing requirements to alarm_central_station_receiver.egg-info/requires.txt
writing alarm_central_station_receiver.egg-info/PKG-INFO
writing top-level names to alarm_central_station_receiver.egg-info/top_level.txt
writing dependency_links to alarm_central_station_receiver.egg-info/dependency_links.txt
writing entry points to alarm_central_station_receiver.egg-info/entry_points.txt
reading manifest file 'alarm_central_station_receiver.egg-info/SOURCES.txt'
writing manifest file 'alarm_central_station_receiver.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_ext
building 'pytjapi' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-Ub3vap/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c alarm_central_station_receiver/tigerjet/pytjapi.c -o build/temp.linux-armv7l-2.7/alarm_central_station_receiver/tigerjet/pytjapi.o
arm-linux-gnueabihf-gcc: error: alarm_central_station_receiver/tigerjet/pytjapi.c: No such file or directory
arm-linux-gnueabihf-gcc: fatal error: no input files
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

I also wanted to take the time to thank you for the time you've spent helping me with these issues. I'm sure you have other things going on, so thank you for your time so far!

scudre commented 5 years ago

@ljsanchez, no worries on your round trip time, I'm happy that you're interested in installing it.

I was able to recreate your issue. Instead of passing in the full package path to the install command can you run the command from in the directory, so:

cd /home/pi/alarm-central-station-receiver/`
sudo python3 setup.py install

Also, since you want to install via python3, don't forget to call python3 instead of python. I noticed in your sample output it was installing into python2.7's directories.

Finally, if you hit any errors when compiling pytjapi.c make sure you also have the python3 development package installed. You can install this via:

sudo apt-get install python3-dev

ljsanchez commented 5 years ago

Thanks for that! After installing python3-pyaudio and running the install command from within the directory, it installed fine (python3-dev was already installed).

I do want you to see the output I got after running sudo alarmd --no-fork:

Oct 27 18 01:58:12 PM alarmd[1163]: [main.INFO] Starting in no-fork mode
Oct 27 18 01:58:12 PM alarmd[1163]: [status.INFO] Loading config from /var/lib/alarmd/alarmd.db
Oct 27 18 01:58:12 PM alarmd[1163]: [main.INFO] Ready, listening for alarms
Traceback (most recent call last):
  File "/usr/local/bin/alarmd", line 11, in <module>
    load_entry_point('alarm-central-station-receiver==1.0.0', 'console_scripts', 'alarmd')()
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 266, in main
    alarm_main_loop()
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 187, in alarm_main_loop
    timeout = get_alarm_timeout(alarm_system)
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 175, in get_alarm_timeout
    return 300 if alarm_system.alarm.arm_status in [
AttributeError: 'AlarmSystem' object has no attribute 'alarm'

I also get this output from running sudo alarm-ctl status:

Exception: [Errno 2] No such file or directory
Unable to open socket, is alarmd running?

It looks like there are a few traceback errors, but you would have a much better idea about what they might be caused by and if they are critical.

Also, if it helps, in the configuration file, I left both the RpiArmDisarm and Pushover functions commented out, everything else is configured. I can attach the config file if you need it.

ljsanchez commented 5 years ago

@scudre, I'm not sure if you've been able to take a look at my last result yet. I tried running through the whole setup again from a new install on the Pi, and I received the same sort of error. I even tried making python3 the default python and tried giving full 777 permission to the alarmd_config file just in case.

Would you be able to give me a rundown of the OS configuration you're using (if it's on a pi, even better), so I can try it with the same setup myself?

Thanks!

scudre commented 5 years ago

Hey sorry I missed your last message. I'm taking a look right now.

scudre commented 5 years ago

@ljsanchez should be fixed now!

https://github.com/scudre/alarm-central-station-receiver/pull/47

I'll be around later today if you run into other hiccups with your setup.

ljsanchez commented 5 years ago

Thanks @scudre! I was able to install it and run sudo alarmd --nofork and when I ran the status command, it pulled up the status. So that's a step in the right direction!

But, I still haven't gotten it fully working. When I tried triggering an alarm, I do get the phone signal to be detected, but the alarm isn't detected. I imagine that I'm just not using the correct communication protocol. The one I have it set to is the Ademco 10bps with 1400Hz handshake (option 0 on my DSC alarm). It also can't save to the alarmd.db file. Below are the messages that I get:

Dec 03 18 00:56:17 AM alarmd[822]: [callup.INFO] Phone Off The Hook
Dec 03 18 00:57:06 AM alarmd[822]: [callup.INFO] Phone On The Hook
Dec 03 18 00:57:06 AM alarmd[822]: [status.INFO] No new events found!
Dec 03 18 00:57:06 AM alarmd[822]: [status.INFO] Saving config to /var/lib/alarmd/alarmd.db
Dec 03 18 00:57:06 AM alarmd[822]: [status.ERROR] Unable to save alarm data: [Errno 2] No such file or directory: '/var/lib/alarmd/alarmd.db.tmp'
Dec 03 18 00:57:06 AM alarmd[822]: [notify.INFO] No events for notification

Apart from that, I also tested the notification with sudo alarmd --notification-test, and I get a traceback error with that command, as below:

Traceback (most recent call last):
  File "/usr/local/bin/alarmd", line 11, in <module>
    load_entry_point('alarm-central-station-receiver==1.0.0', 'console_scripts', 'alarmd')()
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 245, in main
    notification_test_exit()
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/main.py", line 109, in notification_test_exit
    notify_test()
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/notifications/notify.py", line 39, in notify_test
    notify_async(events)
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/notifications/notify.py", line 44, in notify_async
    emailer.notify(events)
  File "/usr/local/lib/python3.5/dist-packages/alarm_central_station_receiver-1.0.0-py3.5-linux-armv7l.egg/alarm_central_station_receiver/notifications/notifiers/emailer.py", line 47, in notify
    if 'EmailNotification' not in AlarmConfig.config:
TypeError: argument of type 'NoneType' is not iterable

I have all the fields populated in the alarmd_config file, but I don't know if there are any special formatting rules.

I also wanted to know how to make alarmd start up automatically, should I add it to an init.d script?

My last question was about the web ui: is it implemented? Starting it just displays a plain text 404 error when I try to access it.

scudre commented 5 years ago

For the 'No such file error' that you're getting, it's due to the directory where the system is trying to save alarmd.db to is missing. I checked in a fix (#48) to have the system automatically create one. If you update to the latest version of the code, you need to update the following value in alarmd_config.ini:

data_file_path = /var/lib/alarmd/alarmd.db`

to be:

data_file_path = /var/lib/alarmd/

For your alarm, it should be a setting related to 'contact ID protocol'. If there is a setting talking about 10 bps, it's likely one for another type of data transmission. I'm going to hunt around on the internet to see if I can find more details for you.

For the notification test issue, this was a regeression. I fixed this in PR #49 which has also been checked in. I ran the test and verified that its working again.

Now, for the Web UI, it is implemented, what URL are you attempting to access? To see the alarm status you want to access: http://:5000/api/alarm

For the history you can see http://:5000/api/alarm/history

scudre commented 5 years ago

For having alarmd start automatically, I created an init.d script. I can share it once I've cleaned it up (which I can do later this week). I also need to figure out how I registered it with the OS to run. As I remember there was an additional step beside simply adding it into /etc/init.d.

scudre commented 5 years ago

One last update for the night: You're right on the 10 bps. Looking at at least one form of DSC documentaiton, it talks about the 10 bps 'slow' contact ID format which does a 1400 hz handshake. (http://cms.dsc.com/download2.php?t=1&id=13652)

Based on the log messages, alarmd is detecting that the phone is off the hook, but it never detect the alarm system dialing the 'phone_number' as defined in alarmd_config.ini. If it detects the alarm is 'calling' you'll see the following messages:

Dec 01 18 06:45:12 AM alarmd[445]: [callup.INFO] Phone Off The Hook Dec 01 18 06:45:21 AM alarmd[445]: [callup.INFO] Alarm Call In Received Dec 01 18 06:45:21 AM alarmd[445]: [callup.INFO] Collecting Alarm Codes Dec 01 18 06:45:21 AM alarmd[445]: [handshake.INFO] Handshake Initiated Dec 01 18 06:45:27 AM alarmd[445]: [callup.INFO] Alarm Hung Up

If you can share your DSC alarm's model number I can help you verify that you have the settings on the alarm setup right.

Another test that you can do is hook up a phone to your raspberry pi/magic jack, and then dial the phone_number you set. You should see alarmd print these messages, and you'll hear the 1400 hz frequency through the phone.

ljsanchez commented 5 years ago

Nice! I was able to test some more today. Those 2 fixes let me send a successful test notification via email, and the write error is gone. We're getting much closer now, thanks!

I'm still not able to get the alarm communication detected though. I tested with a phone like you suggested, and dialing the number manually gets me nothing from the monitor messages. I'm also not hearing a dial tone when I unhook the phone. Is the pi/magicjack supposed to generate a dial tone?

My system is a DSC 1500 in case it helps, but after this last test, I think there might be something going on with my magicjack setup. Have you encountered this behavior?

scudre commented 5 years ago

Yes, you should hear a dial tone when you pick up the handset. This should come up in alarmd logs as the phone being off the hook. Also when you press the keypad you should hear the DTMF tones play back to you. If these things aren't working then it points to the magicjack not setup right.

I ran into similar issues in the past, and it required me to mess with the audio settings for the system. However I refactored how the magicjack is read by alarmd and it should have gotten rid of the need to do this. I can share more this evening of things to verify in the system to make sure its setup right.

On Tue, Dec 4, 2018 at 9:14 PM laz notifications@github.com wrote:

Nice! I was able to test some more today. Those 2 fixes let me send a successful test notification via email, and the write error is gone. We're getting much closer now, thanks!

I'm still not able to get the alarm communication detected though. I tested with a phone like you suggested, and dialing the number manually gets me nothing from the monitor messages. I'm also not hearing a dial tone when I unhook the phone. Is the pi/magicjack supposed to generate a dial tone?

My system is a DSC 1500 in case it helps, but after this last test, I think there might be something going on with my magicjack setup. Have you encountered this behavior?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scudre/alarm-central-station-receiver/issues/41#issuecomment-444361647, or mute the thread https://github.com/notifications/unsubscribe-auth/ATSHP1Xj7vJAq5QruRD7TPIg_YwoQaBgks5u11ZAgaJpZM4WV0mj .

ljsanchez commented 5 years ago

Ok, then it would make sense that communication isn't working. Your comment made me realize that I never checked the volume settings of the magicjack, so I turned all of them up to max and unmuted. But I still didn't get a dial tone, and I even tried a different USB port on the Pi. I checked on a Windows computer and let it install the driver for the magicjack. It did generate a dial tone there and I could see the audio input working as well with the phone microphone. So it seems like a setup issue with my Pi. Could it be the PyAudio installation maybe? I am using python3-pyaudio like you had suggested before.

scudre commented 5 years ago

There are two ways with how alarmd interacts with tigerjet:

1) Reading /dev/hidraw0 2) Sending audio to the tigerjet via PyAudio

For #1, this is how alarmd detects when the phone is off the hook, and the DTMF tones that are being dialed. From your logs, we know that at least the detection of phone on and off the hook is working. However from your logs, step #2 where alarmd sends the 1400 hz tone via PyAudio doesn't happen. Had the audio played, we would have seen these messages:

Dec 01 18 06:45:21 AM alarmd[445]: [callup.INFO] Collecting Alarm Codes Dec 01 18 06:45:21 AM alarmd[445]: [handshake.INFO] Handshake Initiated

So now what?

/dev/hidraw0 is at least transmitting when the phone is on/off the hook which is a good start. I suggest running alarmd in debug mode. You can do this via alarmd --debug. This will print detailed logs, including printing every DTMF digit that MagicJack detects. Next step once its running in debug mode is to hook up a phone and then try dialing a number. If you see the digits printed out then reading of /dev/hidraw0 is working all correctly.

Next step would then be to connect the alarm system again and have it call alarmd. You can then compare the digits the alarm sends with what you set to 'phone_number' in alarmd_config.ini to verify they're the same.

Feel free to copy your system logs here too if you want some help debugging it.

ljsanchez commented 5 years ago

Thanks! But before I run in debug mode, I think something needs to be fixed in my setup :) Take a look at the messages I get when trying to run in debug mode:

ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.front.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

Is this normal? Because it looks like it can't find quite a few definitions or libraries.

scudre commented 5 years ago

Yeah you can safely ignore them. With PyAudio loads it triggers a parsing of the audio config which often has a bunch of errors in it. My system prints a similar output and it works fine.

scudre commented 5 years ago

The errors to worry about are ones that alarmd prints. It would be something like this:

Dec 01 18 06:45:21 AM alarmd[445]: [foo.ERR] some error message

ljsanchez commented 5 years ago

Ok, sounds good.

I tried running debug mode and it kicks me back to the Terminal input line after this message: JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

I also tried running alarmd --no-fork after installing the latest commit, but it instead hangs at the same line. I didn't change anything, so I'm not sure what's going on there? Any thoughts?

scudre commented 5 years ago

I haven't run into that before. Searching online, I've seen a few other people run into the same error when trying to run other programs that use audio. I'd try to looking around online to see if anyone has ideas. One possble lead::

https://bugs.launchpad.net/raspbian/+bug/1734782

ljsanchez commented 5 years ago

I tried a few things, including the suggestions in the link you posted and installing again on a new Raspbian installation with python 2.7. Unfortunately, I still get the error and it hangs at the same line. When running with the debug option, it just quits.

Is there any way I can see a more verbose output of what the daemon/service is doing while it initiates? It seems like it's getting hung up on something, but those jack errors shouldn't necessarily do that and it's odd that it worked fine before.

scudre commented 5 years ago

At the point where it quits, or hangs, are there any other messages or is that it? Also when it hangs can you ctrl+c to exit?

Other questions: do you have any other peripherals attached the the Raspberry Pi? Also, if you don't have the MagicJack plugged in and start the daemon, does it still get stuck at the same spot?

ljsanchez commented 5 years ago

I just tried a brand new installation of Raspbian on the Pi just in case something was wrong with the previous installation.

If I try the no-fork option, it will now start listening to alarms, but with the same behavior as before: no tone. With the debug option, it quits to the terminal input with the jack message. Then if I try with the same no-fork option, it hangs at that message only if I try the debug option beforehand. I can Ctrl-C at that point and alarmd gives me an informational message that it's exiting: alarmd[2028]: [main.INFO] Received SIG_SETMASK, exiting

After a restart, I can listen to alarms again with the no-fork option.

I only have an HDMI display and keyboard/mouse input attached. I also tried with VNC so nothing but power and the Magicjack were attached, but I got the same result. I also tried with the Magicjack unplugged and using both options, it gives me the message ValueError: Unable to find TigerJet Device

ljsanchez commented 5 years ago

Hi @scudre, do you have any ideas on what I might try next? Maybe I'm using an incompatible build of PyAudio?

scudre commented 5 years ago

Hey @ljsanchez To reply to your earlier message: for now I'd stick to running alarmd in no-fork mode until you can sort this out.

Hmmm I don't know if it would be PyAudio that's only used to play the contact ID handshake wav file. It wouldn't control whether you hear the tone or not.

One more thing to try: thinking about my setup again, I've always used a powered USB hub to power both my Raspberry Pi, and the MagicJack. The MagicJack could be trying to pull higher voltage or current than the Raspberry Pi's USB port can handle. Using a powered USB hub would ensure there more than enough power for the MagicJack. Low power to the MagicJack would explain it being identified by the system, but then when attempting to hook a phone to it having it not work properly. It's worth a shot.

scudre commented 5 years ago

@ljsanchez Did some more digging, and I think the need for more current is the culprit. tl;dr MagicJack needs to be used with a powered USB hub. This would explain the flaky behavior you're seeing. There's an exhaustive list of powered USB hubs what work with Raspberry Pis here: https://elinux.org/RPi_Powered_USB_Hubs

To expand on this:

When looking at the MagicJack's details with the 'lsusb -v' command, it lists that it max power is 500 mA. Though this is what it reports, it is possible it is attempting to draw more current.

This blog post talks about the max current for all USB device on a RPi2 and higher cannot exceed 600 mA: https://hackaday.com/2015/04/06/more-power-for-raspberry-pi-usb-ports/

Additionally, for the Rasperry Pi Model B Rev 1 (which I have) it has a 100 mA polyfuse on the USB which prevents any devices on USB from drawing more than that amount of currently. Of course the 500 mA max power that the MagicJack is reporting is way above that.

ljsanchez commented 5 years ago

Thanks for researching into that @scudre. I really appreciate it.

Your previous response made sense to me, I've had other devices act strangely when not being supplied proper current, so it's not a big surprise for me, I just didn't realize that the MagicJack drew so much current. I haven't had a chance to pick up a powered hub yet, but I will look into the list you linked to find one that works and post an update when I test.

ljsanchez commented 5 years ago

I was able to test some more with a powered USB hub and found some interesting behavior.

I performed a fresh reinstall of Raspbian Jessie without any updates and still could not get a dial tone. But when booting into the NOOBS OS installer for the pi, I was able to get a dial tone. I also tried after installing LibreElec, the Kodi OS, and also got a dial tone. However, installing the previous Raspbian version Wheezy, also gave me no tone. I have a feeling that something is interfering with the Magicjack preventing a dial tone to be generated.

Would you mind sharing what OS and version you're using on your pi? I'm thinking of trying another suitable OS to see if the Magicjack generates a dial tone.

scudre commented 5 years ago

Even though there was no dialtone, did you try running alarmd and dialing the number alarmd is listening for? It could still be working, even if you don't get a dialtone.

I'm running Raspbian Jessie (8)


PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"```
ljsanchez commented 5 years ago

Thanks @scudre. I was able to get a dial tone with Jessie after installing alarm control as well, so I think the Wheezy release has something that is interfering with the Magicjack.

However, after doing some testing, I'm still not getting the "Alarm call in received" message. I've tried both the silent knight and radionics 1400hz communication options but only get the off hook and on hook message. I'm trying it with the Magicjack attached to a powered hub now so power shouldn't be an issue. Trying a phone, I get both dial and DTMF tones, but nothing else. I don't get a message that alarm control recognized the phone number, either. I'm not sure if I'm supposed to receive another tone from the Magicjack.

It does seem like there is something going on with my Pi configuration more so than my alarm's configuration, though.

ca-equinoxe commented 5 years ago

Hi @scudre first I want to say thanks for creating such an awesome project - it has great potential to help a great many users who don't want to be tied to alarm companies.

Unfortunately I'm at the same point as @ljsanchez where everything is hooked up correctly (including a powered USB hub), all instructions were followed but I'm getting no dialtone and if I try to directly connect a handset and dial the configured number, alarmd does not detect it. I'm currently running Raspbian Stretch (4.14.79+) - I did try installing Jessie but the install failed complaining that the setuptools version was too low so I went back to Stretch (I tried updating Jessie to the latest versions of everything but couldn't get past the setuptools issue).

So my question is are there any commands I can run to help assist in diagnosing the issue? Given the comments about Jessie working for some I wonder if there is a driver/resource conflict somewhere. Failing this, would you be willing to share an image of your working SD card (I'm on a RPi 2 Model B v1.2) to eliminate hardware differences as a root cause? I'm happy to help in any was possible to get this working as I'm very excited at the potential for this project - Thanks again!

ca-equinoxe commented 5 years ago

A quick update on this - I managed to get dialtone after executing the command:

aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=1

After running this command once the dialtone is persistent.

I also can record a stream from the phone handset using:

arecord -D sysdefault:CARD=1 test.wav

I can play back the recorded stream with 'aplay' on the headset. (In summary the dialtone issue appears to be immediately resolvable but maybe this also indicates the root cause being something amiss with different audio libraries/required initialisation steps etc. - I'm afraid I have no Python experience to qualify this assumption)

Despite this the alarmd process does not appear to be detecting the digit capture when I manually dial the configured number so I'm wondering if alarmd just isn't attaching to the right handle or one that needs to be intialised with additional steps - just a guess. I'l keep chipping away with the limited understanding I have in this area - hope this helps others to some extent...

ca-equinoxe commented 5 years ago

@scudre @ljsanchez , the problem has been resolved! After running in debug mode I noticed the daemon is configured to only trying to capture a 3 digit phone number and I had left my cell number as the default which was obviously too long. So in short either the documentation needs to be updated to clarify this or the daemon needs to allow 10 digit capture.

ca-equinoxe commented 5 years ago

Final update on this (I've been playing all day and have it purring like a kitten now :)), the dialtone doesn't matter but powered USB hub AND a dedicated Pi power supply for this are a must otherwise behaviour is unpredictable. Also it's important to set your account code to something other than '000' (I used 111) in the alarm system otherwise the check digit calculation fails on the Contact ID message. Email and Pushover notifications are working great so I then configured automatic startup in rc.local and added a pushover notification for reboots for good measure. It all works great on my DSC SCW9047 and I'm sure will for others. Happy to help if anyone has any questions - Thanks again @scudre for a great little project!

scudre commented 5 years ago

@ca-equinoxe happy to hear you were able to get it to work! You're right about the three digit phone number. Looking at what's implemented, even though the config.ini can take a phone_number of any length, the way the loop is structure it will only work for 3 digits. I opened issue #50 to track this bug.

What powered USB hub are you using? I guess I was lucky being able to get both the RPI + MagicJack working on a single hub without a dedicated RPI power supply

Also, can you explain what you mean by reboot pushover notifications? Do you mean with alarmd is shutting down?

scudre commented 5 years ago

@ljsanchez try programming a 3 digit phone number that your alarm "calls" as @ca-equinoxe suggested.
When running alarmd in debug mode after the off hook messages you'll see messages in the format of "Digit: X", and "Number: X" where X are numbers. These messages indicate that the system is detecting the phone number "dialed" by the alram system.

ljsanchez commented 5 years ago

Thanks @ca-equinoxe and @scudre. I was able to get a handshake entry in the running log with the 3 digit phone number and 3 digit account code!

However, after trying multiple communication formats, none of the ones my alarm system has available is compatible with the contact-id protocol. It looks like my system is just a little too old and it uses old formats rather than the full DTMF contact-id format.

This is my fault since I didn't realize this sooner, although alarm control detects something is happening with the handshake.

So I have a question for @scudre : would it be too difficult to fork this project into a slightly neutered version with a simple email notification where it would be triggered by the handshake action? I can assist or even take a try, but I wanted to ask if it's even possible the way it's written. It seems to me that it would be doable after just a quick skim of some of the code modules.

My other option would be to replace my alarm system at this point, but just a simple alarm notification would at least tide me over for now. If it is doable, I can open a new issue, since this one is pretty much resolved considering 2 people have been able to get the project running.

ca-equinoxe commented 5 years ago

@ca-equinoxe happy to hear you were able to get it to work! You're right about the three digit phone number. Looking at what's implemented, even though the config.ini can take a phone_number of any length, the way the loop is structure it will only work for 3 digits. I opened issue #50 to track this bug.

What powered USB hub are you using? I guess I was lucky being able to get both the RPI + MagicJack working on a single hub without a dedicated RPI power supply

Also, can you explain what you mean by reboot pushover notifications? Do you mean with alarmd is shutting down?

I'm just using a cheap Chinese no-name USB hub that appears to work well. Interestingly I could manually start the handshake with a handset using the magic-jack. directly connected to the Pi. My guess is the length of the telephone line back to the system determines what power level you can get away with (in my case this is about 50 feet so I needed the extra juice).

Alarmd isn't shutting down but I want to be sure it starts automatically on a reboot as the Pi is running in headless mode so I just added a command in rc.local to initiate it. My next small task is to create a script that monitors the health of the Internet connection and somehow monitor a heartbeat with my phone so that I can have a degree of comfort that everything is working as expected especially if I leave the house with the alarm set for a period of time. If I ever find the time I would consider adding a GSM fail-safe (perhaps using a ready made Pi module) as a backup to the Internet but that would really just be icing on the cake.

Longer term this project has great potential for incorporation into a binding for openHAB which seems to offer a great platform for consolidating many different IOT devices into a single view (you can also create interesting rules such as when the alarm goes off flash all the lights in the house etc.). I'm certainly happy to help working on this if enough time opens up (perhaps next winter) - alas, too many ideas and never enough time :)

ca-equinoxe commented 5 years ago

Thanks @ca-equinoxe and @scudre. I was able to get a handshake entry in the running log with the 3 digit phone number and 3 digit account code!

However, after trying multiple communication formats, none of the ones my alarm system has available is compatible with the contact-id protocol. It looks like my system is just a little too old and it uses old formats rather than the full DTMF contact-id format.

This is my fault since I didn't realize this sooner, although alarm control detects something is happening with the handshake.

So I have a question for @scudre : would it be too difficult to fork this project into a slightly neutered version with a simple email notification where it would be triggered by the handshake action? I can assist or even take a try, but I wanted to ask if it's even possible the way it's written. It seems to me that it would be doable after just a quick skim of some of the code modules.

My other option would be to replace my alarm system at this point, but just a simple alarm notification would at least tide me over for now. If it is doable, I can open a new issue, since this one is pretty much resolved considering 2 people have been able to get the project running.

@ljsanchez out of curiosity what type of system is it? These systems can be fiddly to setup so happy to double check if there is anything I've seen in my travels that might be helpful.

If the system doesn't support ContactID then you might be able to at least poll the alarm state by monitoring the signal on the external siren (or sometimes AUX) circuit. Assuming you have this kind of output and assuming it's 12V (as are many) then you could try using a <$5.00 automotive relay to short your chosen GPIO pins on the Pi (some alarms even have a signal that indicates if the alarm is armed/disarmed that could also be used.) This is the kind of thing the Pi was practically built for and there are many articles that can point you in the right direction of how to set things up - here are a couple for starters - hope this helps!

https://community.smartthings.com/t/making-my-old-dumb-alarm-smart/68650/2

http://rsmck.co.uk/blog/alarm-monitoring-with-raspberry-pi/

ljsanchez commented 5 years ago

@ca-equinoxe My system is a DSC PC1550 that only has support for the standard (old) Ademco and Radionics protocols. Thanks for those links, I hadn't come across them so I'll take a look at them.

I was hoping to make this project work for me since it's an all in one solution and I haven't yet found something like it as far as full functionality goes that could both monitor and notify from the same device. Not to mention I already have everything needed to make it work, except maybe some code changes consisting of potentially a few lines of code.

EDIT: I actually found a pretty simple solution using a relay and GPIO pins by someone who used smptlib to create a notification script and just monitored the GPIO pins to send an email: https://raspberrypi.stackexchange.com/questions/13538/raspberry-pi-to-email-when-power-outage-occurs

What I said above still applies but if my ask is too difficult/unwieldy, I have that as a fallback.