-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathecoflow-api-node.html
More file actions
executable file
·121 lines (115 loc) · 4.94 KB
/
ecoflow-api-node.html
File metadata and controls
executable file
·121 lines (115 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<script type="text/javascript">
RED.nodes.registerType('ecoflow-api',{
category: 'Ecoflow',
paletteLabel: 'Generic API',
color: '#a6bbcf',
defaults: {
name: { value: "", required: false },
remote: { value:"", type:"ecoflow-api-server", required: true },
serial_number: { required: false },
function: { value: "queryQuotaAll", required: false }
},
inputs: 1,
outputs: 1,
icon: "ecoflow-logo.svg",
label: function() { return this.name || 'Ecoflow API' },
oneditprepare: function() {
$("#node-input-function").typedInput({
types: [
{
value: "function",
options: [
{ value: "deviceList", label: "query the device list" },
{ value: "queryQuotaAll", label: "query all data of a device" },
{ value: "setQuota", label: "set a specific value" },
{ value: "queryMqttCert", label: "get MQTT connection parameter" },
{ value: "msg", label: "use the msg.function field" }
]
}
]
})
// polling or callback
let updateFunction = function() {
let fn = $("#node-input-function").val();
if (fn == "deviceList" || fn == 'queryMqttCert') {
$("#serialnumber").hide();
} else {
$("#serialnumber").show();
}
};
updateFunction();
$("#node-input-function").change(updateFunction);
}
});
</script>
<script type="text/html" data-template-name="ecoflow-api">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-remote"><i class="fa fa-tag"></i> Remote Server</label>
<input type="text" id="node-input-remote" placeholder="Remote API">
</div>
<div class="form-row">
<label for="node-input-function"><i class="fa fa-tag"></i> Function</label>
<input type="" id="node-input-function">
</div>
<div class="form-row" id="serialnumber">
<label for="node-input-serial_number"><i class="fa fa-tag"></i> Serial Number</label>
<input type="text" id="node-input-serial_number" placeholder="Serial Number">
</div>
</script>
<script type="text/html" data-help-name="ecoflow-api">
<p>This node uses the offical Ecoflow HTTP-API to make
request for ecoflow device data.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sn
<span class="property-type">string</span>
</dt>
<dd>The serial number of the device to execute a function for (not used by deviceList).</dd>
<dt>payload
<span class="property-type">string/json</span></dt>
<dd>Contains the data to be used in the function.<br/>
This is different based on the function used:
<dl>
<dt>queryQuotaAll</dt>
<dd>Contains the serial number of the device to query (as string). Is used if msg.sn is not set.</dd>
<dt>setQuota</dt>
<dd>Contains a json with all parameters beside the serial number needed for the SetCommand.<br/>
A better option is not posible because the needed json differs from device to device.<br/>
E.g.:
</dd>
</dl>
</dd>
<dt>function
<span class="property-type">string</span>
</dt>
<dd>The function to execute (for niche applications only,
the function should be set on the node for better visibility).<br/>
Can be one of
<ul>
<li>deviceList</li>
<li>queryQuotaAll</li>
<li>setQuota</li>
<li>queryMqttCert</li>
</ul>
</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<dl class="message-properties">
<dt>payload
<span class="property-type">json</span></dt>
<dd>the output of the command, see the
<a href="https://developer-eu.ecoflow.com/us/document/generalInfo">documentation</a>
for structure and content<br/>
<b>Attention</b>: please see the "Known Problems" section in the <a href="https://flows.nodered.org/node/@shaoranlaos/node-red-contrib-ecoflow-http-api">Readme</a>
of the node for some "quirks" in the returned values.
</dd>
</dl>
</ol>
<h2>Details</h2>
<p>For Details see <a href="https://flows.nodered.org/node/@shaoranlaos/node-red-contrib-ecoflow-http-api">Readme</a></p>
</script>