Page 1 of 1
From blocky to dzVents
Posted: Thursday 21 November 2019 9:45
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 (221.74 KiB) Viewed 1551 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
Re: From blocky to dzVents
Posted: Thursday 21 November 2019 11:52
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
}
Re: From blocky to dzVents
Posted: Tuesday 26 November 2019 22:22
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 (29.25 KiB) Viewed 1512 times
Re: From blocky to dzVents
Posted: Wednesday 27 November 2019 1:49
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
}
Re: From blocky to dzVents
Posted: Wednesday 27 November 2019 6:52
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 (75.83 KiB) Viewed 1500 times

- Log.JPG (149.51 KiB) Viewed 1500 times
Re: From blocky to dzVents
Posted: Wednesday 27 November 2019 8:58
by waaren
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
}
Re: From blocky to dzVents
Posted: Wednesday 27 November 2019 13:03
by MarloCZ
Thank you very much, the script works. Sending log.

- Log-2.JPG (274.05 KiB) Viewed 1485 times
Re: From blocky to dzVents
Posted: Wednesday 27 November 2019 13:48
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.
Re: From blocky to dzVents [Solved]
Posted: Monday 09 December 2019 11:38
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.