question-325

About

Information about pembo.co.uk and my history

View details
tetwiis-header

TetWiis (Wii)

TetWiis is a Nintendo Wii homebrew clone of the falling blocks classic

View details
inf-prime-small2

Infinite Prime

App for Windows Phone 7/8 available from the windows phone store

View details
downloads

Downloads

Access the various downloads from this site all from one place

View details

2014 +

So, on my drive to improve my home automation and connect my things together. My next great drive towards this is to connect my Enigma2 based satellite receiver to Samsung SMART TVs in other rooms of the house using streaming video over the LAN.

Much to my surprise, there wasn’t too much around that made this possible, so I’ve started putting something together myself and already have a working proof of concept.

This works using the enigma 2 apis and OpenWebIF. Will retrieve the bouquet list from the receiver and present this, and then will fetch the picon and epg entry for each channel as you browse the list. You can play the video in the small window or full screen.

2014_Smart_TV_Emulator_5_1_small

It’s not quite ready for public consumption yet… there’s still a few things to do to make it friendly to use.  Once nearing completion though, I will release a beta of this.


2014 +

Having purchased a NAS server recently, I wanted to ‘record’ DVB TV from windows media center onto the NAS Server disks rather than locally, so recorded programs would be available via DLNA.

Much to my surprise, I couldn’t setup MCE to do this, and any nas compatible options were not compatible with my DVB-S USB stick, so, I worked around this.

Using a command script/batch file, and windows scheduler, I’ve been able to schedule a recording in the TV Guide, then convert and copy to the NAS Drive in a DLNA compatible format!

At first, I started using SyncToy, but changed this later on as it wasn’t really needed.

The script works as follows:

  1. Moves the MCE wtv file to a temporary directory if it’ not in use (i.e a recording currently taking place)
  2. In the temp directory, converts to DVR-MS, and then to MPEG via FFMPEG
  3. Moves the MP4 to a target folder on the NAS Server.

Then I create a schedule that starts on bootup, and runs every hour after.  The script also logs out to a logfile so that you can see what happens during schedule execution.

The end result, I can schedule a recording within the guide, and within an hour of completion of the program, this is available on the NAS Server via DLNA to my smart TV.

So, here it is.
To make this work, you’ll need to modify the configuration, and grab a copy off FFMPEG.


@echo off

rem ___________________________________________________________________________
rem
rem Configurable Settings
rem ___________________________________________________________________________

set datetimef=%date:~-4%_%date:~3,2%_%date:~0,2%
set LOGFILE=c:\scripts\moveTV\moveTV_%datetimef%.log

set TEMPTV=c:\scripts\moveTV\temp
set MCERECORDEDTV=C:\Users\Public\Recorded TV
set WTVCONVERTER=C:\Windows\ehome\wtvconverter.exe
set FFMPEG=C:\Scripts\ffmpeg\bin\ffmpeg.exe
set TARGET=\\homenas\multimedia\My Videos\Recorded TV
set LOCKFILE=C:\Scripts\moveTV\lockfile

rem ___________________________________________________________________________
rem
rem Check Lockfile
rem If lockfile exists (script still running) then terminate
rem else create the lockfile
rem ___________________________________________________________________________
rem

echo Checking lockfile
if exist %LOCKFILE% GOTO TERMINATE

echo Running > %LOCKFILE%
date /T >> %LOCKFILE%
time /T >> %LOCKFILE%

rem ___________________________________________________________________________
rem
rem Roll over log file
rem If we're on the 1st of the month start a new logfile
rem ___________________________________________________________________________
rem

set DATE=%date%
set DAY=%DATE:~0,2%
echo %DAY%

set TIME=%time%
set TIMe=%TIME:~-0,2%
echo %TIME%

rem Delete any log files older than 3 days
for /f "skip=3 eol=: delims=" %%F in ('dir /b /o-d moveTV*.log') do @del "%%F"

rem ___________________________________________________________________________
rem
rem Initilise
rem ___________________________________________________________________________

echo.
echo +-------------------------------------+
echo   Transfer Recorded TV to NAS Server  
echo +-------------------------------------+
echo.

echo. >> %LOGFILE%
echo == Started Transfer of TV ============
echo == Started Transfer of TV ============ >> %LOGFILE%
echo Start Date:
date /T
time /T
date /T >> %LOGFILE%
time /T >> %LOGFILE%

rem ___________________________________________________________________________
rem
rem Move recorded TV to temp directory for conversion
rem ___________________________________________________________________________

for %%f in ("%MCERECORDEDTV%\*.wtv") do (
  echo Checking File: %%~nf
  (
    type nul >> "%MCERECORDEDTV%\%%~nf.wtv"
  ) 2>nul && move "%MCERECORDEDTV%\%%~nf.wtv" "%TEMPTV%" >> %LOGFILE% || echo File %%~nf.wtv Skipped - Is currently in use >> %LOGFILE%
  
)

echo Moved Files to Temporary Location

rem ___________________________________________________________________________
rem
rem Move Convert *.WTV files in the temp directory to dvr-ms and then MP4
rem ___________________________________________________________________________

for %%f in ("%TEMPTV%\*.wtv") do (

  echo Converting File: %%~nf
  echo Converting File: %%~nf >> %LOGFILE%
  echo ---------------------------------------------------------------
  %WTVCONVERTER% "%TEMPTV%\%%~nf.wtv" "%TEMPTV%\%%~nf.dvr-ms"  >> %LOGFILE%
  rem %FFMPEG% -i "%TEMPTV%\%%~nf.dvr-ms" -y -filter:v yadif -vcodec libx264 -crf 15 "%TEMPTV%\%%~nf.mp4" >> %LOGFILE%
  %FFMPEG% -y -i "%TEMPTV%\%%~nf.dvr-ms" -vcodec copy -acodec copy -f dvd "%TEMPTV%\%%~nf.mpg" >> %LOGFILE%
  echo Conversion Complete - deleting original DVRMS and WTV
  echo File %%~nf Conversion complete
  echo Conversion of File: %%~nf Complete >> %LOGFILE%
  echo Moving File: %%~nf.mpg to %TARGET%
  echo Moving File: %%~nf.mpg to %TARGET% >> %LOGFILE%
  move /Y "%TEMPTV%\%%~nf.mpg" "%TARGET%"

  
  rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  rem !!!!! Delete the recorded MCE program? !!!!!
  rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  del "%MCERECORDEDTV%\%%~nf.wtv"

  rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  echo.
  echo ---------------------------------------------------------------
)

echo Sync Complete

rem ___________________________________________________________________________
rem
rem Cleanup files in the temp folder and the 'recorded tv folder' if needed
rem ___________________________________________________________________________

echo Cleanup of converted files

del "%TEMPTV%\*.dvr-ms"
del "%TEMPTV%\*.wtv"
del "%TEMPTV%\*.mpg"

echo.

del %LOCKFILE%

GOTO END

rem ___________________________________________________________________________
rem
rem FUNCTIONS
rem ___________________________________________________________________________

:TERMINATE
echo LOCKFILE exists... terminating

rem ___________________________________________________________________________
rem
rem END
rem ___________________________________________________________________________

:END
time /T
time /T >> %LOGFILE%
echo *** Done ***
echo *** Done *** >> %LOGFILE%

If you find this useful, please just let me know with a thanks ;-)

2014 +

I’ve been working hard on updating the Lightwave RF Control development to take it out of beta.

I’ve resolved a number of issues/bugs, added multiple device queuing to the arduino code and therefore the ability to power off/on an entire room as shown in the screen shot below.  This required introduction of another serial message format to pass to the transmitting device from the web application, and an separation of some of the serial code/transmission to help with this.  It also required rethinking the UI a little to group controls on the screen better, and introduce (and differentiate) the whole room option where there is more than one device in the room.   This transmits a queue of devices to power on/off each device in the room sequentially.

screen

I’m still ironing out the last few bugs, but this should be released soon for anyone interested once I’ve put the ‘sequence’ code together to allow you to create your own sequences!


2014 +

Due to a few requests, here’s the initial release of Lightwave RF Control!

This release contains two parts

  1. Arudino Sketch and libraries needed to compile this
  2. PHP Web Application

To get this working, you might want to take a look at the write up of the implementation, which details the arduino circuit to put together, and the setup of the php application itself.

The PHP web application needs MySQL, and should create the database on startup, though you’ll need to ensure after unzipping that the ‘config.php’ has necessary write permissions for the web user (chmod 777 the config.php file if you’re lazy like me  :-) )

Download Lightwave RF Control

 

Like this – buy me a beer?

 


2014 9

The following describes the process and setup of how I made my Lightwave RF device controller, from an arduino, a few components, and a Raspberry Pi.

This post will grow out with more information as I add it, but this in in the position now where it’s ready to be put out there.

Downloads

This release contains two parts

  1. Arudino Sketch and libraries needed to compile this
  2. PHP Web Application

To get this working, you might want to read through the rest of this which details the Arduino circuit to put together, and the setup of the php application itself.

The PHP web application needs MySQL, and should create the database on startup, though you’ll need to ensure after unzipping that the ‘config.php’ has necessary write permissions for the web user (chmod 777 the config.php file if you’re lazy like me  :-) )

Download Lightwave RF Control

 

Components/Tools Requied:


Assembly

The following diagram shows a simplified assembly. Note the LCD Serial module is one whole module, just shown as two separate components on the diagram. The transmitter is a 433.92Mhz (called 433 or 434MHz transmitters from various places)

component layout_bb

