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
#!/bin/bash
IP="192.168.5.72"
values=`sqlite3 /CHANGE_PATH_TO_RIGHT_LOCATION/domoticz.db "Select svalue,color,nvalue from DeviceStatus where ID='94'";`
array=(${values//|/ });
Br=${array[0]};
status=${array[2]};
RGB_JSON=${array[1]};
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";
URL="http://$IP/control?cmd=rgb,$R,$G,$B,$Br";
echo $URL > /home/kodi/domoticz/led_log.log;
else
echo "Lights are off";
URL="http://$IP/control?cmd=rgb,0,0,0,0";
echo $URL > /home/kodi/domoticz/led_log.log;
fi
wget 0 /dev/null -q $URL
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
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
Steve