10.03.2025, 02:41
(This post was last modified: 10.03.2025, 09:50 by phongvucba.)
Thank so much! Pro, i will try it !
):
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)
------------------------

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)
------------------------