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):
- Camera motion triggered -> Send to openHAB
- openHAB triggers PIP on TV
- PIP video feed comes from the Orange Pi through the COAX cable.
SOME NOTES
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.
- Samsung TV
-
(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. - Orange Pi Zero Expansion board (OPTIONAL) such as this
- Video to CoAx such as this
- 3.5mm RCA cable such as this
- Camera with a network-based stream (RTSP, H264, MJPEG, etc)
- Micro SD Card for your OPi
B. Software
-
Armbian for Orange Pi Zero
Or any ARM-based OS that can run on the orange pi - Desktop Software for your hardware. I used XFCE
- Chromium for ARM
- OpenHAB Samsung TV Binding
- Blue Iris (Optional)
2. Setup
A. Software
-
Flash your OPiZero with the armbian image
a. Enable SSH -
Install XFCE
-
Install Chromium
-
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.
Setup/How-to
-
Install and Configure your Samsung TV Binding
a. Properly link channels -
Security Camera is triggered through my Blue Iris Server
a. Configure your camera(s) -
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"
when
Item tvpip_familyroom_switch received command
then
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) {
autoPipOffTimer.reschedule(now.plusSeconds(autoPipOffTimerSeconds));
} else {
autoPipOffTimer = createTimer(now.plusSeconds(autoPipOffTimerSeconds), [|
if (tvpip_familyroom_switch.state == ON) {
tvpip_familyroom_switch.sendCommand(OFF);
logInfo("TV PIP", "Auto Off")
}
autoPipOffTimer = null;
]);
}
}
}
end
rule "TV PIP Frontdoor rule"
when
Item tvpip_frontdoor_motion changed to ON
then
sendCommand(tvpip_familyroom_switch, ON)
end
rule "TV PIP On Off (NO SCRIPT)"
when
Item tvpip_familyroom_switch_noscript received command
then
sendCommand(samsungtv_tv_familyroom_keyCode, "KEY_PIP_ONOFF")
end
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
- Attach your 3.5mm cable to orangePi TV OUT jack
- Attach the other end of this cable to your CoAX converter
- Attach coax to your tv coax.
- 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.