11.06.2023, 19:02
Hi
New to all this and trying to convert a 0-100% value that i recive from VAV modules in building and converting these to litres/second. I know that 0% is the same as 20 litres/s and 100% equals 140 litres/second in this case. I tried to get som help from chatGPT and from this forum and others but there is somthing thats not working.
I got the following from the error log.
New to all this and trying to convert a 0-100% value that i recive from VAV modules in building and converting these to litres/second. I know that 0% is the same as 20 litres/s and 100% equals 140 litres/second in this case. I tried to get som help from chatGPT and from this forum and others but there is somthing thats not working.
I got the following from the error log.
Quote:User script 13: attempt to perform arithmetic on local 'percentage' (a boolean value) stack traceback:
User script 13: in function 'convertFlowRate'
Code:
-- KNX group addresses
local PERCENTAGE_GROUP = "0/3/67"
local LITERS_PER_SECOND_GROUP = "0/3/68"
-- Flow rate conversion function
function convertFlowRate(percentage)
local minPercentage = 0
local maxPercentage = 100
local minLitersPerSecond = 20
local maxLitersPerSecond = 140
-- Calculate the percentage within the range 0-1
local normalizedPercentage = (percentage - minPercentage) / (maxPercentage - minPercentage)
-- Calculate the flow rate within the range minLitersPerSecond-maxLitersPerSecond
local flowRate = minLitersPerSecond + normalizedPercentage * (maxLitersPerSecond - minLitersPerSecond)
return flowRate
end
-- Read the percentage from group 0/3/67
local percentage = grp.read(PERCENTAGE_GROUP)
-- Convert the percentage to liters per second
local litersPerSecond = convertFlowRate(percentage)
-- Write the liters per second to group 0/3/68
grp.write(LITERS_PER_SECOND_GROUP, litersPerSecond)