Hi,
I already have some experience creating scripts with blockly, quite simple. Now I come across a problem that cannot be solved with blockly but what I think I can solve with Lua, unfortunately I have no experience with Lua. someone who can help me?
I want to have the value YES / NO in a string user variable called 'ventilate' based on temperature inside and temperature outside.
IF temp outside 5 degrees higher than temp inside THEN vantilation -> NO
Otherwise ventilation -> YES
Someone who can help me get started?
Measure difference
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Measure difference
Please have a look at this dzVents script (dzVents = 100% Lua)
When not yet familiar with dzVents please start with reading Get started before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
-- temperature Delta
local temperatureInside = 'temperature inside' -- change to the names of your actual temperature sensordevices
local temperatureOutside = 'temperature outside'
return
{
on = { devices = { temperatureInside, temperatureOutside } },
logging = { level = domoticz.LOG_DEBUG,
marker = 'Temperature delta' },
execute = function(dz )
local ventilate = dz.variables('ventilate')
if dz.devices(temperatureOutside).temperature > ( dz.devices(temperatureInside).temperature + 5 ) then
if ventilate.value ~= 'NO' then ventilate.set('NO') end
else
if ventilate.value ~= 'YES' then ventilate.set('YES') end
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
Who is online
Users browsing this forum: No registered users and 1 guest