29.11.2022, 12:56
Modify the script that fetches the prices so it saves the list of cheapest hours into storage:
Then create a scheduled script that runs every hour at 0 minutes:
Code:
list = {}
price_hours = {}
for i = 1, 4 do
item = data[ i ]
list[ i ] = string.format('%d = %.2f', item.hour, item.SpotPriceDKK)
price_hours[ i ] = item.hour
end
storage.set('price_hours', price_hours)
hours = table.concat(list, '; ')
grp.checkupdate('13/4/28', hours)
Then create a scheduled script that runs every hour at 0 minutes:
Code:
currhour = os.date('*t').hour
hours = storage.get('price_hours', {})
found = false
for _, hour in ipairs(hours) do
if currhour == hour then
found = true
end
end
grp.checkwrite('1/1/1', found)