Logic Machine Forum
Get data from Trend logs! - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Get data from Trend logs! (/showthread.php?tid=5920)



Get data from Trend logs! - phongvucba - 08.03.2025

Hi everyone, I have a little trouble, hope everyone can help
I want to get the value of Trend logs to put into a specific address. for example 1.1.1 and 1.1.2, how do I do it. Here I want to get the value of 2.03kwh and 1.47kwh into 1.1.1 and 1.1.2
If anyone can help, I would be very grateful! Smile


RE: Get data from Trend logs! - Erwin van der Zwart - 08.03.2025

https://kb.logicmachine.net/libraries/trends/


RE: Get data from Trend logs! - phongvucba - 10.03.2025

Thank so much! Pro, i will try it ! Smile):
I have read the link you sent, I have tried the code like this. But it does not give the desired result, can you help me? I want to get these 2 values 2.03 and 1.47kwh
Thank so much everyone !
------------------------
require('trends')

-- fetch data for the previous day
dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - 1
dates['end'] = os.date('*t')
-----------
dates1 = {}
dates1['start'] = os.date('*t')
dates1['start'].day = dates['start'].day - 2
dates1['end'] = os.date('*t')
-- fetch current value
day = trends.fetchone('Đo điện tầng 3', dates)
day1 = trends.fetchone('Đo điện tầng 3', dates1)
grp.write('1/1/1', day)
grp.write('1/1/2', day1)
------------------------