Sunday, 30 October 2016

X10 Home Security DIY - Notification


So, I've got some old X10 Pro stuff in a box, and I see what commercial products like iSmartAlarm can do, so here's the goal:

A do-it-yourself Home Security System not unlike iSmartAlarm:

  • A central hub
  • Window and door sensors
  • A motion sensor
  • Notifications
  • Arm and disarm functions on phones and tablets
  • A central control panel

My Proposal:


  • Use my desktop linux PC as the central hub, with the ActiveHomePro CM15A controller to receive RF events and to send out X10 powerline commands
  • Use my old X10 window and door sensors
  • Use the mochad linux TCP gateway to connect to the CM15A.  Mochad is a daemon that runs on a linux platform waiting for RF commands to be received and for powerline commands to be transmitted using the CM15A.
  • Use a bash script (bashX10.sh) to listen for events on the mochad port and to send various notifications, e.g.
  • Using linphonec for linux, Android and iPhone hosts to receive messages
  • Using curl to send to the IFTTT Maker channel, which can trigger all kinds of other things, like an events log in Google Drive, SMS messages to cell phones, and so on
  • Using lifxlan-master to send commands directly to LIFX bulbs over the LAN (rather than going through IFTTT, which is slower and requires internet access)
  • Using nc (netconnect) to initiate commands back to the cm15a - like the chime, and light and appliance modules

Notifications

The flowchart for notifications is as follows:




We send out notifications to:
- Android & iOS phones and linux desktops on my LAN (using linphone and notify-my-android)
- the IFTTT Maker channel (to Google Drive and to anywhere on the cloud)
- LIFX bulbs over my LAN using lifxlan-master
- X10 devices using x10cmd to send pl commands back through the CM15A

For now, the IFTTT link is used to keep a log of the notification events in Google Drive (see IFTTT to show how to link the IFTTT Maker channel to Google Drive in a simple recipe), and to notify my cell phone via SMS if I am not home.

The "at home" status is determined by pinging my cell phone on the LAN using nmap and awk from the bashX10.sh script.

References

[1] Lifxlan-master
[2] mochad
[3] linphone
[4] IFTTT

Alternatives:  

I could have used Home Assistant but they don't support the X10 RF sensors; someone has just started supporting mochad, but it is early days yet.  I could also have purchased an iSmartAlarm system, but where's the fun in that?  The incremental cost for this system is $0 - the hardware was sitting around doing nothing, and my time is (almost) free - and as you can see, I am leveraging the expert development efforts of many other fine developers who make their code freely available on the net.

Notifications: 

There are so many options for notifying to other devices, and chat on linphone is not exactly fit for this purpose (it is really a VOIP application, and the interface is quite finicky when used without a SIP account).

I've tried using SSH as well , but it only works on devices that are on the LAN and have SSH (available on Android, linux, and iOS, but not on a Chromebook without enabling Developer mode).

Pushover is a commercial choice, and the cost is quite reasonable - it can support notifications on phones, tablets, linux and windows computers, and chromebooks - it might be worth a try.

Pushbullet is another choice - free, but seems somehow to have lost its way, and it is not supported on my old Android cell.

I am presently using notify-my-android to push notifications to our Android phones when we are not home.  it is free for low volumes, and it is quite reliable.