From blocky to dzVents  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

From blocky to dzVents

Post by gielie »

Hi all,

i have a blocky running which id like to change to dzvents, im a terrible coder, i tried something but this doesnt work.
Can someone help me out with translating my blocky to dzvents?
fan.png
fan.png (221.74 KiB) Viewed 1548 times
So what i want is my ventilation based on presence and time, when everybody is away/at night fan off, during the day or i 1 person at home, fan on.

thanks a lot
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: From blocky to dzVents

Post by waaren »

gielie wrote: Thursday 21 November 2019 9:45 i have a blocky running which id like to change to dzvents, im a terrible coder, i tried something but this doesnt work.
Can someone help me out with translating my blocky to dzvents?
Please don't post images as a link but attach them as an img file. The link to the image was not visible when your server could not be reached.

Can you test this ?

Code: Select all

local JolandaPresence = 'Life360-Jolanda Presence'  -- Please check the names on missing or extra spaces I might have copied them wrong
local MachielPresence = 'Life360-Machiel Presence'

return 
{
    on = 
    {
        timer = {'at 07:00', 'at 22:30'},
        devices = { JolandaPresence, MachielPresence },
    },
    
    
    execute = function(dz, item)
        local fan = dz.devices('Ventilatie stand 2')
        local bothAway = ( dz.devices(JolandaPresence).state ~= 'On' ) and ( dz.devices(MachielPresence).state ~= 'On' ) 
        
        if dz.time.matchesRule('at 22:30-07:00') or bothAway then 
            fan.switchOff().checkFirst()
        else
            fan.switchOn().checkFirst()
        end    
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MarloCZ
Posts: 11
Joined: Tuesday 26 November 2019 21:53
Target OS: Windows
Domoticz version:
Contact:

Re: From blocky to dzVents

Post by MarloCZ »

Hello
excuse my english, but i need some help converting blockly script to dzVents
This is starting the heating, where I have a timer set directly on the switch "Kotel" and starts when I change the value on "Thermostat", which I have as a set point.
Thanks for the help
Blockly-Termostat.JPG
Blockly-Termostat.JPG (29.25 KiB) Viewed 1509 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: From blocky to dzVents

Post by waaren »

MarloCZ wrote: Tuesday 26 November 2019 22:22 This is starting the heating, where I have a timer set directly on the switch "Kotel" and starts when I change the value on "Thermostat", which I have as a set point.
Not sure I completely understand but can you try this ?

Code: Select all

return 
{
    on =  { timer = { 'every 5 minutes' },
            devices = { 'Termostat', 'Obyvak-u-TV' }},
        
    logging = { level = domoticz.LOG_DEBUG }, -- change to LOG_ERROR if script works as expected
    
    execute = function(dz, item)
        _G.logMarker = _G.moduleLabel
    
        local hysteresis = 0.2
        local boiler = dz.devices('Kotel')
        local temperature = dz.utils.round(dz.devices('Obyvak-u-TV').temperature,1)
        local setpoint = dz.utils.round(dz.devices('Termostat').setPoint,1)
    
        dz.log('Boiler state: ' .. boiler.state,dz.LOG_DEBUG)
        dz.log('Measured temperature: ' .. temperature,dz.LOG_DEBUG)
        dz.log('Setpoint: ' .. setpoint,dz.LOG_DEBUG)
        
        if setpoint < ( temperature - hysteresis ) and boiler.state == 'On' then 
            boiler.switchOff()
            dz.log('Switching boiler off',dz.LOG_DEBUG)
        elseif setpoint > ( temperature + hysteresis ) and boiler.state == 'Off' then 
            boiler.switchOn()
            dz.log('Switching boiler on',dz.LOG_DEBUG)
        else
            dz.log('No action needed',dz.LOG_DEBUG)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MarloCZ
Posts: 11
Joined: Tuesday 26 November 2019 21:53
Target OS: Windows
Domoticz version:
Contact:

Re: From blocky to dzVents

Post by MarloCZ »

Thanks for answering, I did it according to this procedure: https://www.youtube.com/watch?v=Ga8mSQ-XCbc

Picture of my Thermostat timer setting and Log.

I would like the script to run only when the current "Thermostat" value changes
I want to convert it to dzVents because I can't find the boot value in Blockly "device.changed"
Timer-Termostat.JPG
Timer-Termostat.JPG (75.83 KiB) Viewed 1497 times
Log.JPG
Log.JPG (149.51 KiB) Viewed 1497 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: From blocky to dzVents

Post by waaren »

MarloCZ wrote: Wednesday 27 November 2019 6:52 Thanks for answering, I did it according to this procedure: https://www.youtube.com/watch?v=Ga8mSQ-XCbc
Sorry but I don't understand a word from what is said there.
I would like the script to run only when the current "Thermostat" value changes/quote]
I changed the script accordingly.

Code: Select all

return 
{
    on =  { devices = { 'Termostat', 'Obyvak-u-TV' }},
        
    logging = { level = domoticz.LOG_DEBUG }, -- change to LOG_ERROR if script works as expected
    
    execute = function(dz, item)
        _G.logMarker = _G.moduleLabel
    
        local boiler = dz.devices('Kotel')
        local temperature = dz.utils.round(dz.devices('Obyvak-u-TV').temperature,1)
        local setpoint = dz.utils.round(dz.devices('Termostat').setPoint,1)
    
        dz.log('Boiler state: ' .. boiler.state,dz.LOG_DEBUG)
        dz.log('Measured temperature: ' .. temperature,dz.LOG_DEBUG)
        dz.log('Setpoint: ' .. setpoint,dz.LOG_DEBUG)
        
        if setpoint < temperature and boiler.state == 'On' then 
            boiler.switchOff()
            dz.log('Switching boiler off',dz.LOG_DEBUG)
        elseif setpoint > temperature and boiler.state == 'Off' then 
            boiler.switchOn()
            dz.log('Switching boiler on',dz.LOG_DEBUG)
        else
            dz.log('No action needed',dz.LOG_DEBUG)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MarloCZ
Posts: 11
Joined: Tuesday 26 November 2019 21:53
Target OS: Windows
Domoticz version:
Contact:

Re: From blocky to dzVents

Post by MarloCZ »

Thank you very much, the script works. Sending log. ;)
Log-2.JPG
Log-2.JPG (274.05 KiB) Viewed 1482 times
MarloCZ
Posts: 11
Joined: Tuesday 26 November 2019 21:53
Target OS: Windows
Domoticz version:
Contact:

Re: From blocky to dzVents

Post by MarloCZ »

I have one more request.
Is there any way to run the script only when the "Thermostat" value changes?

Something like that ?

return
{
on = { devices.changed = { 'Termostat' }},


Thx.
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: From blocky to dzVents  [Solved]

Post by gielie »

waaren wrote: Thursday 21 November 2019 11:52
gielie wrote: Thursday 21 November 2019 9:45 i have a blocky running which id like to change to dzvents, im a terrible coder, i tried something but this doesnt work.
Can someone help me out with translating my blocky to dzvents?
Please don't post images as a link but attach them as an img file. The link to the image was not visible when your server could not be reached.

Can you test this ?

Code: Select all

local JolandaPresence = 'Life360-Jolanda Presence'  -- Please check the names on missing or extra spaces I might have copied them wrong
local MachielPresence = 'Life360-Machiel Presence'

return 
{
    on = 
    {
        timer = {'at 07:00', 'at 22:30'},
        devices = { JolandaPresence, MachielPresence },
    },
    
    
    execute = function(dz, item)
        local fan = dz.devices('Ventilatie stand 2')
        local bothAway = ( dz.devices(JolandaPresence).state ~= 'On' ) and ( dz.devices(MachielPresence).state ~= 'On' ) 
        
        if dz.time.matchesRule('at 22:30-07:00') or bothAway then 
            fan.switchOff().checkFirst()
        else
            fan.switchOn().checkFirst()
        end    
    end
}
I used your script and it works like a charm, Thanks a lot.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest