Hikvision Motion Detection in OpenHAB using node.js

Using a node.js module (node-hikvision-api) for accessing a hikvision camera’s built-in motion detection for use in OpenHAB

It’s a little annoying how Hikvision exposes the motion events on their cameras. It’s a multipart http stream containing XML.

See Hikvision manual Page 176
Section 8.11.30 /ISAPI/Event/notification/alertStream

node-hikvision-api abstracts that away a bit so hikmotion.js can focus on what to do with those events, like update motion contacts in OpenHAB.

hikvision camera with motion events configured
(tested with DS-2CD2332-I & XC-2142FWDI)

linedetect vmd
Continue reading “Hikvision Motion Detection in OpenHAB using node.js”

rtlamr Power Meter Data in OpenHAB

Wouldn’t it be cool if you could monitor your electricity usage with OpenHAB for less than 20 bucks with the same accuracy your power company uses for billing?

Using an inexpensive rtl-sdr dongle, it’s possible to listen for signals from ERT compatible smart meters using rtlamr. This script runs as a daemon, launches rtl_tcp and rtlamr, and parses the output from rtlamr. If this matches your meter, it will push the data into OpenHAB using the REST API.

Turns out these ERT meters (at least in Omaha) are broadcasting 4 hours of usage data with 5 minute resolution. It broadcasts this data every minute, repeating the previous broadcast until the next 5 minute interval has completed. This data is flying around unprotected. Using free software and an inexpensive SDR dongle it’s possible to pull this data into OpenHAB.

rtlamr does all the heavy lifting here. It listens for the data, decodes, and passes along the meter readings.

On my meter, the interesting information is just above the readout. That’s my meter’s type and endpoint ID or serial number. I’ve blurred my details for privacy.

Continue reading “rtlamr Power Meter Data in OpenHAB”

Controlling Android Tablet Screen with OpenHAB and ADB

Wouldn’t it be cool to control an android device’s wake and sleep from OpenHAB? I’ve strapped a couple tablets to the wall with command strips. I’m using them to control OpenHAB. Gotta get ’em working well enough to gain wife approval before doing anything more permanent.

I was griping about turning my tablet screens on and off in response to sensor triggers in my home automation system. My first attempt using Tasker to poll the OpenHAB Rest API was too laggy to be useful. I wasn’t making much progress when my buddy over at https://opsech.io told me about adb and sending keyevents using adb shell. He ninja’d up tabletcontrol.sh and it works beautifully. Following his example, I munged out gettabstatus.sh and it works well enough.

Rooted Android device
WiFi ADB – Debug Over Air
NOTE: This app works on ROOTED devices only.

OpenHAB Server & exec binding, tested on 1.8
linux/bash, tested on Ubuntu Server 14.04 LTS
android tools ADB
[text]sudo apt-get install android-tools-adb[/text]

Continue reading “Controlling Android Tablet Screen with OpenHAB and ADB”

Taking over an ADT Alarm and integrating it with OpenHAB

As you can see from previous posts, I’ve started automating my house. There was an ADT alarm system installed. I was given a user code, but that was it. I opted not to pay ADT’s ridiculous monthly fee since reasonable monitoring can be had for $10/month.

Looking at the panel, I have a Safewatch Pro 3000, which the internets tells me is close to a honeywell/ademco vista20p without a couple features like zone doubling.

I have a simple touchpad, not an alpha display, probably similar to the 6150, so it’s terrible to program with.

The wireless receiver is in the 5881 series, still don’t know for sure the specific model, but I suspect its the 5881enh.Continue reading “Taking over an ADT Alarm and integrating it with OpenHAB”

Using Perl and ImageMagick to Generate Meme Image Macros

Sometimes I feel a need to automate some meme generation. Luckily I found this incredibly helpful blogpost from jackmeme. http://www.jackmeme.com/blog.php?id=1

I used it as inspiration and did something similar in Perl. Of course the Imagemagick perl-magick reference was invaluable. http://www.imagemagick.org/script/perl-magick.php

The first thing I thought of with automated meme generation? The Weather! See my previous post about getting data from the Weather Underground API using Perl

This naturally lead to the forecast overlaid on the current radar.

Inspired by http://thefuckingweather.com/, I decided I want my daily forecast in meme form. The first weather-related meme I think of is Ollie Williams.


But that doesn’t really fit with the meme. Change fucking to motherfucking and Samuel L Jackson is PERFECT!


Smoosh those memes together and I’ve got my morning weather!


I found another source of amusement while playing with generating image macros. There is a Pyborg bot in one of the IRC channels I frequent. “She” says some pretty funny stuff, so we keep a quote list. Of course this is ripe for meme-ifying.


More Evequotes are available in the Imgur Album

Keep reading to see the secret sauce.
Continue reading “Using Perl and ImageMagick to Generate Meme Image Macros”

Collecting ONSSI Ocularis CS RC-C Logs with nxlog / Logstash / Elasticsearch / Kibana3

Edit: This post is pretty old and Elasticsearch/Logstash/Kibana have evolved a lot since it was written.

That’s quite a title. I work with an ONSSI Ocularis CS setup. Originally installed with NetDVMS, but upgraded to RC-C.

This post builds upon a couple earlier posts

What does all this mean? This heavily redacted screenshot should give some idea.
Number of overall motion events over time, same for failure events. Top list of cameras with motion events, top list of cameras with failure events.

You can see we’ve got a few failed cameras. Likely a power surge or network failure. Having this information will lower the time to repair, minimizing camera down time!
Continue reading “Collecting ONSSI Ocularis CS RC-C Logs with nxlog / Logstash / Elasticsearch / Kibana3”

Sending Windows Event Logs to Logstash / Elasticsearch / Kibana with nxlog

Edit: This post is pretty old and Elasticsearch/Logstash/Kibana have evolved a lot since it was written.

Part 3 of 4 – Part 1Part 2Part 4
This is a continuation of http://www.ragingcomputer.com/2014/02/logstash-elasticsearch-kibana-for-windows-event-logs

Again, I took a lot of inspiration from http://sysxfit.com/blog/2013/07/18/logging-with-logstash-part-3/

The nxlog reference manual is surprisingly well written with excellent examples.

Loggly has some examples I found useful, even if I’m not using their service.

There are other options.
Continue reading “Sending Windows Event Logs to Logstash / Elasticsearch / Kibana with nxlog”

Securing Elasticsearch / Kibana with nginx

Edit: This post is pretty old and Elasticsearch/Logstash/Kibana have evolved a lot since it was written.

Part 2 of 4 – Part 1Part 3Part 4
This is a continuation from http://www.ragingcomputer.com/2014/02/logstash-elasticsearch-kibana-for-windows-event-logs

The great folks working on Kibana have been so awesome as to provide an example nginx configuration!

Kibana prompting for login to save changes to the dashboard

Before I start, I’ve got a tip of the hat to the resources that helped me figure this out


Continue reading “Securing Elasticsearch / Kibana with nginx”

Logstash / Elasticsearch / Kibana for Windows Event Logs

Edit: This post is pretty old and Elasticsearch/Logstash/Kibana have evolved a lot since it was written.

Part 1 of 4 – Part 2Part 3Part 4

Have you heard of Logstash / ElasticSearch / Kibana? I don’t wanna oversell it, but it’s AMAZING!

I’ll start with a screenshot. You know you want this. I have to blur a few things to keep some 53cr375 about my environment.

This is my configuration for collecting Windows event logs. I’m still working out the differences between the Windows XP, Server 2008R2, and Windows 7 computers I’m collecting logs from, but this has already proven very useful.

If you don’t know about it yet, you should really go watch this webinar. http://www.elasticsearch.org/webinars/introduction-to-logstash/ I’ll wait.
Continue reading “Logstash / Elasticsearch / Kibana for Windows Event Logs”

HTTP Live Streaming Windows Desktop to Roku Using VLC

I should stop reading Reddit when I’ve got some time to kill. It ends up eating into time I don’t have to kill.

HTTP Live Streaming (HLS) looks pretty easy to do with VLC.

It requires having a local web server. xampp is my favorite way to install apache on windows. You could also use IIS.

In these examples, my laptop is and I’m using C:xampphtdocsstream for the output folder. You will need to adjust for your environment.

If you don’t care about audio, you can use the built-in screen:// source for VLC

[text]"C:Program Files (x86)VideoLANVLCvlc.exe" -I dummy screen:// :screen-fps=10 vlc://quit –sout=#transcode{width=1280,height=720,fps=10,vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=10,ref=1},acodec=mp3,ab=96}:std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index=C:xampphtdocsstreammystream.m3u8,index-url=},mux=ts{use-key-frames},dst=C:xampphtdocsstreammystream-########.ts}[/text]

To capture both screen and audio and video with VLC requires using dshow. Free and works:

NOTE: If the screen width isn’t an exact multiple of 8, the video grabbed by dshow won’t play correctly in VLC. It will look garbled like black with diagonal lines.
For example: my laptop’s resolution is 1366×768. 1360 is a multiple of 8, but 1366 isn’t. It wasn’t until I had dshow scale the output to 1280×720 that I was able to get usable video into VLC.

"last_init_config_was"="default/from reg read config as: 768×1366 -> 720×1280 (0top 768b 0l 1366r) 10fps, dedupe? 0, millis between dedupe polling 10, m_bReReadRegistry? 0 "

Now that I can view the dshow video without trouble, I’m ready to encode to h.264 and segment for HLS.


@echo off
rem Start Stream
del /q C:xampphtdocsstream*
"C:Program Files (x86)VideoLANVLCvlc.exe" -I dummy dshow:// :dshow-vdev=screen-capture-recorder :dshow-adev=virtual-audio-capturer :dshow-aspect-ratio=16:9 vlc://quit –sout=#transcode{width=1280,height=720,fps=10,vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=10,ref=1},acodec=mp3,ab=96}:std{access=livehttp{seglen=1,delsegs=true,numsegs=5,index=C:xampphtdocsstreammystream.m3u8,index-url=},mux=ts{use-key-frames},dst=C:xampphtdocsstreammystream-########.ts}

Note: Some devices honor the video stream’s stated aspect ratio, even if the video dimensions are different. My screen is 16:10, but I’m smooshing to 16:9. To make this work correctly, I had to specify the dshow aspect ratio as 16:9. No amount of fussing with it on the transcode side will fix this. It defaults to 4:3.


Next Step: Roku
Sign up for roku developer account and download the SDK.

The simplevideoplayer example will play HLS and is simple enough for this.

Comment out the other video source lines in appMain.brs and change the URL under Apple’s HLS test stream to your local webserver.
Note: For some reason, this did not play unless I had srt = “” set.


‘Apple’s HLS test stream
urls = [""%5D
qualities = ["HD"]
streamformat = "hls"
title = "Apple BipBop Test Stream"
srt = ""