29.04.2021, 12:29
I've implemented the above and can report back that it's working!
The IP address in the URL above should be replaced with 'https://owner-api.teslamotors.com'
I'm still having a little trouble capturing the energy_site_id .. how does one traverse the returned table with a numeric (1) table name.
https://owner-api.teslamotors.com/api/1/products returns data in the form
which I'd normally process as follows
however the table name '1' in the above errors when I try to save the script
How do I reference the value with a table name of 1?
Kind Regards
James
The IP address in the URL above should be replaced with 'https://owner-api.teslamotors.com'
I'm still having a little trouble capturing the energy_site_id .. how does one traverse the returned table with a numeric (1) table name.
https://owner-api.teslamotors.com/api/1/products returns data in the form
Code:
* table:
[response]
* table:
[1]
* table:
[site_name]
* string: Home Energy Gateway
[energy_site_id]
* string: xxxxxxx
[id]
* string: xxxx-xxx-xxxx-xxxx
which I'd normally process as follows
Code:
mydata = json.pdecode(table.concat(resp))
assetSiteD = mydata.response.1.energy_site_id
however the table name '1' in the above errors when I try to save the script
Code:
Lua syntax error at line 200: malformed number near '.1.energy_site_id'
How do I reference the value with a table name of 1?
Kind Regards
James