Skip to content

Commit

Permalink
remove node-fetch package and use native one
Browse files Browse the repository at this point in the history
  • Loading branch information
b2un0 committed Apr 12, 2024
1 parent 68361fc commit 984c27f
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 177 deletions.
4 changes: 2 additions & 2 deletions examples/shareWireguard.json5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// published this to "MQTT_TOPIC=fritz2mqtt"
// published to "MQTT_TOPIC=fritz2mqtt"
{
"page": "shareWireguard"
}
}
2 changes: 1 addition & 1 deletion examples/shareWireguard_connection_off.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"connection6": "off", // "connection6" is the internal name of the target connection
"active_connection6": 0,
"apply": null // mandatory!
}
}
2 changes: 1 addition & 1 deletion examples/shareWireguard_connection_on.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"connection6": "on", // "connection6" is the internal name of the target connection
"active_connection6": 1,
"apply": null // mandatory!
}
}
2 changes: 1 addition & 1 deletion examples/wireguard_edit_defaultroute_off.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"uid": "connection6", // "connection6" is the internal name of the target connection
"accessdefaultroute": "off",
"apply": null // mandatory!
}
}
2 changes: 1 addition & 1 deletion examples/wireguard_edit_defaultroute_on.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"uid": "connection6", // "connection6" is the internal name of the target connection
"accessdefaultroute": "on",
"apply": null // mandatory!
}
}
4 changes: 2 additions & 2 deletions home_assistant/mqtt_switch_wireguard_connection_on_off.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ mqtt:
"connection6": "on",
"active_connection6": 1,
"apply": null
}
}
payload_off: >-
{
"page": "shareWireguard",
"connection6": "off",
"active_connection6": 0,
"apply": null
}
}
state_topic: "fritz2mqtt/shareWireguard"
state_on: true
state_off: false
Expand Down
3 changes: 1 addition & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {URLSearchParams} = require('node:url');
const fetch = require('node-fetch');
const {XMLParser} = require('fast-xml-parser');
const crypto = require('node:crypto');
const mqtt = require('mqtt');
Expand All @@ -17,7 +16,7 @@ class fritz2mqtt {

mqttClient.on('connect', () => {
mqttClient.subscribe(process.env.MQTT_TOPIC);
console.log('mqtt subscribed: ', process.env.MQTT_TOPIC)
console.log('mqtt subscribed:', process.env.MQTT_TOPIC)
});

mqttClient.on('message', async (topic, message) => {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
},
"dependencies": {
"fast-xml-parser": "^4.3.2",
"mqtt": "^5.2.1",
"node-fetch": "^2.7.0"
"mqtt": "^5.5.2"
},
"devDependencies": {
"nodemon": "^3.0.1"
},
"engines": {
"node": ">= 18"
"node": ">= 20"
},
"bugs": {
"url": "https://github.com/b2un0/fritz2mqtt/issues"
Expand Down
Loading

0 comments on commit 984c27f

Please sign in to comment.