How To Automatically Show Security Feed on any TV with PIP

This how-to shows how to automatically show your security camera feed to your TV. In this tutorial, I am using a Samsung TV, but should be applicable to other TVs with minor changes here and there. I am also using Orange Pi

Flow (Super quick summary):

  1. Camera motion triggered -> Send to openHAB
  2. openHAB triggers PIP on TV
  3. PIP video feed comes from the Orange Pi through the COAX cable.


For my TV (and any other TVs I have owned), you can only PIP with a digital signal and an analog signal. In the case of my TV, the primary display is the HDMI feed, and the PIP display comes from the COAX feed. Most TVs work this way. I still yet to find and own a TV that PIPs two HDMI signals at once. I have been asked many times (forum, and in person) how I am able to do this Automatic PiP. My initial setup was actually different than this HOW-TO. Instead of using Samsung TV Binding, I am controlling the PiP using my Samsung TV’s EXLINK port. The EXLINK port is a support/developer port in RS232 (UART). I have an ESP8266 connected to this UART port using correct TTL levels. Whenever I explain this to whoever asks, they have no idea what I am talking about. So I recreated the Automatic PIP on my other TV, but instead I am using Samsung TV Binding as demonstration/POC.

1. Requirements

A. Hardware

Note: Get them wherever you can get them the cheapest. I already had them laying around. I just went to Amazon for a quick search and pasted the first link I could find so you know which ones I am talking about.
  1. Samsung TV
  2. (OPiZero) Orange Pi Zero
    I am using Orange Pi zero since it’s more lightweight than the bigger Raspberry Pi. It also has an ethernet jack unlike the rPi zero.
  3. Orange Pi Zero Expansion board (OPTIONAL) such as this
  4. Video to CoAx such as this
  5. 3.5mm RCA cable such as this
  6. Camera with a network-based stream (RTSP, H264, MJPEG, etc)
  7. Micro SD Card for your OPi

B. Software

  1. Armbian for Orange Pi Zero
    Or any ARM-based OS that can run on the orange pi
  2. Desktop Software for your hardware. I used XFCE
  3. Chromium for ARM
  4. OpenHAB Samsung TV Binding
  5. Blue Iris (Optional)

2. Setup

A. Software

  1. Flash your OPiZero with the armbian image
    a. Enable SSH
  2. Install XFCE
  3. Install Chromium
  4. Add Chromium to automatically start on boot
    a. Parameterize chromium with your Blue IRIS stream URL
    Now, whenever your OPiZero starts/boots, it should open chromium and display the feed. Notes:
    For my setup, I am not just using a blue iris feed, my URL points to a small web page with a few scripts. This small web app has a websocket connection to OH to trigger what shows on the web page. For example, based on a rule, instead of displaying the feed, I display a caller ID whenever someone calls. If you are not familiar with javascript/web, I suggest just using HABPanel as the URL for step 2.A.4.a. This is optional. You can always just use your webcam/blueiris feed. You can also use something else than chromium. I was initially using mplayer to play the Blue Iris stream on a headless OPiZero, but I figured chromium is better since I can easily create the web page.


  1. Install and Configure your Samsung TV Binding
    a. Properly link channels
  2. Security Camera is triggered through my Blue Iris Server
    a. Configure your camera(s)
  3. Configure Blue Iris or your camera to send a post when triggered.
    Blue Iris sends a POST request to my OpenHAB when triggered:

You can use MQTT if you have the latest version of Blue Iris. tv_pip_frontdoor_motion is just a Switch Item:

3. Items

Group:Switch gTvPip "TV PiP" (All)
Switch tvpip_familyroom_switch "TV PiP FamilyRoom" (gTvPip)
Switch tvpip_familyroom_switch_noscript "(noscript) TV PiP FamilyRoom" (gTvPip)
Switch tvpip_frontdoor_motion "TV PiP FrontDoor Motion" (gTvPip)

tvpip_familyroom_switch_noscript is just another item I can toggle without triggering any rule. Some caveats with Samsung TV Binding
When you send a PIP command, you cannot tell if it was successful or not. Usually it is. The issue here is that if there’s any timing issue with your Blue Iris or you already have the PIP on. What happens is BlueIRIS will still send the POST request, OH will issue the PIP command, and PIP will instead turn off (assuming PIP was already ON). With EXLINK, when you send a PIP, it gives you feedback/response through the UART port. The issue is mitigated/handled by the rule.

4. Rule

Note how we do not process the OFF state. We do this in a timer. This way, our item can receive multiple “ON”s and we only process it if the timer is not running already. tvpip_familyroom_switch is used by my HABPanel.

var Boolean isRuleEnabled = true
var Timer autoPipOffTimer = null
val autoPipOffTimerSeconds = 30
var Boolean isIgnoreCommand = false

