LED Strip Lights

For a while now I’ve been wanting to add some LED Strips to my setup.

I wanted to get colour changeable strips that I could remotely control via DomotiGa.

I ended up getting 2 controllers based on the customisable H801 chip from AliExpress:

H801

H801

The downside is that I needed an Android Phone to set it up (Connect to my WiFi network), but once done, I no longer need the Android Phone.

In the future I’ll update the firmware to customise it and make it more secure, but for now it works relatively easy.

With advice taken from this post, I managed to create a simple script to send commands to the controller:

sendip -p ipv4 -is 192.168.4.15 -p udp -us 30978 -ud 30977 -d 0xfbeb000000000079979d00 -v 192.168.4.131
  • The first IP address is the address the command is sent from
  • The second IP address is the address of the H801 controller
  • The actual command is made of several parts: 0xfbeb 0000000000 79979d 00:
    • 0xfbeb is constant
    • Next come the hex values for the colours R G B W1 W2 (0000000000)
    • Then comes part of the controller’s MAC Address, in reverse order. The MAC Address is 18:fe:34:9d:97:79
    • The last bit (00) is again constant

This simple method allows me to easily switch the strip on and off and change its colour, and the results are quite impressive:

LED Strip Under TV Cabinet

LED Strip Under TV Cabinet

LED Strip Staircase

LED Strip Staircase

 

Because I have 2 controllers, I wanted to use a single script and parse as an argument the controller number that I wanted to communicate with.

The end result is the below script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import time
import sys
import subprocess

LEDStripBase="echo PASSWORD | sudo -S sendip -p ipv4 -is 192.168.0.24 -p udp -us 30978 -ud 30977 -d 0xfbeb"
LEDStrip1="000063509900 -v 192.168.0.40 > /dev/null"
LEDStrip2="000091559900 -v 192.168.0.41 > /dev/null"
# Kill the Xmas script if running
cmd="echo PASSWORD | sudo -S pkill -9 -f LEDStripXmas"
ps = subprocess.Popen(cmd, shell=True)
time.sleep(0.1)

if(len(sys.argv[2])==1):
	MyParam2 = "0" + hex(int(sys.argv[2]))[2:]
else:
	MyParam2 = hex(int(sys.argv[2]))[2:]

if(len(sys.argv[3])==1):
	MyParam3 = "0" + hex(int(sys.argv[3]))[2:]
else:
	MyParam3 = hex(int(sys.argv[3]))[2:]

if(len(sys.argv[4])==1):
	MyParam4 = "0" + hex(int(sys.argv[4]))[2:]
else:
	MyParam4 = hex(int(sys.argv[4]))[2:]

try:
	if(sys.argv[1] == '1'):
		cmd = LEDStripBase + MyParam2 + MyParam3 + MyParam4 + LEDStrip1
		ps = subprocess.Popen(cmd, shell=True)
	if(sys.argv[1] == '2'):
		cmd = LEDStripBase + MyParam2 + MyParam3 + MyParam4 + LEDStrip2
		ps = subprocess.Popen(cmd, shell=True)

except:
	pass

Note: I only soldered the RGB and Vcc pins as I’m not looking to use the white channels, hence the hard coded 0000 in the above script

All I need to do now to change the colour [to purple on the 1st controller) is to call the script as follows:

LEDStrip 1 255 0 255

 

Now to take it to the next level, I created a separate script to slowly run through the colour spectrum. I mainly run it at Christmas so called it LEDStripXmas.py (hence the command in previous script to kill this one if running):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import time
import sys
import subprocess

LEDStripBase="echo PASSWORD | sudo -S sendip -p ipv4 -is 192.168.0.24 -p udp -us 30978 -ud 30977 -d 0xfbeb"
LEDStrip1="000063509900 -v 192.168.0.40 > /dev/null"
LEDStrip2="000091559900 -v 192.168.0.41 > /dev/null"

colors=[255,0,0]
while(True):
	# Cycle through RGB Spectrum
	colors[0]=255
	colors[1]=0
	colors[2]=0
	for decColour in range(0,3,1):
		if(decColour == 2):
			incColour = 0
		else:
			incColour = decColour + 1
		for i in range(0,255,1):
			colors[decColour] = colors[decColour] -1
			colors[incColour] = colors[incColour] +1
			R = hex(colors[0])[2:]
			if(len(R)==1):
				R = "0" + R
			G = hex(colors[1])[2:]
			if(len(G)==1):
				G = "0" + G
			B = hex(colors[2])[2:]
			if(len(B)==1):
				B = "0" + B
			if(sys.argv[1] == '1'):
				cmd = LEDStripBase + R + G + B + LEDStrip1
			else:
				cmd = LEDStripBase + R + G + B + LEDStrip2
			ps = subprocess.Popen(cmd, shell=True)
			time.sleep(0.1)

For the below movie, I’ve reduced the wait time (normal cycle takes about 1 min)

I then added the strips as devices in DomotiGa.

They are added as virtual devices, with Value1 being the strip’s status (on|off) and values 2,3,4 carrying the decimal value of the R G B colours respectively:

LED Strips - DomotiGa

LED Strips – DomotiGa

Then all I had to do is to call an action when one of the values of the device changes:

LEDStrip.py 1 <$188|2$> <$188|3$> <$188|4$>

And finally in SmartVISU I added a device:

LED Strip SmartVisu

LED Strip SmartVisu

Clicking on the colour brings the colour picker:

ED Strip SmartVisu Colour Picker

ED Strip SmartVisu Colour Picker