Page 1 of 1

Lua Script, Custom Sensor, Blockly.

Posted: Thursday 11 August 2016 18:13
by StanHD
Hi,

Domoticz Ver 3.5412 - Windows

As Blockly does not have math I have made a counter in Lua that updates a Custom Sensor. This works:-

Code: Select all

counter = otherdevices_svalues['Custom1']
counter = tonumber(counter)
commandArray = {}
if 
   devicechanged['Test'] == 'On'
then
   counter = counter + 1
   commandArray['UpdateDevice'] = 1247 .. '|0|' .. tostring(counter)
elseif
    devicechanged['Test'] == 'Off'
then
   counter = counter - 1
   commandArray['UpdateDevice'] = 1247 .. '|0|' .. tostring(counter)
end

return commandArray
The Custom Sensor Updates:-

Image Image

I have made a simple Blockly script to test, but this does not work, even though the Custom Sensor is changing correctly:-

Image

If I update the Custom Sensor via JSON, then the Blockly responds correctly.
I have also tried using the "Counter" sensor and "User Variables", which all work with the Lua script, but still the Blockly will not respond.

Any ideas?

(This is not my final goal. When I can get it to work I want to add the logic to a Blockly that controls my Velux windows so that I can determine the position of the windows as they are incrementally opened and closed under temperature control)

Thanks

Re: Lua Script, Custom Sensor, Blockly.

Posted: Thursday 11 August 2016 21:12
by Derik
should i use something like this for cunting hours?
I need a script that is counting how long my UVB light is burning..

Re: Lua Script, Custom Sensor, Blockly.

Posted: Wednesday 17 August 2016 8:31
by StanHD
Any ideas why this isn't working?

Thanks