Page 1 of 1

LUA - lastupdate, getting wrong data[solved]

Posted: Friday 27 May 2016 22:40
by Flopp
MySensors, EthernetGateway, 1.5.1
DZ running on Windows 7 as Service, 3.4967

I have 8 Temp/Hum nodes.
Below is my LUA script, I have very low knowledge of LUA.

My problem is that Node KoketFonster is not getting the lastest lastupdate time, it gets second last. For all other nodes I get correct lastupdate time.
I send data every 30 mins from each node.
I have check if one of the data that is send is old but it is not, all 3 data that I send is on same time. I send Temp, Hum and Volt. Only difference is that KoketFonstret is not the same type of sensor as the rest of my nodes.

If I run

Code: Select all

http://192.168.100.18:8080/json.htm?type=devices&rid=92
is says the latest time, so I dont understand where the second last time is coming from, the time is correct but not the latest.

Anyone that have an idea why I is like this?

Code: Select all

commandArray = {}

local function update(cmd)
vari = "Variable:"  .. cmd
t1 = os.time()

s = otherdevices_lastupdate[cmd]
print(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)

t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (difference > 2400) and (uservariables[cmd] == 0) then
    commandArray['SendEmail']=''..cmd..' mer än 40 min# #[email protected]'
    print ("ingen data på 40 min " .. cmd)
    commandArray[vari] = "1"
elseif (difference < 2400) and (uservariables[cmd] == 1) then
    commandArray[vari] = "0"
end 

end

update ('Ute')
update ('KoketFonster')
update ('Uterummet')
update ('BadrumUppe')
update ('VinglasSkapet')
update ('Sovrum')
update ('TempHumandi')
update ('TempHumtst')
return commandArray

Re: LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 9:48
by jvdz
Are you sure you only have one device called KoketFonster ?

Jos

Re: LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 9:49
by Flopp
One in Temperature and one in Voltage

Re: LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 9:52
by jvdz
LUA can't handle that as it works with the devicesnames, so you require unique devicenames!
Try renaming one of the 2 and adapt your scripts accordingly.

Jos

LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 9:53
by Flopp
Will try.
It works for all my other device which also have exact same names.
Timestamp for Voltage is exact same as Temperature.

Re: LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 10:10
by Flopp
@jvdz Thanks
It helped to rename Voltage device.
There shall be a way to "call" voltage or temperature device. Will find it and write it back here.

LUA - lastupdate, getting wrong data

Posted: Saturday 28 May 2016 10:13
by Flopp
Here it says about different type of data for a device

https://www.domoticz.com/wiki/Events#By ... ion_folder.

Maybe that only work with devicechange command?
I tried to use it with commandArray but it didn't work.