Page 1 of 1
Max value for SetPoint
Posted: Friday 20 March 2020 14:16
by ulfh2018
I am using dzVents to regulate temperature in a room. The system is built up using RFXcom and sensors, which are controlled via SetPoint and switches connected via GPIO to a RPi.
I am building the system for my twin brother, who is NOT very fond of IT, so it must be as fool proof as possible. One of the issues is to failsafe the setting of temperature in SetPoint, so I would like to have a max value that cannot he cannot override. I can, of course, do this via an if test in the script I am running every minute or so, but I would like to have some kind of real-time event, but I don't know how to do it.
Best regards
Ulf Holt
Re: Max value for SetPoint
Posted: Friday 20 March 2020 14:54
by waaren
ulfh2018 wrote: ↑Friday 20 March 2020 14:16
One of the issues is to failsafe the setting of temperature in SetPoint, so I would like to have a max value that cannot he cannot override.
this should do just that.
Code: Select all
local maxSetpoint = 25
return
{
on =
{
devices =
{
'Setpoint',
},
},
execute = function(dz, item)
if item.setPoint > maxSetpoint then
dz.log('setpoint device ' .. item.name .. ' was set to ' .. item.setPoint .. ' degrees ==>> lowered to ' .. maxSetpoint .. ' degrees.' ,dz.LOG_FORCE)
item.updateSetPoint(maxSetpoint).silent()
end
end
}
Re: Max value for SetPoint
Posted: Friday 20 March 2020 15:09
by ulfh2018
Thanks a lot, Waaren, I see the logic. Should I run the script using a timer like on = { timer = { 'every minute' } } or just put it inside the scripts I have (one for each room)? I'm sorry if this is very basic
Re: Max value for SetPoint
Posted: Friday 20 March 2020 15:23
by ulfh2018
Not as easy as I thought (it never is).
Here is the script I use to control the switch:
return {
on = { timer = { 'every minute' } },
execute = function(domoticz)
local Sensor = domoticz.devices(1) -- Temperature
local SETPOINT = domoticz.devices(13) -- SetPoint
SETPOINT.updateSetPoint(SETPOINT.setPoint) -- This will refresh the setPoint with current valu
if (Sensor.temperature <= (SETPOINT.setPoint - 0.2)) then -- turn on heat
domoticz.devices(19).switchOn().checkFirst() -- Turn on heater
elseif (Sensor.temperature >= (SETPOINT.setPoint + 0.2)) then -- turn off hea
domoticz.devices(19).switchOff().checkFirst()
else
-- within hysteresis range
end
end
}
Though I think I understod the logic, the syntaxes in the script you sent me scares me off
Re: Max value for SetPoint
Posted: Friday 20 March 2020 16:36
by waaren
ulfh2018 wrote: ↑Friday 20 March 2020 15:09
Thanks a lot, Waaren, I see the logic. Should I run the script using a timer like on = { timer = { 'every minute' } } or just put it inside the scripts I have (one for each room)? I'm sorry if this is very basic
It is a stand alone script. You only have to change the name of the setPoint device to the name you use.
Re: Max value for SetPoint
Posted: Friday 20 March 2020 16:51
by ulfh2018
Hm. Get an error /domoticz/scripts/dzVents/generated_scripts/SetPoint.lua:16: attempt to compare number with nil
at the line:
if item.setPoint > maxSetpoint then
Looks like item.SetPoint returns nil. I use the device name I read in the device list, so the name is correct.
Have only changed the device name and added timer to run the script every minute.
Re: Max value for SetPoint
Posted: Friday 20 March 2020 17:38
by waaren
ulfh2018 wrote: ↑Friday 20 March 2020 16:51
Have only changed the device name and added timer to run the script every minute.
You don't need a timer. The script executes every time the setpoint changes. As I posted before the only thing that needs to be changed is the name of the setpoint device.
Re: Max value for SetPoint [Solved]
Posted: Friday 20 March 2020 17:42
by ulfh2018
Thank you - worked like a dream!!!!