timer in Blockly

Moderator: leecollings

Post Reply
har0543
Posts: 18
Joined: Wednesday 06 January 2016 11:34
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Dalfsen netherlands
Contact:

timer in Blockly

Post by har0543 »

Hello

I have perhaps a very simple question but I did not find an answer.
I have connected blinds in Domoticz and the work fine. Closing and opening can be done with my phone.

I also have connected a lux sensor. I can control the blind with a Blockly with a amount of light.
But when the weather is cloudy the blinds go up and down all the time.
Is there an option to say p.a. when the amount of lux is for 10 minutes above a setvalue the blinds are to be closed?

Thanks for reading and i hope some advice
Har
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer in Blockly

Post by waaren »

har0543 wrote: Tuesday 14 July 2020 19:52 I also have connected a lux sensor. I can control the blind with a Blockly with a amount of light.
But when the weather is cloudy the blinds go up and down all the time.
Is there an option to say p.a. when the amount of lux is for 10 minutes above a setvalue the blinds are to be closed?
I don't think this is possible in Blockly. You need dzVents or one of the other script options available to do this.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
har0543
Posts: 18
Joined: Wednesday 06 January 2016 11:34
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Dalfsen netherlands
Contact:

Re: timer in Blockly

Post by har0543 »

Thanks for the info.
In Dzvent I did not find such an option.
any idears?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer in Blockly

Post by waaren »

har0543 wrote: Wednesday 15 July 2020 20:57 Thanks for the info.
In Dzvent I did not find such an option.
any idears?
Could look like

Code: Select all

return
{
    on =
    {
        devices =
        {
            'luxSensor',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
        marker = 'delayed blinds',
    },

    execute = function(dz, item)
        local lightFence = 3500             -- change to required uv
        local blind = dz.devices('blindName') -- change to name of you blind
        local delay = 600                     -- change to delay in seconds

        dz.log('Blind state = ' .. blind.state, dz.LOG_DEBUG)
        dz.log('Measured Lux = ' .. blind.lux, dz.LOG_DEBUG)

        if item.lux > lightFence then
            blind.close().checkFirst().afterSec(delay)
        else
            blind.cancelQueuedCommands()
            if blind.lastUpdate.secondsAgo > delay and blind.state == 'Closed' then
                blind.open()
            end
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
har0543
Posts: 18
Joined: Wednesday 06 January 2016 11:34
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Dalfsen netherlands
Contact:

Re: timer in Blockly

Post by har0543 »

thanks! give it a try
wouterlet
Posts: 109
Joined: Tuesday 02 October 2018 20:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: timer in Blockly

Post by wouterlet »

Blocky should also be possible I guess. You could use a dummy switch. If lux is desired level then switch dummy switch on after 10 minutes.
Elseif dummy switch is on then close curtain.
Elseif lux is less then dummy switch off

Hope it's clear to you. But this makes a timer in blocky
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer in Blockly

Post by waaren »

wouterlet wrote: Saturday 18 July 2020 22:15 Blocky should also be possible I guess. You could use a dummy switch. If lux is desired level then switch dummy switch on after 10 minutes.
Elseif dummy switch is on then close curtain.
Elseif lux is less then dummy switch off

Hope it's clear to you. But this makes a timer in blocky
I guess you are right. This Blockly does work
curtain.png
curtain.png (110.74 KiB) Viewed 1868 times

XML (import in event editor)
Spoiler: show
[code<xml xmlns="http://www.w3.org/1999/xhtml"><block type="domoticzcontrols_ifelseif" id="tZGc@Y;ufY,:BW7G0QF/" x="-443" y="-505"><mutation elseif="3"></mutation><value name="IF0"><block type="logic_compare" id="Ht8:A7wX]L]5w}4P~YU|"><field name="OP">GT</field><value name="A"><block type="utilityvariablesGL" id="4a#nYF!EEz?(Kl!xfSL~"><field name="Utility">410</field></block></value><value name="B"><block type="math_number" id="mqcBOximchspTnduL?:K"><field name="NUM">110</field></block></value></block></value><statement name="DO0"><block type="logic_setafter" id="(g*^h@TQ2Irt`.Y6}V%n"><value name="A"><block type="switchvariablesGL" id="@{f-;t:WQBrRdS=$#ud@"><field name="Switch">409</field></block></value><value name="B"><block type="logic_states" id="w1Iub6|upF^f]fH(Va]V"><field name="State">On</field></block></value><value name="C"><block type="math_number" id="39AjF;}NL5ma#h1n_dxl"><field name="NUM">600</field></block></value><next><block type="writetolog" id="7M2*8L2H{K;:xFgT3sMU"><value name="writeToLog"><block type="text" id="3ub.l#P7m0jtdD-l:^|1"><field name="TEXT">Lux &gt; fence ==&gt;&gt; Helper on after 600 seconds</field></block></value></block></next></block></statement><value name="IF1"><block type="logic_operation" id="BIc^5I8QKe24%HA|lZ8]"><field name="OP">AND</field><value name="A"><block type="logic_compare" id="e?2D_+!_1u;S+-N:@-Z{"><field name="OP">EQ</field><value name="A"><block type="switchvariablesGL" id="Y/`Tj)77-DQf(C{bxPMq"><field name="Switch">409</field></block></value><value name="B"><block type="logic_states" id="loDPIW?K*KRCaH7]h;fu"><field name="State">On</field></block></value></block></value><value name="B"><block type="logic_compare" id="+Pz5V}NKDsU-petg0$;X"><field name="OP">GT</field><value name="A"><block type="utilityvariablesGL" id="v=?PC:v5-AEo{8qNJxVV"><field name="Utility">410</field></block></value><value name="B"><block type="math_number" id="00NsHFgy4gE8z{-wqH/o"><field name="NUM">110</field></block></value></block></value></block></value><statement name="DO1"><block type="logic_set" id="sG=Fw*A1;LNLi$M79XgN"><value name="A"><block type="switchvariablesAF" id="N60he$o84E}c9d06^%}C"><field name="Switch">411</field></block></value><value name="B"><block type="logic_states" id="Ura-Jw#tmR)C(bO^zi9W"><field name="State">On</field></block></value><next><block type="writetolog" id="h/P`%J]e!1GuJA0jOsz$"><value name="writeToLog"><block type="text" id="B2,%sFpfLY|TrubNsQyd"><field name="TEXT">Helper on ==&gt;&gt; Curtain down</field></block></value></block></next></block></statement><value name="IF2"><block type="logic_compare" id="UlLH4t*9~7v8p_KuE^Nn"><field name="OP">LT</field><value name="A"><block type="utilityvariablesGL" id="M/+q#bVqJ[Z5,2?C4`K)"><field name="Utility">410</field></block></value><value name="B"><block type="math_number" id="po|+@h[_x~2;!blz/S|]"><field name="NUM">110</field></block></value></block></value><statement name="DO2"><block type="logic_setafter" id="$?Q8Ap9o=r}6oI5_w#4N"><value name="A"><block type="switchvariablesGL" id=":eQ3[9kUnyL]=!,3cw+Y"><field name="Switch">409</field></block></value><value name="B"><block type="logic_states" id="VS4-H.LdYJeOxyyE-r%{"><field name="State">Off</field></block></value><value name="C"><block type="math_number" id="0fy-Y$.4f`lA}-Wp?2]c"><field name="NUM">600</field></block></value><next><block type="writetolog" id="0/jv:}5N|.x,!jPr$[5r"><value name="writeToLog"><block type="text" id="Ih~B%[:%`E!Xm^Dp9FL8"><field name="TEXT">Lux &lt; fence ==&gt;&gt; Helper off after 600 seconds</field></block></value></block></next></block></statement><value name="IF3"><block type="logic_operation" id="Do^:2Ed8hiXqCAv:oFoF"><field name="OP">AND</field><value name="A"><block type="logic_compare" id="~K{{o.6{1o4nvT.ZwDQH"><field name="OP">EQ</field><value name="A"><block type="switchvariablesGL" id="jH~jCtD-3V,?|zR.Cap9"><field name="Switch">409</field></block></value><value name="B"><block type="logic_states" id="7jf:JZ4UY-@AY-;54r$S"><field name="State">Off</field></block></value></block></value><value name="B"><block type="logic_compare" id="5CTm9NQ#zV*`}O#ND5LX"><field name="OP">LTE</field><value name="A"><block type="utilityvariablesGL" id="+8b,Q]aDgNM$`TM5KwD6"><field name="Utility">410</field></block></value><value name="B"><block type="math_number" id=".U`,APc;3qW1KIO[rt?W"><field name="NUM">110</field></block></value></block></value></block></value><statement name="DO3"><block type="logic_set" id="qoqeyde*bW:8,3oUqtOF"><value name="A"><block type="switchvariablesAF" id="tQ=4]h.2!|(n+Xcu!:s]"><field name="Switch">411</field></block></value><value name="B"><block type="logic_states" id="6j9GHVc$9qNtPcb=ekc."><field name="State">Off</field></block></value><next><block type="writetolog" id="#=;QG.IWKUJ3{{Sc!m(n"><value name="writeToLog"><block type="text" id="v:HOF.a%cD=io]%H5pLx"><field name="TEXT">Helper off ==&gt;&gt; Curtain up</field></block></value></block></next></block></statement></block></xml>
[/code]
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest