Hi,
I am using a HttpClient to get schedule to know when turn on/off a relay. With the HttpClient, I get a JSON from a webserver. The JSON is simple but can be dynamic data. Actually, I have 2 relays with different start times and days enable.
Easily, I can get the value of the “updated” and “relays” “no” using root[“updated”].asString() or root[“relays”][0][“no”].asString()
What I try, is to loop in all “relays”, know if a relay is enabled for a day (from 1 to 7) and loop in the “time” node to know at what time is starting and for how long. Ex: start @09:03 for 10 minutes.
I read a couple of threads and I was able to start the code but my knowledge need help. Someone can help me or give some in to continue ?
I use “SparkJson.h” lib
Here is the JSON
{
"updated": "2018-05-20 00:08:19",
"relays": [
{
"days": {
"1": "1",
"2": "1",
"3": "1",
"4": "1",
"5": "1",
"6": "1",
"7": "1"
},
"time": {
"06:05": "1",
"00:17": "30",
"09:03": "10"
},
"no": "1"
},
{
"days": {
"1": "0",
"2": "0",
"3": "1",
"4": "0",
"5": "0",
"6": "1",
"7": "0"
},
"time": {
"12:30": "2",
"00:46": "1",
"00:17": "30",
"09:03": "5"
},
"no": "2"
}
]
}