rule "TV PIP On Off"
    Item tvpip_familyroom_switch received command
    if (isRuleEnabled) {
        sendCommand(samsungtv_tv_familyroom_keyCode, "KEY_PIP_ONOFF")
        if (receivedCommand === ON) {
            logInfo("TVPIP", "Received ON. Will turn off in " + autoPipOffTimerSeconds.toString + " secs.");
            if (autoPipOffTimer !== null) {
            } else {
                autoPipOffTimer = createTimer(now.plusSeconds(autoPipOffTimerSeconds), [|
                    if (tvpip_familyroom_switch.state == ON) {
                        logInfo("TV PIP", "Auto Off")
                    autoPipOffTimer = null;

rule "TV PIP Frontdoor rule"
    Item tvpip_frontdoor_motion changed to ON
    sendCommand(tvpip_familyroom_switch, ON)

rule "TV PIP On Off (NO SCRIPT)"
    Item tvpip_familyroom_switch_noscript received command
    sendCommand(samsungtv_tv_familyroom_keyCode, "KEY_PIP_ONOFF")

I highly recommend everyone to use isRuleEnabled as I did above. This allows me to enable/disable a rule with just a variable value change. The BlueIRIS “OFF” configuration (screenshot above) is for demonstration purposes only. My OH do not process the OFF at all. I do this from the rule above.. But I can see this useful for other people. BlueIRIS can send a POST request once the motion has “ended”

5. Hardware Setup

  1. Attach your 3.5mm cable to orangePi TV OUT jack
  2. Attach the other end of this cable to your CoAX converter
  3. Attach coax to your tv coax.
  4. Test pip work (even without signal)

Notes on hardware

I am not using a converter. I made my own. Note that coax is expecting RF signal. Im also not using the orange pi expansion board, I soldered mine to the orange pi pins (GND and pin 13). If your TV does not currently have an OH binding, and your TV does not have a developer port, you can still automate PIP using an infrared remote module. I did this on my old TV in the garage using ESP8266 and some IR emitters. Any questions, feel free to post

Simple HTML Minifier for ESP

A simple HTML minifier for ESP/microcontrollers


For embedded systems where memory is crucial, you’d want to save as much as possible. Even unnecessary spaces should be removed because every bit counts! What this code does is take your HTML code and minimizes it using regular expression. It DOES not minify the code like others do, it will simply remove unnecessary characters.

I use this primarily for ESP when a simple html code will be served using a lightweight webserver.

Minifying saved me 31% !

The magic happens here:

/* Remove comments (both html and js comments) */
.replace(/((<!--[\s\S]*?(?:-->)?<!---+>?|<!(?![dD][oO][cC][tT][yY][pP][eE]|\[CDATA\[)[^>]*>?|<[?][^>]*>?)|(\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$))/g, "")
.replace(/"/g, '\"') /* Escape quote */
.replace(/\s\s+/g, " ") /* Replace double spaces with a single space */
.replace("\r", "") /* Remove carriage returns */
.replace("\n", "") /* Remove new lines */
.replace(/\s*\(\s*/g, "(") /* Remove space before and after ( */
.replace(/\s*\)\s*/g, ")") /* Remove space before and after ) */
.replace(/\s*{\s*/g, "{") /* Remove space before and after { */
.replace(/\s*}\s*/g, "}") /* Remove space before and after { */
.replace(/\s*=\s*/g, "=") /* Remove space before and after = */
.replace(/\s*:\s*/g, ":") /* Remove space before and after : */
.replace(/\s*;\s*/g, ";") /* Remove space before and after ; */
.replace(/\s*,\s*/g, ",") /* Remove space before and after , */
.replace(/\s*>\s*/g, ">") /* Remove space before and after > */
.replace(/\s*<\s*/g, "<") /* Remove space before and after < */

HABPanel Universal Keypad Widget

Created a universal keypad for openHAB’s HABPanel interface. You can see the discussion here: Universal Keypad

Code is now open-source (GPL v3) here: GitHub/LuckyMallari

The key here is to make widget simple to use and edit by users so a large settings page was created. The entire widget also uses no Javascript code and is purely handled by events and techniques using AngularJS templates. All logic is done in the template itself. Requiring no JS code will be beneficial to new users with little to no experience in Javascript, particularly AngularJS





Settings page


Style-able through settings or CSS




Responsive design

First post!

Hi there folks! First post! Making history here.

I’m looking forward to sharing my thoughts and ideas here, whether it’s as complex as circuitry, as confusing as code, or as plain as describing what farting feels like.  I don’t write as much as I code, but hopefully I’ll be able to convey my thoughts in words exactly how I think of them so bare with me.

I have a few plans already lined up for the site. First, update the theme as you can see, it’s still the default one.  Still unsure though; I actually like the theme. It’s simple and elegant. I’ll create sections for coding, Arduino/IoT or electronics in general, Speed section (thing cars and motorcycles), and a “family” page. I have done a lot of things in my years of experience in the IT world, so one-by-one if time permits, I will share them all with you.

But for now, here’s a small poem.

The Name

Leaves of clovers
Under a tree
Caressing flowers
Kissing thee
Years of faith
Many hope for
And love the life
Luck's open doors
Lark at the scene
And let happiness reign
Remember me since
It's a damn good name!