Page 1 of 1
Negative temp value in Blockly
Posted: Tuesday 27 September 2022 16:39
by Treve
The thermostat of the freezer is defective, I thought to solve this temporarily with a simple blockly. It seems that no negative values are possible.
Can someone clarify and possibly offer me a solution.

- Blockly negative temp.jpg (20.03 KiB) Viewed 1967 times
Re: Negative temp value in Blockly
Posted: Tuesday 27 September 2022 16:43
by willemd
Switch to DzVents, it is so much more powerful, although a small learning curve .....
Re: Negative temp value in Blockly
Posted: Wednesday 28 September 2022 11:31
by Treve
Since I need a working script in the short term and have no time to learn myself into DZVentz.
I found a script from the late 'Waaren',
return {
on = { timer = { 'every minute' } },
execute = function(domoticz)
local Sensor = domoticz.devices('Omnik temperature')
if Sensor.temperature >= 25 then
domoticz.devices('Omnik Ventilator').switchOn()
end
end
}
and adapted it without any knowledge.
return {
on = { timer = { 'every minute' } },
execute = function(domoticz)
local Sensor = domoticz.devices('Vriezer')
if Sensor.temperature <= -16 then
domoticz.devices('Switch 7 Vriezer').switchOn()
elseif Sensor.temperature >= -18 then
domoticz.devices('Switch 7 Vriezer').switchOff()
end
end
}
Can this script work?
Re: Negative temp value in Blockly
Posted: Wednesday 28 September 2022 12:52
by plugge
You have to change:
if Sensor.temperature <= -16 then
in: if Sensor.temperature >= -16 then
and
elseif Sensor.temperature >= -18 then
in: elseif Sensor.temperature <= -18 then
Remember these are negative values.
If the script iteself works for you? Try it!
Re: Negative temp value in Blockly
Posted: Wednesday 28 September 2022 14:13
by Treve
return {
on = { timer = { 'every minute' } },
execute = function(domoticz)
local Sensor = domoticz.devices('testtemp')
if Sensor.temperature <= 22 then
domoticz.devices('Lidl On/Off plug 4').switchOn()
elseif Sensor.temperature >= 24 then
domoticz.devices('Lidl On/Off plug 4').switchOff()
end
end
}
I created a test environment with positive temperatures, the switch turns On below 22' and Off above 24'.
Conclusion is, the script works.
Now investigate whether it also works with negative (freezing) values, or can anybody tells me if it will?
Re: Negative temp value in Blockly
Posted: Wednesday 28 September 2022 15:13
by Treve
return {
on = { timer = { 'every minute' } },
execute = function(domoticz)
local Sensor = domoticz.devices('Vriezer')
if Sensor.temperature >= -18 then
domoticz.devices('Switch 7 Vriezer').switchOn()
elseif Sensor.temperature <= -19 then
domoticz.devices('Switch 7 Vriezer').switchOff()
end
end
}
This did the trick.
good find for someone who has never dealt with dzvents until this morning.