I’m trying to fetch my P1 energy data from a Domoticz installation using a script.
// Create the request
const res = await fetch( 'http://192.168.1.81:8080/json.htm?type=command¶m=getdevices&idx=29');
if (!res.ok) {
throw new Error(res.statusText);
}
// Get the body JSON
const body = await res.json();
When I try to run this, Domoticz seems to deny the request because of authorization issues:
———————————————————
❌ Script Error
⚠️ Error: Unauthorized
at fetch-domoticz-p1.js.js:4:9
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async HomeyScriptApp.runScript (/app.js:364:22)
at async Object.runScript (/api.js:30:22)
Reading up in the Domoticz documentation, it says I should encode username & password in the “Authorization” HTTP request header. Encoding username/password is no problem, but how do I get these in the request from Homey?
In the end, I want to connect this data to the data from my solar panels to create something like this (screenshot from domoticz, don’t need the graphs but do need the data):
That is actually not a bad solution. Bit of a security breach, but not too bad since my domoticz server should not be available to the outside world anyway. Thx!
That is exactly what I use it for though in my case it goes back to 2020. It runs on a RPi3 that doubles as a music server. Unfortunately, Domoticz refuses to fetch information from my PV installation, which was a breeze in Homey. Therefore, the combination of the two.
Anyway, Domoticz has been next to dead for years now. Not much development is going on anymore, things are dormant. As long as i works, it works.