how to check positive numbers in dzvents-script
Moderator: leecollings
how to check positive numbers in dzvents-script
Domoticz v 3.8153
Raspberrypi v3
Hallo.
in a dzvents-script i want to check a rise in temperature >3:
if (current) >= vochtpercentage or (delta_5 >= 3) then... ". In this case a rise as well as a drop of temperature with 3 will trigger the THEN
a "+"-sign is not accepted. the same for ():
if (current) >= vochtpercentage or (delta_5 >= +3) then..
if (current) >= vochtpercentage or (delta_5 >= (+3)) then..
I cannot find the right answer.
Please help
thanks
Paul
Raspberrypi v3
Hallo.
in a dzvents-script i want to check a rise in temperature >3:
if (current) >= vochtpercentage or (delta_5 >= 3) then... ". In this case a rise as well as a drop of temperature with 3 will trigger the THEN
a "+"-sign is not accepted. the same for ():
if (current) >= vochtpercentage or (delta_5 >= +3) then..
if (current) >= vochtpercentage or (delta_5 >= (+3)) then..
I cannot find the right answer.
Please help
thanks
Paul
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: how to check positive numbers in dzvents-script
maybe
math.abs(delta_5) >= 3 ?
so you will trigger a +3 difference as well as a -3 difference
math.abs(delta_5) >= 3 ?
so you will trigger a +3 difference as well as a -3 difference
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: how to check positive numbers in dzvents-script
Hi Paul,
to help a bigger snippit of your code is needed.
As far as I understand from this line and your description, delta_5 is positive integer or float and therefore it cannot be used for this purpose on its own.
to help a bigger snippit of your code is needed.
As far as I understand from this line and your description, delta_5 is positive integer or float and therefore it cannot be used for this purpose on its own.
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
Re: how to check positive numbers in dzvents-script
Emme,
-3 is what i do not want only a positive rise.
Waaren,
I include two parts of the code. The delta_5 is a difference in temperature (degrees) in a 5-minute interval.
Every 5 minutes the current temperature ("current") becomes humidityTmin5 and
the former Tmin5 becomes the Tmin10.
If the rise in temperature in 5 minutes is more then 3degree a fan is activated.
The code sees no difference between +3 and -3, so if the temperature drops more than 3degrees in 5 minutes the fan is also activated. I do
not want that to happen.
hope you can help
regards
Paul
==========
--delta =
delta_10 = (current - humidityTmin10)
if PRINT_MODE == true then
print ('Stijging/daling laatste 10 min: ' ..delta_10) --stijging/daling laatste 10 minuten
end
delta_5 = (humidityTmin5 - humidityTmin10) --stijging/daling laatste 5 min
if PRINT_MODE == true then
print ('Stijging/daling laatste 5 min. ' ..delta_5)
end
===================
-- fan (de)activeren
if (current) >= vochtpercentage or (delta_5 >= 3) then
domoticz.devices(vent_schakelaar).switchOn()
if Off_timer == 2 then
domoticz.notify('ventilator aan (>61%)', ' vochtpercentage en delta_t5 : ' ..current ..delta_5, domoticz.PRIORITY_LOW)
end
===================
-3 is what i do not want only a positive rise.
Waaren,
I include two parts of the code. The delta_5 is a difference in temperature (degrees) in a 5-minute interval.
Every 5 minutes the current temperature ("current") becomes humidityTmin5 and
the former Tmin5 becomes the Tmin10.
If the rise in temperature in 5 minutes is more then 3degree a fan is activated.
The code sees no difference between +3 and -3, so if the temperature drops more than 3degrees in 5 minutes the fan is also activated. I do
not want that to happen.
hope you can help
regards
Paul
==========
--delta =
delta_10 = (current - humidityTmin10)
if PRINT_MODE == true then
print ('Stijging/daling laatste 10 min: ' ..delta_10) --stijging/daling laatste 10 minuten
end
delta_5 = (humidityTmin5 - humidityTmin10) --stijging/daling laatste 5 min
if PRINT_MODE == true then
print ('Stijging/daling laatste 5 min. ' ..delta_5)
end
===================
-- fan (de)activeren
if (current) >= vochtpercentage or (delta_5 >= 3) then
domoticz.devices(vent_schakelaar).switchOn()
if Off_timer == 2 then
domoticz.notify('ventilator aan (>61%)', ' vochtpercentage en delta_t5 : ' ..current ..delta_5, domoticz.PRIORITY_LOW)
end
===================
Re: how to check positive numbers in dzvents-script
mistake:
read temperature = humidity
paul
read temperature = humidity
paul
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: how to check positive numbers in dzvents-script
Hi Paul,
are you sure that the fan is triggered by the (delta_5 >= 3) part of the expression and not by the (current) >= vochtpercentage part ?
I simplified the script that I original copied from https://www.domoticz.com/wiki/Humidity_control because this is all I need to get my bathroom dry after a shower
are you sure that the fan is triggered by the (delta_5 >= 3) part of the expression and not by the (current) >= vochtpercentage part ?
Code: Select all
print ("1. true expected: " .. tostring ( 4 >= 3) )
print ("2. true expected: " .. tostring ( 3 >= 3) )
print ("3. false expected: " .. tostring ( 2 >= 3) )
print ("4. false expected: " .. tostring ( 0 >= 3) )
print ("5. false expected: " .. tostring ( -1 >= 3) )
print ("6. false expected: " .. tostring ( -3 >= 3) )
print ("7. false expected: " .. tostring ( -4 >= 3) )
print ("8. false expected: " .. tostring ( -4.5 >= 3) )
print ("9. true expected: " .. tostring ( 4.5 >= 3) )
give:
2018-01-10 01:00:47.190 dzVents: 1. true expected: true
2018-01-10 01:00:47.190 dzVents: 2. true expected: true
2018-01-10 01:00:47.190 dzVents: 3. false expected: false
2018-01-10 01:00:47.191 dzVents: 4. false expected: false
2018-01-10 01:00:47.191 dzVents: 5. false expected: false
2018-01-10 01:00:47.192 dzVents: 6. false expected: false
2018-01-10 01:00:47.192 dzVents: 7. false expected: false
2018-01-10 01:00:47.192 dzVents: 8. false expected: false
2018-01-10 01:00:47.192 dzVents: 9. true expected: true
Code: Select all
--[[ ************************************************************************************
*** Filename : /opt/domoticz/scripts/dzVents/scripts/Bathroom humidity.lua
*** Initial Date : 14 january 2017
*** Initial Designer : xxxxxxxx
*** Use of this file : dzVents script (LUA) to check if ventilator needs to start in bathroom
*** Active on system : Domoticz
*****************************************************************************************
*** Modification History List
*** -------------------------
*** modified by : xxxxxxxxxx date: 14/09/2017
*** modified : Modified for dzvents 2.2 syntax, +debug +location
***
*** modified by : xxxxxxxxxx date: 5/11/2017
*** modified : Introduced repeatAfterSec to avoid missed signals to 4.33 Mhz switch
***
************************************************************************************** ]]--
return {
active = true,
on = {
timer = { 'every minute' }
},
data = {
HumidityBefore = { initial = 65 }
},
execute = function(domoticz)
local debug = false
function debug_print(MyLine)
if debug then print(MyLine) end
end
local Humidity = domoticz.devices("Badkamer (Zwave)").humidity
local Vent = domoticz.devices('Centrale afzuiging')
if ( Humidity == 0 or Humidity == nil) then
print("dzVents: Bathroom Humidity: current is 0 or nil. Skipping this reading")
else
if ( Humidity ~= domoticz.data.HumidityBefore ) then
debug_print ("dzVents: Bathroom Humidity: " .. tostring(Humidity) .. " domoticz.data.HumidityBefore: " .. tostring(domoticz.data.HumidityBefore ))
local StartNeeded = ( ( Humidity > domoticz.data.HumidityBefore + 3 ) and ( Vent.state == 'Off' ) )
if StartNeeded then
print ("dzVents: Bathroom Humidity: Fan off ==>> Switching fan on for 20 minutes")
Vent.switchOn().repeatAfterSec(10,5) -- Repeat command 5 times (after 10,20,30,40 and 50 seconds)
Vent.switchOff().afterMin(20).repeatAfterSec(10,5)
end
domoticz.data.HumidityBefore = Humidity
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
Re: how to check positive numbers in dzvents-script
I know for sure. I tested it with:
"if (delta_5 >= 3) then
domoticz.devices(vent_schakelaar).switchOn()" and the fan switched on.
I will go into your script, but i still need an answer how to exclude a drop in humidity
regards
Paul
"if (delta_5 >= 3) then
domoticz.devices(vent_schakelaar).switchOn()" and the fan switched on.
I will go into your script, but i still need an answer how to exclude a drop in humidity
regards
Paul
Re: how to check positive numbers in dzvents-script
I tried your script. Local Humidity en Vent changed.
Fan started....
an error in line 53 (switch-on of the Fan) : 2018-01-10 16:14:00.198 Error: dzVents: Error: ...cz/scripts/dzVents/generated_scripts/VochtVentVtest3.lua:53: attempt to call field 'repeatAfterSec' (a nil value)/
because of that probably the switch-off after 20 minutes did not work either. Suggestions?
I use dzventz 2.2.00 and domoticz 3.8153.
regards
Paul
Fan started....
an error in line 53 (switch-on of the Fan) : 2018-01-10 16:14:00.198 Error: dzVents: Error: ...cz/scripts/dzVents/generated_scripts/VochtVentVtest3.lua:53: attempt to call field 'repeatAfterSec' (a nil value)/
because of that probably the switch-off after 20 minutes did not work either. Suggestions?
I use dzventz 2.2.00 and domoticz 3.8153.
regards
Paul
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: how to check positive numbers in dzvents-script
@Paul,
I am really puzzled by this. Could you please insert the function
somewhere in the beginning of your code and call it with ValueAndTypeCheck(delta_5) just before your existing code "if (delta_5 >= 3) then" ?
I am really puzzled by this. Could you please insert the function
Code: Select all
function ValueAndTypeCheck(Var2Check)
print("---------------")
print("Var2Check value: " .. tostring(Var2Check) )
Var2Check_Type = type(Var2Check)
print("Var2Check type: " .. Var2Check_Type )
if Var2Check_Type ~= "string" then
print (tostring(Var2Check) .. " >= 3 is " .. tostring((Var2Check >= 3)))
if Var2Check > 0 then
print ("Var2Check is positive")
elseif Var2Check < 0 then
print ("Var2Check is negative")
else
print ("Var2Check is zero")
end
else
print("no further checks possible on Var2Check")
end
print("---------------")
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
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: how to check positive numbers in dzvents-script
@Paul,
my fault: repeatAfterSec is only available starting dzVents version 2.3
you must remove the .repeatAfterSec(10,5) part for dzVents version 2.2
my fault: repeatAfterSec is only available starting dzVents version 2.3
you must remove the .repeatAfterSec(10,5) part for dzVents version 2.2
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
Re: how to check positive numbers in dzvents-script
How can i download v 2.3 in domoticz?
Re: how to check positive numbers in dzvents-script
Waaren,
I inserted your code in to the top of the script and
just before "if (delta_5) >3 then..." I inserted "ValueAndTypeCheck(delta_5)".
a part of the log-file (drop 2 degrees) :
2018-01-10 22:39:00.285 dzVents: T-5: Digoo_ch1: 82
2018-01-10 22:39:00.285 dzVents: T-10: Digoo_ch1: 84
2018-01-10 22:39:00.286 dzVents: Stijging/daling laatste 10 min: -4
2018-01-10 22:39:00.286 dzVents: Stijging/daling laatste 5 min. -2
2018-01-10 22:39:00.286 dzVents: ---------------
2018-01-10 22:39:00.286 dzVents: Var2Check value: -2
2018-01-10 22:39:00.286 dzVents: Var2Check type: number
2018-01-10 22:39:00.286 dzVents: -2 >= 3 is false
2018-01-10 22:39:00.286 dzVents: Var2Check is negative
2018-01-10 22:39:00.287 dzVents: ---------------
and
(rise 7 degrees)
2018-01-10 22:53:00.222 dzVents: T-5: Digoo_ch1: 84
2018-01-10 22:53:00.222 dzVents: T-10: Digoo_ch1: 77
2018-01-10 22:53:00.223 dzVents: Stijging/daling laatste 10 min: 7
2018-01-10 22:53:00.223 dzVents: Stijging/daling laatste 5 min. 7
2018-01-10 22:53:00.223 dzVents: ---------------
2018-01-10 22:53:00.223 dzVents: Var2Check value: 7
2018-01-10 22:53:00.223 dzVents: Var2Check type: number
2018-01-10 22:53:00.223 dzVents: 7 >= 3 is true
2018-01-10 22:53:00.224 dzVents: Var2Check is positive
2018-01-10 22:53:00.224 dzVents: ---------------
I inserted your code in to the top of the script and
just before "if (delta_5) >3 then..." I inserted "ValueAndTypeCheck(delta_5)".
a part of the log-file (drop 2 degrees) :
2018-01-10 22:39:00.285 dzVents: T-5: Digoo_ch1: 82
2018-01-10 22:39:00.285 dzVents: T-10: Digoo_ch1: 84
2018-01-10 22:39:00.286 dzVents: Stijging/daling laatste 10 min: -4
2018-01-10 22:39:00.286 dzVents: Stijging/daling laatste 5 min. -2
2018-01-10 22:39:00.286 dzVents: ---------------
2018-01-10 22:39:00.286 dzVents: Var2Check value: -2
2018-01-10 22:39:00.286 dzVents: Var2Check type: number
2018-01-10 22:39:00.286 dzVents: -2 >= 3 is false
2018-01-10 22:39:00.286 dzVents: Var2Check is negative
2018-01-10 22:39:00.287 dzVents: ---------------
and
(rise 7 degrees)
2018-01-10 22:53:00.222 dzVents: T-5: Digoo_ch1: 84
2018-01-10 22:53:00.222 dzVents: T-10: Digoo_ch1: 77
2018-01-10 22:53:00.223 dzVents: Stijging/daling laatste 10 min: 7
2018-01-10 22:53:00.223 dzVents: Stijging/daling laatste 5 min. 7
2018-01-10 22:53:00.223 dzVents: ---------------
2018-01-10 22:53:00.223 dzVents: Var2Check value: 7
2018-01-10 22:53:00.223 dzVents: Var2Check type: number
2018-01-10 22:53:00.223 dzVents: 7 >= 3 is true
2018-01-10 22:53:00.224 dzVents: Var2Check is positive
2018-01-10 22:53:00.224 dzVents: ---------------
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: how to check positive numbers in dzvents-script
@Paul,
dzVents 2.3 is part of Domoticz Beta. I don't think you can install it separately on top of domoticz 3.8153
I am running out of ideas why your code reacts unexpected to a negative value. I sent you a PM on how to progress this
dzVents 2.3 is part of Domoticz Beta. I don't think you can install it separately on top of domoticz 3.8153
I am running out of ideas why your code reacts unexpected to a negative value. I sent you a PM on how to progress this
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
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: how to check positive numbers in dzvents-script
Indeed, don't move dzVents runtime files around installs as it is tightly coupled to the Domoticz code. Therefore 2.3.0 can only be used with the current beta and not with stable.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Who is online
Users browsing this forum: No registered users and 1 guest