Page 2 of 2

Re: Lua 3D array

Posted: Thursday 22 March 2018 22:36
by JustMitchie

Code: Select all

Error: EventSystem: in Gas_Update: [string "print('setting Gas')..."]:8: attempt to concatenate field 'gas' (a nil value)
That is with the value 7.418 m3 so, maybe it needs just the 7.418?

Re: Lua 3D array

Posted: Thursday 22 March 2018 22:42
by JustMitchie
forgot the capital letter G. But now the problem is that it writes 7.418 m3 as 0.007 m3
and i doublechecked the data, the data is 7 m3 per day

i got the clever idea to multiply the value by 1000 by doing

Code: Select all

commandArray['UpdateDevice']=otherdevices_idx['Gas']..'|0|'..(jsonData.result[1].CounterToday * 1000)
but offcourse this now throws the error that "attempt to perform arithmetic on field 'CounterToday' (a string value) "so thats not going to happen. I'm asking this because the kwh meter got the same sort of things, so i'll only need to edit the stuff

kind regards!

Code: Select all

   local value = string.sub(jsonData.result[1].CounterToday, 1, 5) * 1000
   commandArray['UpdateDevice']=otherdevices_idx['Gas']..'|0|'..value 
NAILED IT! THANKS <3