convert blockly to dzvents  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

convert blockly to dzvents

Post by AllesVanZelf »

Hi all,
I have a Blockly script that I want to convert to a DzVents. It is this one:
Image

I want to try this in DzVents because this blockly script does work for opening the sunscreen and it is closing the suncreen, but closing is going 1% by 1%. So closing from 30%, 31%, 32% etc. till 100% - what is closed. That makes it very slow.
I'm hoping that dzvents will solve this issue.
Anyone who can write this script in dzvents? Please!
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: convert blockly to dzvents

Post by waaren »

AllesVanZelf wrote: Sunday 24 May 2020 20:35 Hi all,
I have a Blockly script that I want to convert to a DzVents.

I want to try this in DzVents because this blockly script does work for opening the sunscreen and it is closing the suncreen, but closing is going 1% by 1%. So closing from 30%, 31%, 32% etc. till 100% - what is closed. That makes it very slow.
Happy to help but I don't understand why the slowness occurs in the Blockly so might well be that the dzVents script does not solve that.

Can you try this one (untested)

Code: Select all

return
{
     on =
     {
        timer = 
        {
            'every 5 minutes',
        },
        devices =
        {
            'BR Mogelijk Regen',
            'BR Regent het?',
            'BR Regen komend uur',
            'BR Zonnekracht',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },
    
    execute = function(dz)
        local shutter = dz.devices('Zonwering Qubino Shutter')
        local possibleRain = dz.devices('BR Mogelijk Regen').state
        local raining = dz.devices('BR Regent het?').state
        local nextHourRain = tonumber(dz.devices('BR Regen komend uur').sValue)
        local sunPower = tonumber(dz.devices('BR Zonnekracht').sValue)

        dz.log(shutter.name .. ',    state: ' .. tostring(shutter.state) , dz.LOG_DEBUG)
        dz.log('BR Mogelijk Regen,   state: ' .. tostring(possibleRain) , dz.LOG_DEBUG)
        dz.log('BR Regent het?,      state: ' .. tostring(raining) , dz.LOG_DEBUG)
        dz.log('BR Regen komend uur, value: ' .. tostring(nextHourRain) , dz.LOG_DEBUG)
        dz.log('BR Zonnekracht,      value: ' .. tostring(sunPower) , dz.LOG_DEBUG)

        if shutter.state == 'Closed'  and dz.time.matchesRule('at 9:30-15:20') and possibleRain == 'Off' and raining == 'Off' and nextHourRain == 0  and sunPower >= 500 then
            shutter.dimTo(45).silent()
        elseif shutter.state ~= 'Closed' and dz.time.matchesRule('at 15:30-23:59') then
            shutter.dimTo(100).silent()
        elseif shutter.state ~= 'Closed' and possibleRain == 'On' then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het regent volgens Buienradar, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)
        elseif shutter.state ~= 'Closed' and nextHourRain > 0  then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het gaat komen uur regenen volgens Buienradar, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)
        end
    end
}


Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: convert blockly to dzvents

Post by AllesVanZelf »

Thank you Waaren!!!
I will try this one out and report you back.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: convert blockly to dzvents

Post by AllesVanZelf »

He Waaren,
Thank you again.
This morning the sunscreen opened around 10. This is good. At that point the sun became strong enough. ;)
And at 15:30 the sunscreen closed in one run till 100% what is closed. This is good too!! Very good.
What is the difference between the blockly and dzvents scripts?? The blockly is almost the same is it not? Strange that the dzvents closes in one run and the blockly in steps of 1% a time.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: convert blockly to dzvents  [Solved]

Post by waaren »

AllesVanZelf wrote: Monday 25 May 2020 16:00 What is the difference between the blockly and dzvents scripts?? The blockly is almost the same is it not? Strange that the dzvents closes in one run and the blockly in steps of 1% a time.
My guess is that the Blockly called itself many times because the sunscreen was one of the devices of which the state needed to be compared. So if the Blockly changes the state of the sunscreen the Blockly triggered again etc....

The dzVents script does not trigger on a changed state of the sunscreen.
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