Hi,
So I got the DataScraper script to work, and it is a fantastic tool!
However, it is far more advanced than my current knowledge, and I am stuck. So a little bit of help would be highly appreciated.
What I have done so far is to fetch the current energy prices from an API. The format is JSON, with 24 sections which represents the energy price for every hour of the day. I managed to create a pattern so that GrabData is a list of all the prices for every hour of a day, like this:
[Grab1Data]
0=1.1156
1=1.08999
2=1.06685
3=1.06029
And so on, all the way to 23=.
From this, I create three devices: One that show the day average price, one that shows a calculated day low price point, and one that shows a calculated day high price point, relative to the average. (please se my DataScraper.ini below). The goal is to create events that can turn stuff on and off depening on if the energy price is lower or higher than the average.
I only lack one device: the one that holds the current hour energy price. It obviously have to be updated every hour.
The data is already grabbed, but I have no clue how to extract it. I can't grab the hourly price from the API, just a full day (24 hours with corresponding price points). I have fiddled around with the [hour] replacement value as a pattern to use the API/JSON as a source, but it doesn't seem to work. I guess I have to use a Regex on the grabbed data in the DataScraperData.ini file(?), but I have absolutely no knowledge of Regex. So the learning curve is steep, and I have no clue how to create a regex that extract the price for the current hour. Or could I use a pattern directly on the JSON? Any suggestions?
Thanks!
Jon00DataScraper.ini:
[Settings]
DataLogging=1
ExpressionLogging=1
ErrorLogging=1
IEClearDelay=3
[Grab1]
Path=https://www.hvakosterstrommen.no/api/v1/prices/[year]/[month]-[day]_NO2.json
PostData=
TextFile=1
Encoding=
Username=
Password=
Options=
UserAgent=
Devicemode=4
StripHTML=1
UseIE=0
SSLMode=*3072
GroupDevices=0
Pattern1=JSON> 0.NOK_per_kWh || 1.NOK_per_kWh || 2.NOK_per_kWh ||3.NOK_per_kWh ||4.NOK_per_kWh ||5.NOK_per_kWh || 6.NOK_per_kWh || 7.NOK_per_kWh || 8.NOK_per_kWh ||9.NOK_per_kWh ||10.NOK_per_kWh ||11.NOK_per_kWh ||12.NOK_per_kWh ||13.NOK_per_kWh ||14.NOK_per_kWh ||15.NOK_per_kWh ||16.NOK_per_kWh ||17.NOK_per_kWh ||18.NOK_per_kWh || 19.NOK_per_kWh || 20.NOK_per_kWh ||21.NOK_per_kWh ||22.NOK_per_kWh ||23.NOK_per_kWh
DeviceName1=EnergyPrice - Average
DeviceText1=Average Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24]
DeviceValue1=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24]
DeviceImage1=[100]
Speakbutton1=
TriggerString1=
SearchMode1=1
TriggerEvent1=?
DeviceName2=EnergyPrice - Low
DeviceText2=Low Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*0.85]
DeviceValue2=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*0.85]
DeviceImage2=[200]
Speakbutton2=
TriggerString2=
SearchMode2=1
TriggerEvent2=?
DeviceName3=EnergyPrice - High
DeviceText3=High Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*1.15]
DeviceValue3=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*1.15]
DeviceImage3=[100]
Speakbutton3=
TriggerString3=
SearchMode3=1
TriggerEvent3=?
DeviceName4=CurrentEnergyPrice
DeviceText4=Energy Price for [day]/[month]/[year] @ [hour] is ???????????
DeviceValue4=????????????
DeviceImage4=[100]
Speakbutton4=
TriggerString4=
SearchMode4=1
TriggerEvent4=?
[Info]
Version=1.0.35
So I got the DataScraper script to work, and it is a fantastic tool!
However, it is far more advanced than my current knowledge, and I am stuck. So a little bit of help would be highly appreciated.
What I have done so far is to fetch the current energy prices from an API. The format is JSON, with 24 sections which represents the energy price for every hour of the day. I managed to create a pattern so that GrabData is a list of all the prices for every hour of a day, like this:
[Grab1Data]
0=1.1156
1=1.08999
2=1.06685
3=1.06029
And so on, all the way to 23=.
From this, I create three devices: One that show the day average price, one that shows a calculated day low price point, and one that shows a calculated day high price point, relative to the average. (please se my DataScraper.ini below). The goal is to create events that can turn stuff on and off depening on if the energy price is lower or higher than the average.
I only lack one device: the one that holds the current hour energy price. It obviously have to be updated every hour.
The data is already grabbed, but I have no clue how to extract it. I can't grab the hourly price from the API, just a full day (24 hours with corresponding price points). I have fiddled around with the [hour] replacement value as a pattern to use the API/JSON as a source, but it doesn't seem to work. I guess I have to use a Regex on the grabbed data in the DataScraperData.ini file(?), but I have absolutely no knowledge of Regex. So the learning curve is steep, and I have no clue how to create a regex that extract the price for the current hour. Or could I use a pattern directly on the JSON? Any suggestions?
Thanks!
Jon00DataScraper.ini:
[Settings]
DataLogging=1
ExpressionLogging=1
ErrorLogging=1
IEClearDelay=3
[Grab1]
Path=https://www.hvakosterstrommen.no/api/v1/prices/[year]/[month]-[day]_NO2.json
PostData=
TextFile=1
Encoding=
Username=
Password=
Options=
UserAgent=
Devicemode=4
StripHTML=1
UseIE=0
SSLMode=*3072
GroupDevices=0
Pattern1=JSON> 0.NOK_per_kWh || 1.NOK_per_kWh || 2.NOK_per_kWh ||3.NOK_per_kWh ||4.NOK_per_kWh ||5.NOK_per_kWh || 6.NOK_per_kWh || 7.NOK_per_kWh || 8.NOK_per_kWh ||9.NOK_per_kWh ||10.NOK_per_kWh ||11.NOK_per_kWh ||12.NOK_per_kWh ||13.NOK_per_kWh ||14.NOK_per_kWh ||15.NOK_per_kWh ||16.NOK_per_kWh ||17.NOK_per_kWh ||18.NOK_per_kWh || 19.NOK_per_kWh || 20.NOK_per_kWh ||21.NOK_per_kWh ||22.NOK_per_kWh ||23.NOK_per_kWh
DeviceName1=EnergyPrice - Average
DeviceText1=Average Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24]
DeviceValue1=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24]
DeviceImage1=[100]
Speakbutton1=
TriggerString1=
SearchMode1=1
TriggerEvent1=?
DeviceName2=EnergyPrice - Low
DeviceText2=Low Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*0.85]
DeviceValue2=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*0.85]
DeviceImage2=[200]
Speakbutton2=
TriggerString2=
SearchMode2=1
TriggerEvent2=?
DeviceName3=EnergyPrice - High
DeviceText3=High Energy Price for [day]/[month]/[year] is [0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*1.15]
DeviceValue3=[0+{1},+{2},+{3},+{4},+{5},+{6},+{7},+{8},+{9},+{10},+{11},+{ 12},+{13},+{14},+{15},+{16},+{17},+{18},+{19},+{20},+{21},+{ 22},+{23},/24,*1.15]
DeviceImage3=[100]
Speakbutton3=
TriggerString3=
SearchMode3=1
TriggerEvent3=?
DeviceName4=CurrentEnergyPrice
DeviceText4=Energy Price for [day]/[month]/[year] @ [hour] is ???????????
DeviceValue4=????????????
DeviceImage4=[100]
Speakbutton4=
TriggerString4=
SearchMode4=1
TriggerEvent4=?
[Info]
Version=1.0.35
Comment