how can i know the time of the latest data in history?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

how can i know the time of the latest data in history?

Post by papoo »

Hello,
I am trying to force refresh a record in history if it is older than one day.
How to do that simply?
MyVar.getLatest().time return a table, not a time
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: how can i know the time of the latest data in history?

Post by papoo »

i found in doc
rawDate
rawTime
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how can i know the time of the latest data in history?

Post by waaren »

papoo wrote: Tuesday 29 January 2019 22:28 Hello,
I am trying to force refresh a record in history if it is older than one day.
How to do that simply?
MyVar.getLatest().time return a table, not a time
for Lua (and therewith for dzVents) time is a table.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: <2025
Location: Hengelo(Ov)/NL
Contact:

Re: how can i know the time of the latest data in history?

Post by Toulon7559 »

Have been struggling with the same aspect, but not yet found a simple answer.
See viewtopic.php?f=61&t=18582&p=159686&hil ... ty#p143230
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: how can i know the time of the latest data in history?

Post by waaren »

papoo wrote: Tuesday 29 January 2019 22:28 Hello,
I am trying to force refresh a record in history if it is older than one day.
How to do that simply?
MyVar.getLatest().time return a table, not a time
This should do it

Code: Select all

return {
    on      =   {      timer = {" every minute"}},

    data    =   {  testValue = { history = true, maxItems = 1 }},  -- Only one record in history
 
    execute = function(dz)
       -- initialize persistent historical data (only needed once)
        if dz.data.testValue.getLatest() == nil then
            dz.data.testValue.add( "initialized")  
        end
        
        if dz.data.testValue.get(1).time.daysAgo > 0 then
            dz.data.testValue.add("refreshed at " .. dz.time.rawDate .. ", " .. dz.time.rawTime)  
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest