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.
68127-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.

OllieForecast

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

68127-memetemp

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

68127

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.

meme25

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
http://www.ragingcomputer.com/2014/02/logstash-elasticsearch-kibana-for-windows-event-logs
http://www.ragingcomputer.com/2014/02/sending-windows-event-logs-to-logstash-elasticsearch-kibana-with-nxlog

What does all this mean? This heavily redacted screenshot should give some idea.
kibana-ocularis-logs
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.
http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.pdf

Loggly has some examples I found useful, even if I’m not using their service.
http://community.loggly.com/customer/portal/articles/1266344-nxlog-windows-configuration
https://www.loggly.com/docs/logging-from-windows/

There are other options.
http://www.canopsis.org/2013/05/windows-eventlog-snare-logstash/
http://docs.fluentd.org/articles/windows
http://cookbook.logstash.net/recipes/log-shippers/
http://cookbook.logstash.net/recipes/windows-service/
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!
https://github.com/elasticsearch/kibana/blob/master/sample/nginx.conf

Kibana prompting for login to save changes to the dashboard
kibana-login

Before I start, I’ve got a tip of the hat to the resources that helped me figure this out
https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04/
http://nginx.org/en/docs/http/configuring_https_servers.html

https://www.digitalocean.com/community/articles/how-to-set-up-http-authentication-with-nginx-on-ubuntu-12-10
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

http://stackoverflow.com/questions/15503455/elasticsearch-allow-only-local-requests
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.
kibana-windows

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”

Windows Grab Frames for Time Lapse

It’s that time again! Another construction project at work!

It was decided that I would run another time-lapse webcam of the construction process. This was a little last-minute. Our electrician mounted an analog camera and plugged into a network video encoder. http://www.axis.com/products/cam_m7001/

I haven’t had time to set up a proper linux box to manage all this so I threw together a batch file and a scheduled task to run on my workstation every 5 minutes until I get the rest set up.

I love how easy it is to get a jpg off the Axis M7001 Video Encoder http://xxx.xxx.xxx.xxx/jpg/1/image.jpg

I’m familiar (and a fan of) wget. The win32 version works pretty well too.
http://gnuwin32.sourceforge.net/packages/wget.htm

This uses my favorite method of generating zero padded time & date stamp files. It concatenates 0 and the variable then selects the right 2 characters.

constructioncamgrab.bat
[plain]
@echo off
REM Create the date and time elements.
for /f "tokens=1-7 delims=:/-, " %%i in (‘echo exit^|cmd /q /k"prompt $d $t"’) do (
for /f "tokens=2-4 delims=/-,() skip=1" %%a in (‘echo.^|date’) do (
set %%a=%%j
set %%b=%%k
set %%c=%%l
set hh=%%m
set min=%%n
)
)

REM zero-pad and see the result
set mm=0%mm%
set mm=%mm:~-2%
set dd=0%dd%
set dd=%dd:~-2%
set hh=0%hh%
set hh=%hh:~-2%
set min=0%min%
set min=%min:~-2%

echo %yy%%mm%%dd%%hh%%min%

set outFile=C:construction_cam%yy%%mm%%dd%%hh%%min%.jpg

"C:Program Files (x86)GnuWin32binwget.exe" http://xxx.xxx.xxx.xxx/jpg/1/image.jpg -O %outFile%
[/plain]

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://www.reddit.com/r/Roku/comments/1b9uuv/stream_desktop_to_roku/c95f2nl

HTTP Live Streaming (HLS) looks pretty easy to do with VLC.
http://wiki.videolan.org/Documentation:Streaming_HowTo/Streaming_for_the_iPhone

It requires having a local web server. xampp is my favorite way to install apache on windows. You could also use IIS.
http://www.apachefriends.org/en/xampp.html

In these examples, my laptop is 192.168.5.55 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=http://192.168.5.55/stream/mystream-########.ts},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:
https://github.com/rdp/screen-capture-recorder-to-video-windows-free
https://github.com/rdp/virtual-audio-capture-grabber-device

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.

[text]
[HKEY_CURRENT_USERSoftwarescreen-capture-recorder]
"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 "
"last_run_performance"=""
"capture_height"=dword:00000300
"capture_width"=dword:00000556
"start_x"=dword:00000000
"start_y"=dword:00000000
"default_max_fps"=dword:0000000a
"stretch_to_width"=dword:00000500
"stretch_to_height"=dword:000002d0
"stretch_mode_high_quality_if_1"=dword:00000000
"hwnd_to_track"=dword:00000001
"disable_aero_for_vista_plus_if_1"=dword:00000000
"track_new_x_y_coords_each_frame_if_1"=dword:00000000
"dedup_if_1"=dword:00000000
"millis_to_sleep_between_poll_for_dedupe_changes"=dword:00000000
"capture_transparent_windows_with_mouse_blink_only_non_aero_if_1"=dword:00000000
[/text]

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

VLC_Desktop_Stream.bat

[text]
@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=http://192.168.5.55/stream/mystream-########.ts},mux=ts{use-key-frames},dst=C:xampphtdocsstreammystream-########.ts}
[/text]

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.

[text]
:dshow-aspect-ratio=16:9
[/text]

Next Step: Roku
Sign up for roku developer account and download the SDK.
http://www.roku.com/developer

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

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.

appMain.brs

[text]
‘Apple’s HLS test stream
urls = ["http://192.168.5.55/stream/mystream.m3u8"%5D
qualities = ["HD"]
streamformat = "hls"
title = "Apple BipBop Test Stream"
srt = ""
[/text]

Nexus 7 USB Webcam with Torque Track Recorder

I’ve never wanted to embed a tablet in my dash more than I do right now.

While browsing reddit a couple days ago, I came across this post about using a USB webcam with an OTG adapter.

Which lead me to this page about Nexus 7 webcam.

I am a huge fan of Torque OBDII reader for android (Torque Pro) with Torque Track Recorder. It kinda sucks on my original Motorola Droid so I wanted to get it working on my Nexus 7. Which got me really excited about hooking up a webcam to my nexus 7. (I currently have an iPhone 4 so that’s not an option)

So I rooted my nexus 7.

A couple Google searches later, I was reading about swapping cameras on android. This was really helpful to know to look for nvcamera.conf

which lead me to this google+ post about usb=/dev/video0 in nvcamera.conf

YAHTZEE!

Once i knew what I was modifying, I had to mount /system as rw
mount -o remount rw /system

A reboot later and I was looking at myself through a USB webcam in Torque Track Recorder

I’ll export video tonight. I wasn’t expecting to see wifi sync!
http://torque-bhp.com/wiki/Exporting_Video

/system/etc/nvcamera.conf

# format, cameraName=device,direction,orientation,type
# type can be ‘stereo’ for stereo capable, ‘mono’ for not stereo capable,
# ‘usb’ to enable searching for a usb device and where to put it in the list
# if found. Lines must be shorter then 256 characters
version=1
camera0=/dev/mi1040,front,270,mono // front camera
usb=/dev/video0

The RIPINATOR – Semi-automated DVD Ripping

The Ripinator!!!

Motivation:
My fiance and I have a stack of DVDs. They’re dusty and inconvenient. I wanted to rip them to my network storage so I can easily watch them from my Boxee Box. It’s not that I’m lazy, but I hate doing repetative things if I can automate it.

Overview:
I’m using Perl with Win32::SerialPort to control the autoloader. I’m using Win32::DriveInfo to get the volume name of the DVD. I’m using TMDB on the off chance the volumename will pull up the movie. I’m using DVDFab 8 to rip mainmovie to an ISO file. I’m using Handbrake to encode to iPad preset. In my testing, this looks just as good as the ISO file and uses only 20-30% of the space.

To use I batch together either all movies, or all TV shows. I rip my movies into my mapped network drive, V:queue and my TV shows into V:TV_queue
I have my faster computers actually do the encoding. Multiple computers. I map the V: drive to the same fileshare. I encode my movies to V:Encoded and my TV shows to V:TV_Encoded

Requirements-Hardware:

Requirements-Software:

  • Windows
  • Perl
  • Perl Modules – install through Perl Package Manager
    • Win32::SerialPort
    • Win32::DriveInfo
    • TMDB
  • DVDFab 8
  • Handbrake
  • nircmd
  • A big stack of DVDs
  • A large hard drive

Files
traycmds.pl
ripper.pl
ripinator.pl
gripper.pl
encodetv.pl
encodemovies.pl
cmdtest.pl

ripinator.pl
Main program. It requires gripper, ripper, and traycmds. I broke this into multiple pieces to make it easier for me to keep track of.
Enumerates all CD/DVD drives attached to the computer and iterates through them probing the gripper arm to each tray. If a tray is detected, the drive number and drive letter are noted.
It then checks the levels of the bins.
If there are discs in the desginated input bin, it will load them into the drives and start the ripper.pl script
If there are discs done ripping, it will unload them into either the reject bin, or the output bin, depending on the exit code
This will continue until either something crashes, a disc is completely unreadable, or there are no more discs left to rip.

gripper.pl
Description:
Contains subs
Required Setup:
Set COM port on line 218

getVersion()
Returns the version of the autoloader’s firmware
getSerialNumber()
returns the serial number of the autoloader
goHome()
moves the gripper arm to the top of the unit
getStatus()
Queries the autoloader’s status. See command notes for more info
getPosition()
Gets the current position of the gripper arm
getBin($bin)
gets a disc from the specified bin
putBin($bin)
puts a disc in the specified bin
getDrive()
gets a disc from the specified drive
putDrive()
puts a disc in the specified drive
probeTray()
probes the gripper arm to the disc tray, returns drive number
sendCommand()
sends a command to the autloader. see command notes for more info

traycmds.pl
Description:
Contains subs
Required Setup:
Put nircmd in C:nircmdnircmd.exe

@allDVDdrives = closeAllDrives()
Closes all CD/DVD drives. Returns an array of all the CD/DVD drives attached to the computer.
closeDrive($drive)
Closes the specified drive
openDrive($drive)
opensthe specified drive
getVolName($drive)
gets the volume label of the specified drive

ripper.pl
Usage:
perl ripper.pl $drive $tray
Description:
Rips DVD to specified location. makes and removes lock files for ripinator. Looks up TMDB, if available, uses moviename and year for filename, if not, uses volumename.
Required Setup:
Get an API key for TMDB
set $dest_dir where you want ripped DVD ISO files to be stored
set $dvdfab as path to dvdfab.exe
enter TMDB API kay on line 96

cmdtest.pl
Usage:
perl cmdtest.pl !e1C
Description:
Allows sending commands to the autoloader

encodemovies.pl
Usage:
perl encodemovies.pl
Description:
Encodes ISO files to iPad preset m4v with handbrake.
Required Setup:
Set machine name, path to handbrake, source and destination folders.

encodetv.pl
Usage:
perl encodetv.pl
Description:
Encodes ISO files to iPad preset m4v with handbrake. Splits each title into a separate file.
Required Setup:
Set machine name, path to handbrake, source and destination folders.

Back Story:
A few years ago, we had a Rimage DVD production robot at work. I dubbed it Trogdor the Burninator. Rimage had some pretty scummy practices… The ink cartridges are standard HP cartridges, but had a little tag in the label that will keep the software from loading if you don’t buy the Rimage branded cartridges. I’m sure they would have gouged even more if they could think of a way to do it. So we replaced it with a newer, nicer one from Primera. It was an improvement in pretty much every way. I got the old one since no one else wanted it. SCORE!

I took it up as a project again. I had saved the old software from Rimage and was able to get it to run for 30 days between wiping and reloading the computer it was attached to. This was enough time to determine that the connection between the printer and the RAS 13 autoloader was RS232 serial. I sniffed the traffic between long enough to figure out which commands did what, and what replies meant. This is by no means definitive, but it’s enough to use an otherwise useless piece of equipment.