Assembly Instructions

  1. 433.92MHz transmitter – attach the data pin to digital pin 3. Supply a +5V and ground from the breadboard
  2. LCD I2C Serial Module – has a 4 pin connection. 2 for data, and the +5V and ground. Although this is shown in the diagram as 2 components, they can be purchased as a single module. The module can be wired either with a set of jumper cables (female to male), or via a 4 pin cable and some header pins into the breadboard, and then cables from there to the Arduino. Data connections are wired into analogue pins 4 and 5
  3. Transmitted LED. Wire in ground, and Pin 13 as the power
  4. Soldered a 17.3cm coiled wire to the transmitter to extend the range

Wired into a breadboard (messily unlike the diagram above) here’s what my prototype looked like:

prototype

3 areas of interest are highlighted in the photo

  1. Left – 4 pin cable, connected into the breadboard via header pins (which fell out pretty easily!). This goes to the LCD I2C Serial display
  2. Right top – 3 pin connector to the transmitter module. Here I used a screw terminal connector, as my cable was recycled from an old computer PSU so there was only a 3 pin connector on one end.
  3. Right middle – the transmitter, connect by a 3 pin cable, note the coiled cable for the antenna. The recommended length appeared to be 17.3cm

Note – the transmitting LED was not connected here. For prototype, I just relied on the one inbuilt into the Arduino on pin 13

Prototype was tested using the serial monitor within the Arduino IDE by placinf a lightwave RF device in pariring mode, and supplied the following command over serial:

#111235190237183123100Lounge*

 

 

The format of the message is as follows

Description Length Values Example Notes
Start 1 # # Start with a #
Transmitted ID 18 [0-9](18) 111235190237183123 Has to be 18 chars
On/Off 1 [0/1] 1 1=on 0=off
Dim Level 2 [00-31] 31 31 = Max
01 = Min00 = Ignore
Description 15 [aA-zZ] Lounge Up to 15 characters – if more will wrap around
End 1 * * End with a *

 


Finished Product

Assembly instructions

  1. Wired and soldered all components into the strip board, simplified over the breadboard layout slightly
  2. Using the multi-tool, cut opening in the lid suitable for the LCD screen
  3. Drill small hole in the lid big enough to push through the LED
  4. Drill hold in right hand side for antenna cable
  5. Mount Arduino onto hexagonal spacers using screens.
  6. Align Arduino inside project box, mark and cut hole using rotary multi-tool for the USB cable.
  7. Use glue gun to glue Arduino/spacers to the project box
  8. Use glue to stick LCD display (and LED if needed) into place on the lid
  9. Use glue gun or sealant to seal the display lid and fill and gaps
  10. Glue spacers on strip board, glue to project box base.
  11. Glue spacers in project box to hold the transmitter in place

Photos

inbox01

inbox02

completebox

 


Raspberry PI Setup

Installation

  1. Install Apache/PHP and MySQL on the raspberry pi
  2. Unzip the developed web application into the webserver.
  3. Using a browser on the network, connect into the URL where you unzipped the device to. This should open the setup/installation screen.
    installation
  4. Configure the COM Port to that of the Arduino, and provide the database settings needed, then press the ‘Next >>’ button to install. If there are any errors, observe the message and correct as needed (e.g. permissions on the config.php file)

Device Setup

Once installation has been completed successfully, you’ll be taken to the setup wizard to add any Lightwave devices you may have:

 

Step through the wizard to

a) Select or create a room – devices are grouped by room in the user interface
step1

b) Add the receiver (The actual lightwave RF device). Here you add give it a description and select the type of receiver, e.g. dimmer, socket, relay, etc.
step2

c) Following addition of the receiver is to create a transmitter identifier. This uniquely allows the transmitter to be associated with a single receiver, or multiple receivers. For example, you can reuse the same transmitter for a room to turn on more than one device from the same command. You’ll notice in the following screenshot that the final transmitter covers 2 receivers. If you want the control to be unique, just pick new transmitter and enter a description.
step3

d) That’s enough configuration and your room, receiver and transmitter are all recorded and linked. The final stage is to actually pair the transmitter and receiver together. To do this, you need to put your receiver into pairing mode (e.g for a dimmer, hold both buttons. For a socket hold the single button. For relay, push in and hold the pairing button with a pen).
step4
Once the device shows it’s in pairing mode (usually by flashing the lights) you need to transmit a code for the transmitter. The wizard allows you to do this, and then once the receiver confirms a pairing, you can test this with the off/on buttons.

Once paired, finally press the finish button.

Device Control

You’ll then be presented with the device control screen where you can control your Lightwave RF devices
devicecontrol

 

From here you can select the room, and chose to power on/off the devices, and where the device is a dimmer, you can choose to adjust the dim by clicking or touching the dim ‘gradient’ bar.

If you want to change the setup or reinstall, you can use the menu in the top left corner.
menu

 

On transmission, it should looks like this!

boxon

 

Like this – buy me a beer?