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
Max value for SetPoint [Solved]
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Max value for SetPoint
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 65
- Joined: Sunday 11 November 2018 9:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Oslo
- Contact:
Re: Max value for SetPoint
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
-
- Posts: 65
- Joined: Sunday 11 November 2018 9:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Oslo
- Contact:
Re: Max value for SetPoint
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
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
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Max value for SetPoint
It is a stand alone script. You only have to change the name of the setPoint device to the name you use.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 65
- Joined: Sunday 11 November 2018 9:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Oslo
- Contact:
Re: Max value for SetPoint
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.
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.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Max value for SetPoint
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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 65
- Joined: Sunday 11 November 2018 9:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Oslo
- Contact:
Re: Max value for SetPoint [Solved]
Thank you - worked like a dream!!!!
Who is online
Users browsing this forum: No registered users and 1 guest