Skip to content

Commit

Permalink
Merge pull request #9 from wywywywy/remove-deprecation
Browse files Browse the repository at this point in the history
chore: remove deprecation & bump version
  • Loading branch information
wywywywy authored Dec 2, 2023
2 parents f38e75e + cfd9123 commit 7ae24cf
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 32 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
FROM node:14-alpine
FROM node:16-alpine

RUN mkdir -p /app
WORKDIR /app

RUN npm i -g npm@6

COPY package*.json /app/
RUN npm ci

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Domoticz exporter for Prometheus.io, written in Node.js 14.
Domoticz exporter for Prometheus.io, written in Node.js.

This exporter provides metrics for the devices defined in Domoticz, rather than for Domoticz itself.

Expand All @@ -16,6 +16,7 @@ This exporter provides metrics for the devices defined in Domoticz, rather than
## Environment Variables

The arguments can also be set as env variables instead. Useful if you're using it in a Docker container.

1. DOMOTICZ_PORT
2. DOMOTICZ_INTERVAL
3. DOMOTICZ_HOSTIP
Expand All @@ -27,7 +28,7 @@ The arguments can also be set as env variables instead. Useful if you're using i

## From Source

Node 14 is required to run it.
Node 16+ is required to run it.

git clone [email protected]:wywywywy/domoticz_exporter.git
cd domoticz_exporter
Expand Down Expand Up @@ -59,9 +60,9 @@ There are 4 types of devices in Domoticz, and they are presented as separate met
3. temp = Get all temperature devices
4. utility = Get all utility devices

Unfortunately there is no standard in Domoticz how "levels" are presented. So for example on some devices battery level 100 means full, and others it will be 255.
Unfortunately there is no standard in Domoticz how "levels" are presented. So for example on some devices battery level 100 means full, and others it will be 255.

The same goes for units - on some it may be Celsius others Fahrenheit, some it may be kWh others Ah, etc. It all depends on the device itself.
The same goes for units - on some it may be Celsius others Fahrenheit, some it may be kWh others Ah, etc. It all depends on the device itself.

# TODO

Expand Down
6 changes: 3 additions & 3 deletions domoticz_exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ setInterval(gatherMetrics, interval * 1000);

// Start Server.
console.log(`INFO: Starting HTTP server...`);
const server = http.createServer((req, res) => {
const server = http.createServer(async (req, res) => {
// Only allowed to poll prometheus metrics.
if (req.method !== 'GET') {
res.writeHead(404, { 'Content-Type': 'text/html' });
return res.end('Support GET only');
}
debug('GET request received');
res.setHeader('Content-Type', register.contentType);
return res.end(register.metrics());
return res.end(await register.metrics());
}).listen(port);
server.setTimeout(30000);
console.log(`INFO: Domoticz exporter listening on port ${port}`);
Expand All @@ -158,7 +158,7 @@ function buildUrl({
port = 443;
protocol = 'https://'
}
return protocol + ip + ':' + port + '/json.htm?type=devices&filter=' + type + '&used=true&order=Name'
return protocol + ip + ':' + port + '/json.htm?type=command&param=getdevices&filter=' + type + '&used=true&order=Name'
}

// Get all devices of a particular device type from Domoticz
Expand Down
175 changes: 158 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domoticz_exporter",
"version": "1.0.1",
"version": "1.0.2",
"description": "Domoticz exporter for Prometheus.io",
"main": "domoticz_exporter.js",
"scripts": {
Expand All @@ -18,9 +18,9 @@
"homepage": "https://github.com/wywywywy/domoticz_exporter#readme",
"dependencies": {
"command-line-args": "^5.2.1",
"dotenv": "^16.0.0",
"moment": "^2.29.1",
"node-fetch": "^2.6.7",
"prom-client": "^12.0.0"
"dotenv": "^16.3.1",
"moment": "^2.29.4",
"node-fetch": "^2.7.0",
"prom-client": "^13.2.0"
}
}

0 comments on commit 7ae24cf

Please sign in to comment.