A function like this would be great to have in dzVents:
The transcript below is of a chatGPT conversation, that shows it's bad knowledge about dzVents, because getHistory() is a made up function.
"To retrieve data from a sensor in the past using dzVents, you can use the getHistory() method. You can define the start and end times for the desired period using os.time(), then use the getHistory() method to retrieve the history data for the device for that period. The method returns a table of DeviceHistoryItem objects, each with a time and value property. You can then loop through the history data and print out the time and value of each item using os.date() to format the time in a readable format.
here is an example of how to use the getHistory() method to retrieve data from a sensor in the past:
Code: Select all
local myDevice = 'myDeviceName'
local startTime = os.time{year=2023, month=3, day=1, hour=0, min=0, sec=0}
local endTime = os.time{year=2023, month=3, day=31, hour=23, min=59, sec=59}
local history = dz.devices(myDevice):getHistory(startTime, endTime)
for _, item in ipairs(history) do
print(os.date('%c', item.time) .. ': ' .. item.value)
end
There you have it. Would be nice to read database history values directly within dzvents.the current Historical variables API, as described' on the wiki page is more complex, because you are building a copy / shadow variable.