This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Processing KNX Addresses
#20
Is this the right way?
Code:
local inputgroup = {}
local groupobjects = {}

function readAndSetTemperature(group, j)
  local base = group .. '/'
  local readAddress = base .. '0/15'
  local setAddress = base .. '4/' .. j

  local temperature = grp.getvalue(readAddress)
  if temperature ~= nil then
    grp.checkwrite(setAddress, temperature)
  end
end

client = require('localbus').new(0.1)

client:sethandler('groupwrite', function(event)
  local addr = event.dst
  local group = inputgroup[addr]

  if group then
    local value = grp.getvalue(addr)
    groupobjects[group][addr] = value

    local controlCheck = group .. '/0/11'
    local controlValue = grp.getvalue(controlCheck)

    local zeroCheck = group .. '/0/13'
    local zeroValue = grp.getvalue(zeroCheck)

    if zeroValue == false or controlValue == true then
      for j = 17, 117, 10 do
        local addr = group .. '/4/' .. j
        grp.checkwrite(addr, 0)
      end
    else
      for j = 17, 117, 10 do
        readAndSetTemperature(group, j)
      end
    end
  end
end)

for i = 0, 60 do
  local group = i
  groupobjects[group] = {}

  for j = 13, 113, 10 do
    local addr = group .. '/4/' .. j
    local value = grp.getvalue(addr)

    if value ~= nil then
      inputgroup[addr] = group
      groupobjects[group][addr] = value
    end
  end
end

while true do
  client:loop(1)
end
Reply


Messages In This Thread
Processing KNX Addresses - by AISystem - 10.05.2023, 07:13
RE: Processing KNX Addresses - by admin - 10.05.2023, 07:30
RE: Processing KNX Addresses - by AISystem - 10.05.2023, 08:24
RE: Processing KNX Addresses - by admin - 10.05.2023, 08:49
RE: Processing KNX Addresses - by AISystem - 10.05.2023, 11:50
RE: Processing KNX Addresses - by admin - 10.05.2023, 11:51
RE: Processing KNX Addresses - by AISystem - 10.05.2023, 12:05
RE: Processing KNX Addresses - by admin - 10.05.2023, 12:33
RE: Processing KNX Addresses - by AISystem - 10.05.2023, 14:21
RE: Processing KNX Addresses - by admin - 11.05.2023, 05:59
RE: Processing KNX Addresses - by AISystem - 11.05.2023, 07:28
RE: Processing KNX Addresses - by admin - 11.05.2023, 12:18
RE: Processing KNX Addresses - by AISystem - 22.05.2023, 11:29
RE: Processing KNX Addresses - by admin - 22.05.2023, 12:01
RE: Processing KNX Addresses - by AISystem - 25.05.2023, 07:14
RE: Processing KNX Addresses - by AISystem - 29.05.2023, 08:55
RE: Processing KNX Addresses - by admin - 29.05.2023, 09:41
RE: Processing KNX Addresses - by AISystem - 29.05.2023, 10:33
RE: Processing KNX Addresses - by admin - 29.05.2023, 10:58
RE: Processing KNX Addresses - by AISystem - 29.05.2023, 11:23
RE: Processing KNX Addresses - by admin - 29.05.2023, 11:48

Forum Jump: