The problem is that all of your path statements try to access an element in an array. E.g. the [1]
in:
JSONPATH:$.result.watt_hours_day.[1]
But there is no array in your JSON. This is an unfortunate side-effect of how forecast solar formats their return data. Each set of data is not an array of timestamps and values but an object where the timestamps are the keys
. So you would have to use something like:
JSONPATH:$.result.watt_hours_day.2022-11-03
Of course, this is not going to work for a configuration in the JSONPATH because tomorrow the key will be different and you can’t (to my knowledge) put a dynamic value in the JSONPATH transformation.
There are a couple of possible solutions here:
The easiest solution is probably to just keep the entire return JSON in a single string item and then use a rule when that string changes to parse that item according to the current date and populate the other items you want.
You could also use a JS transform instead of a JSONPATH transform and write a JS script that will parse the item item and return the value you want. Of course, if you want more than one value, you’ll need a different JS transform script for each channel.
Instead of doing this yourself you could look at the Solar Forecast PV add-on that handles Forecast Solar as one of its options: