LUA - lastupdate, getting wrong data[solved]

Moderator: leecollings

Post Reply
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

LUA - lastupdate, getting wrong data[solved]

Post 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
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: LUA - lastupdate, getting wrong data

Post by jvdz »

Are you sure you only have one device called KoketFonster ?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: LUA - lastupdate, getting wrong data

Post by Flopp »

One in Temperature and one in Voltage
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: LUA - lastupdate, getting wrong data

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

LUA - lastupdate, getting wrong data

Post 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.
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: LUA - lastupdate, getting wrong data

Post 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.
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

LUA - lastupdate, getting wrong data

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest