hoping someone a bit more knowledgeable might be able to offer some suggestions on what I might be doing wrong in the Homey app I’m writing. Basically I’m trying to get some json data from a Solar Battery inverter via its API, however I instead seem to be receiving some html data instead. My code is as follows (except with and having the correct values):
I suspect maybe it is something to do with the header data, but that looks correct to me. Does anyone have any suggestions? I’m fairly new to Javascript.
Thanks, you were right, the issue was the use of http rather than https. So it was returning a status code of 301 indicating a redirect to the https version and the data returned was html redirection code.
Yes, as mentioned it was simply because I was including http rather than https, as far as I remember. Once that was fixed I was able to connect to the API as expected.
Yes, I’ve got insights working and control of the battery via flows, so I have a flow set up that checks the battery level in the evening and discharges excess to the grid before my cheap rate begins. I’m planning on tidying it up a bit and improving it (currently it doesn’t create proper devices just runs as an app) then might consider releasing it as a community project. It’s far from perfect, i.e. it works via the web portal rather than using the local network but after a bit of tweaking it seems to work reasonably reliably.