Skip to content

LED Strip Dimmer, MythTV integration


This task has been the easy part due to MythTV flexibility and only a few shell scripts was created:

  • Serial line initialization.
  • LED control (called lamp), which accepts commands like ‘on‘ / ‘off‘ to switch on (100 %) or off smoothly in 5 s, ‘half‘ to set to 50 % in 5 s, ‘shutdown‘ to switch off immediately and ‘switch‘ that enables to invert current state (on -> off, off -> 50 %) or if called two times quickly (double press on the remote control) while going from off to 50 % order to light to 100 %.
  • Relay control, which accepts commands ‘on‘ and ‘off‘ that turn the Relay on and off.

Serial line initialization

This script is called upon boot, and as the USB Serial emulation was prone to change its name under /dev, I finally setup a UDEV rule to have a fixed name ‘ttyUSB0’ under /dev.

For that, I googled a lot, and finally the procedure is the one described below.

Look at syslog and insert the Arduino Nano

This will tell what is the serial device used (here a pl2303) and the name under /dev (here ttyUSB0: ‘… now attached to ttyUSB0’)

Then issue the command below to have the exact attributes for UDEV:

And create the UDEV rule:

Finally the commsetup script is:

LED control

The LED control script just translates the ‘on’ / ‘off’ / ‘half’ / ‘shutdown’ / ‘switch’ parameters mentioned in the introduction into commands (of type ++Dc-vvv-ttt.t ) that are sent to the dimmer over the serial line.

The script is very basic: at the moment, all fade in / fade out have a fixed 5 second duration set within this script.

It is called by MythTV and also during shutdown. For MythTV, references to /path-to-dimmer-scripts/lamp script has been set on the Play / Pause / Stop / Resume… events using the management GUI. This is up to each personal taste…

Here is the source:

Relay control

This script is straightforward, it just translates ‘on’ / ‘off’ into commands of type ++Rc-v for the Relay that are sent to the dimmer over the serial line.

It is called when MythTV starts to switch off the ceiling lamps and power on the LED dimmer, and on shutdown to power off the LED dimmer and switch on the ceiling lamps.

The calls for Relay and Dimmer are inserted in the MtyTV /usr/share/mythtv/ script:

Here is the source:


Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *