_p216 - Simple RGB Strip Controller + RGW Switch with Selector in Domoticz

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

_p216 - Simple RGB Strip Controller + RGW Switch with Selector in Domoticz

#1 Post by countcobolt » 29 Jun 2018, 16:32

Hi all

after following the the online tutorial from http://www.twoenter.nl/blog/arduino-esp ... -domoticz/ I noticed that _P142 no longer compiled and also that it was too much for what I need. Hence I started to design my own (based on the P142 plugin) and came up with a smaller and for my needs better plugin.

Basically it has 2 commands : RGB & off and sets the PWM of the different pins in use for the hardware. The function RGB is used like RGB,R,G,B,Brightness.Do set the 4 parameters as elsewise the brightness is 0.

Next I cheated a bit with domoticz. By Default Domoticz does not allow you to read the RGB value via LUA. The work around is to create a bash script that reads the values direct from the SQLite database.

Bash Script:

Code: Select all

values=`sqlite3 /CHANGE_PATH_TO_RIGHT_LOCATION/domoticz.db "Select svalue,color,nvalue from DeviceStatus where ID='94'";`
array=(${values//|/ });
R=`echo "$RGB_JSON" | jq '.r'`;
G=`echo "$RGB_JSON" | jq '.g'`;
B=`echo "$RGB_JSON" | jq '.b'`;
echo $status;
if [ "$status" = "1" ]; then
echo "Lights are on";
echo $URL > /home/kodi/domoticz/led_log.log;
echo "Lights are off";
echo $URL > /home/kodi/domoticz/led_log.log;
wget 0 /dev/null -q $URL
Remember to change the IP to the IP or your RGB controller and change the location of your sqlite database. Also you need jq installed on your machine. Copy this script in the scripts/bash folder

Next we need to set up a lua script to run on the change and run this bash script

Code: Select all

commandArray = {}
print('LEDSTRIP: This is getting send to the log file');
os.execute ("/CHANGE TO DOMOTICZ LOCATION/domoticz/scripts/bash/set_ledstrip.sh")
return commandArray
save this in the scripts/lua folder and call it to script_device_YOUR_DEVICE_NAME.lua

Caveats: for some reason on the mobile app for domoticz, I can set the color and then need to turn the lights back on. They turn of when changing the color

Kind regards

(2.22 KiB) Downloaded 116 times

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests