This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script with Dutch power prices
#3
Try this, it will automatically use current date time and will provide prices for the current and the next hour.

Code:
json = require('json') http = require('socket.http') escape = require('socket.url').escape now = os.date('!%Y-%m-%dT%H:00:00+00:00') today = os.date('!%Y-%m-%d') tomorrow = os.date('!%Y-%m-%d', os.time() + 86400) ts = escape(today .. 'T00:00:00+00:00') te = escape(tomorrow .. 'T00:00:00+00:00') url = 'https://mijn.easyenergy.com/nl/api/tariff/getapxtariffs?startTimestamp=' .. ts .. '&endTimestamp=' .. te res, err = http.request({   url = url,   headers = {     ['content-type'] = 'application/json'   } }) if res then   data = json.pdecode(res)   if type(data) == 'table' then     for i, item in ipairs(data) do       if item.Timestamp == now then         tariff_return_now = item.TariffReturn         if data[ i + 1 ] then           tariff_return_next = data[ i + 1 ].TariffReturn         end         break       end     end     log(tariff_return_now, tariff_return_next)   else     log('invalid data', res)   end else   log('request failed', err) end
Reply


Messages In This Thread
RE: Script with Dutch power prices - by admin - 30.05.2022, 10:34
RE: Script with Dutch power prices - by admin - 31.05.2022, 08:52
RE: Script with Dutch power prices - by JASK - 15.03.2023, 21:20
RE: Script with Dutch power prices - by admin - 16.03.2023, 06:25

Forum Jump: