Page 1 of 1

[Help] Variable Question for Quindor's Sample Project

Posted: Thursday 10 December 2015 18:37
by jeremiahlandi
Hello,

I have followed the steps outlined by Quindor in his blog about setting up "ESP8266 WiFi LED dimmer Part 4 of X: Configuring Domoticz".
(http://blog.quindorian.org/2015/01/esp8 ... -of-x.html)

My question stems around the variables in the Domoticz Lua script:

DomDevice = 'GPIO-0_channel'
IP = '10.10.200.10'
Port = '43333'
LEDtarget = 'LED1_Target='

What are the targets of these variables and what should their values be (e.g. the ESP8266 or the Domoticz server)? I have them currently setup with my device IP and the same port; however, if i move my dimmer the LED doesn't dim on the device. Just want to make sure I am setting things up correctly.

Re: [Help] Variable Question for Quindor's Sample Project

Posted: Sunday 13 December 2015 12:38
by jeremiahlandi
I believe I have figured it out after some more rereading.

I believe my original assumption to be correct. The Variables are used to send an echo command in the script, so it makes sense it is telling the server what the device IP is to send it to. If this doesn't make sense or I am wrong please let me know.

Code: Select all

commandArray = {}

DomDevice = 'GPIO-0_channel'
IP = '10.0.1.8'
Port = '43333'
LEDtarget = 'LED1_Target='

 if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then DomValue = 0;
   print ("Turning off " .. DomDevice);
   runcommand = "echo " .. (LEDtarget) .. "0  | nc " .. (IP) .. " " .. (Port) .. " ";
   print (runcommand);
   os.execute(runcommand);
 return commandArray
   else
    DomValue = (otherdevices_svalues[DomDevice]);
   end
   CalcValue = DomValue * 33;
   print ("Value received from Domoticz was " .. (DomValue) .." ");
   print ("Calculated value for ESP is " .. (CalcValue) .." ");
   print ("Dimming "  .. (DomDevice) .. " to " .. (CalcValue) .. " ");
   runcommand = "echo " .. (LEDtarget) .. "" .. (CalcValue) .. " | nc " .. (IP) .. " " .. (Port) .. " ";
   print (runcommand);
   os.execute(runcommand);
 end
return commandArray