Variable for Blockly

Easy to use, 100% Lua-based event scripting framework.
Post Reply
Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Variable for Blockly

Post by Jubbes » Wednesday 24 October 2018 16:53

Hello, is it possible to make a Variable that i can use in Blockly?
The variable should say 15 min. before sunset.

In Blockly then:
if time = new variable `sunset-10min` then .......


Jubbes

User avatar
waaren
Posts: 1344
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Variable for Blockly

Post by waaren » Wednesday 24 October 2018 20:24

You can set the value of a User variables created in Domoticz with dzVents at the time you want (in this case 15 minutes before sunset) or when a certain event occurred. And this can trigger a Blockly like the attached when saved as to be started on UserVariable events
Blockly.png
Blockly.png (20.22 KiB) Viewed 282 times
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Variable for Blockly

Post by Jubbes » Wednesday 24 October 2018 20:32

can you show me this script with user value in dzVents???? 15min before sunset. Thank you

User avatar
waaren
Posts: 1344
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Variable for Blockly

Post by waaren » Wednesday 24 October 2018 21:13

Jubbes wrote:
Wednesday 24 October 2018 20:32
can you show me this script with user value in dzVents???? 15min before sunset. Thank you
Below how to set (and reset) the value of the domoticz user Variable named "Alarm" of type string.

Code: Select all

--  setvar 

return {
        on = {  timer =         { "15 minutes before sunset" }},
              
        logging =   {   level   = domoticz.LOG_DEBUG,                        -- INFO, DEBUG or ERROR
                        marker = "setvar" },                         

    execute = function(dz, item)
        domoticz.variables("Alarm").set("On")                                 -- set to On
        domoticz.variables("Alarm").set("Off").afterSec(60)                   -- set to Off after 60 seconds
    end
}
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Variable for Blockly

Post by Jubbes » Wednesday 24 October 2018 21:24

and now what i do in blockly is:

if alarm = on do. set scene......... = on


korrect?

User avatar
waaren
Posts: 1344
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Variable for Blockly

Post by waaren » Wednesday 24 October 2018 21:39

Jubbes wrote:
Wednesday 24 October 2018 21:24
and now what i do in blockly is:

if alarm = on do. set scene......... = on


korrect?
That is a possibility but why should you do that ? Anything that can be done with Blockly, can be done with dzVents and a whole lot more..

Look at the video Danny (creator of dzVents) posted and the wiki to get an idea of the possibilities when learning this framework for using Lua with domoticz.
Last edited by waaren on Wednesday 24 October 2018 21:44, edited 1 time in total.
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Variable for Blockly

Post by Jubbes » Wednesday 24 October 2018 21:43

i know, but i am a absolute beginner in domoticz, blockly and dzVents.
Thank you very very much for your help !!!!!


The value Alarm can have every name?

User avatar
waaren
Posts: 1344
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Variable for Blockly

Post by waaren » Wednesday 24 October 2018 21:47

Jubbes wrote:
Wednesday 24 October 2018 21:43
i know, but i am a absolute beginner in domoticz, blockly and dzVents.
Thank you very very much for your help !!!!!


The value Alarm can have every name?
Yes it can have any name as long as you change it in domoticz, dzVents and Blockly to keep it aligned . Also have a look at my (edited) previous post. Now with links to the wiki and youtube video on dzVents.
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Jubbes
Posts: 8
Joined: Wednesday 24 October 2018 14:35
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Variable for Blockly

Post by Jubbes » Thursday 25 October 2018 21:09

The script doesnt run. What must i do in more options / user variables?

User avatar
waaren
Posts: 1344
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Variable for Blockly

Post by waaren » Thursday 25 October 2018 21:34

Jubbes wrote:
Thursday 25 October 2018 21:09
The script doesnt run. What must i do in more options / user variables?
My mistake, sorry. Should be:

Code: Select all

--  setvar 

return {
        on = {  timer =         { "15 minutes before sunset" }},
              
        logging =   {   level   = domoticz.LOG_DEBUG,                        -- INFO, DEBUG or ERROR
                        marker = "setvar" },                         

    execute = function(domoticz, item)
        domoticz.variables("Alarm").set("On")                                 -- set to On
        domoticz.variables("Alarm").set("Off").afterSec(60)                   -- set to Off after 60 seconds
    end
}
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests