Skip to content

Commit 827c120

Browse files
committed
add mqtt-parameter endpoint
fixes #13
1 parent 2d24b64 commit 827c120

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ the endpoint expects the following as a json payload on the message
8585
{"cmdCode": "WN511_SET_PERMANENT_WATTS_PACK","params": {"permanentWatts": 20}}
8686
```
8787

88+
### query MQTT configuration parameter
89+
90+
This will query the HTTP-API for the needed configuration to use the offical MQTT-API.
91+
92+
Example:
93+
```
94+
{"certificateAccount":"open-...","certificatePassword":"...","url":"mqtt-e.ecoflow.com","port":"8883","protocol":"mqtts"}
95+
```
96+
8897
## Getting Access Key and Secret Key
8998

9099
The Credentials can be requested on the offical Ecoflow IoT Website: [Ecoflow OpenIoT](https://developer-eu.ecoflow.com).

ecoflow-api-node.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
{ value: "queryQuotaAll", label: "query all data of a device" },
2323
{ value: "queryQuotaSelective", label: "query specific datapoints" },
2424
{ value: "setQuota", label: "set a specific value" },
25+
{ value: "queryMqttCert", label: "get MQTT connection parameter" },
2526
{ value: "msg", label: "use the msg.function field" }
2627
]
2728
}
@@ -31,7 +32,7 @@
3132
// polling or callback
3233
let updateFunction = function() {
3334
let fn = $("#node-input-function").val();
34-
if (fn == "deviceList") {
35+
if (fn == "deviceList" || fn == 'queryMqttCert') {
3536
$("#serialnumber").hide();
3637
} else {
3738
$("#serialnumber").show();
@@ -98,6 +99,7 @@ <h3>Inputs</h3>
9899
<li>deviceList</li>
99100
<li>queryQuotaSelective</li>
100101
<li>setQuota</li>
102+
<li>queryMqttCert</li>
101103
</ul>
102104
</dd>
103105
</dl>

ecoflow-api-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ module.exports = function(RED) {
4444
[data,error] = await server.setQuotaSelective(serialNumber,quotaTypes);
4545
}
4646
break;
47+
case 'queryMqttCert':
48+
[data,error] = await server.queryMqttCert();
49+
break;
4750
}
4851

4952
if (data) {

ecoflow-api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module.exports = function(RED) {
6666
})
6767
.catch(function(error) {
6868
node.error(error);
69+
console.log(error);
6970
return [undefined,error];
7071
});
7172
}
@@ -82,6 +83,9 @@ module.exports = function(RED) {
8283
node.setQuotaSelective = function(sn, values) {
8384
return EcoflowRequest("/iot-open/sign/device/quota", {}, 'PUT', {sn: sn, ...values });
8485
}
86+
node.queryMqttCert = function(sn) {
87+
return EcoflowRequest("/iot-open/sign/certification", {});
88+
}
8589
}
8690

8791
RED.nodes.registerType("ecoflow-api-server", RemoteServerNode, {

0 commit comments

Comments
 (0)