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.

Power price API -> grp. adresses on Wiser
#1
Hello people! Big Grin
Im all new to all this scripting thing with my Wiser.
I have been looking at the forum, and found an other script that more or less say it does what I want.
Then i've changed some of the parameters and the API.

When I run the script i just get this awnswer in the alert log:

Resident script:12: attempt to index a nil value
stack traceback:

Can anyone help? Tongue 
Code:
require('json')
https = require 'ssl.https'
date = os.date('%Y-%m-%d')



url = 'https://api.energidataservice.dk/dataset/Elspotprices?offset=0&filter=%7B%22PriceArea%22:%22dk1%22%7D&sort=HourDK%20DESC&timezone=dk&limit=24'
status = ssl.https.request(url)

data = json.decode(status)

price1 = data[1].SpotPriceDKK
grp.checkupdate('5/5/1', price1)

price2 = data[2].SpotPriceDKK
grp.checkupdate('5/5/2', price2)

price3 = data[3].SpotPriceDKK
grp.checkupdate('5/5/3', price3)

price4 = data[4].SpotPriceDKK
grp.checkupdate('5/5/4', price4)

price5 = data[5].SpotPriceDKK
grp.checkupdate('5/5/5', price5)

price6 = data[6].SpotPriceDKK
grp.checkupdate('5/5/6', price6)

price7 = data[7].SpotPriceDKK
grp.checkupdate('5/5/7', price7)

price8 = data[8].SpotPriceDKK
grp.checkupdate('5/5/8', price8)

price9 = data[9].SpotPriceDKK
grp.checkupdate('5/5/9', price9)

price10 = data[10].SpotPriceDKK
grp.checkupdate('5/5/10', price10)

price11 = data[11].SpotPriceDKK
grp.checkupdate('5/5/11', price11)

price12 = data[12].SpotPriceDKK
grp.checkupdate('5/5/12', price12)

price13 = data[13].SpotPriceDKK
grp.checkupdate('5/5/13', price13)

price14 = data[14].SpotPriceDKK
grp.checkupdate('5/5/14', price14)

price15 = data[15].SpotPriceDKK
grp.checkupdate('5/5/15', price15)

price16 = data[16].SpotPriceDKK
grp.checkupdate('5/5/16', price16)

price17 = data[17].SpotPriceDKK
grp.checkupdate('5/5/17', price17)

price18 = data[18].SpotPriceDKK
grp.checkupdate('5/5/18', price18)

price19 = data[19].SpotPriceDKK
grp.checkupdate('5/5/19', price19)

price20 = data[20].SpotPriceDKK
grp.checkupdate('5/5/20', price20)

price21 = data[21].SpotPriceDKK
grp.checkupdate('5/5/21', price21)

price22 = data[22].SpotPriceDKK
grp.checkupdate('5/5/22', price22)

price23 = data[23].SpotPriceDKK
grp.checkupdate('5/5/23', price23)

price24 = data[24].SpotPriceDKK
grp.checkupdate('5/5/24', price24)





medelpris = price1+price2+price3+price4+price5+price6+price7+price8+price9+price10+price11+price12+price13+price14+price15+price16+price17+price18+price19+price20+price21+price22+price23+price24
gennemsnit = medelpris / 24
grp.checkupdate('5/5/25', gennemsnit)

maxpris = math.max(price1, price2, price3, price4, price5, price6, price7, price8, price9, price10, price11, price12, price13, price14, price15, price16, price17, price18, price19, price20, price21, price22, price23, price24)
grp.checkupdate('5/5/26', maxpris)

minpris = math.min(price1, price2, price3, price4, price5, price6, price7, price8, price9, price10, price11, price12, price13, price14, price15, price16, price17, price18, price19, price20, price21, price22, price23, price24)
grp.checkupdate('5/5/27', minpris)


log(price1, price2)
Reply


Messages In This Thread
Power price API -> grp. adresses on Wiser - by ClausP - 10.11.2022, 08:01

Forum Jump: