Logic Machine Forum
Create Groupadress on runtime - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Create Groupadress on runtime (/showthread.php?tid=3325)



Create Groupadress on runtime - bednarekluc - 28.04.2021

I have a problem with the following script.
It works fine, up until the point where it should write data to the KNX bus.
But it doesn't do that, but it doesn't give an error either.
Has anybody a clue what I'm doing wrong here?


for i = 1, 8, 1 do
  log (data.daily[i])
 
  dailyResult = {}    -- new array

  dailyResult[0] = data.daily[i].humidity
  dailyResult[1] = data.daily[i].uvi
  dailyResult[2] = data.daily[i].wind_gust
  dailyResult[3] = data.daily[i].pressure
  dailyResult[4] = data.daily[i].moonrise
  dailyResult[5] = data.daily[i].dt
  dailyResult[6] = data.daily[i].feels_like.day
  dailyResult[7] = data.daily[i].feels_like.night
  dailyResult[8] = data.daily[i].feels_like.eve
  dailyResult[9] = data.daily[i].feels_like.morn
  dailyResult[10] = data.daily[i].dew_point
  dailyResult[11] = data.daily[i].rain
  dailyResult[12] = data.daily[i].sunrise
  dailyResult[13] = data.daily[i].wind_speed
  dailyResult[14] = data.daily[i].pop
  dailyResult[15] = data.daily[i].moon_phase
  dailyResult[16] = data.daily[i].temp.day
  dailyResult[17] = data.daily[i].temp.night
  dailyResult[18] = data.daily[i].temp.morn
  dailyResult[19] = data.daily[i].temp.max
  dailyResult[20] = data.daily[i].temp.eve
  dailyResult[21] = data.daily[i].temp.min
  dailyResult[22] = data.daily[i].sunset
  dailyResult[23] = data.daily[i].wind_deg
  dailyResult[24] = data.daily[i].weather[1].main
  dailyResult[25] = data.daily[i].weather[1].id
  dailyResult[26] = data.daily[i].weather[1].icon
  dailyResult[27] = data.daily[i].weather[1].description
  dailyResult[28] = data.daily[i].clouds
  dailyResult[29] = data.daily[i].moonset

  for k = 0, 29, 1 do
    grpAdress = '31/' .. tostring(i) .. '/' .. tostring(k)
    log(grpAdress)
    grp.checkwrite(grpAdress,dailyResult[k])
  end
end


RE: Create Groupadress on runtime - admin - 28.04.2021

Have you created the required objects beforehand?


RE: Create Groupadress on runtime - bednarekluc - 28.04.2021

(28.04.2021, 09:54)admin Wrote: Have you created the required objects beforehand?

Yes they are created.


RE: Create Groupadress on runtime - admin - 28.04.2021

Log what checkwrite returns:
Code:
res, err = grp.checkwrite(grpAdress,dailyResult[k])
log(grpAdress, res, err)

Your first loop goes up to 8, while the middle group address part cannot be larger than 7. So 31/8/X becomes 31/0/X.