Lua Script, Custom Sensor, Blockly.

Moderator: leecollings

Post Reply
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Lua Script, Custom Sensor, Blockly.

Post 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
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Lua Script, Custom Sensor, Blockly.

Post 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..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Lua Script, Custom Sensor, Blockly.

Post by StanHD »

Any ideas why this isn't working?

Thanks
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest