node-red-contrib-esphome 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/build/nodes/in.html +17 -9
- package/build/nodes/in.js +2 -0
- package/build/nodes/in.js.map +1 -1
- package/package.json +7 -7
- package/src/nodes/in.ts +2 -0
package/README.md
CHANGED
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
|
|
20
20
|
Node-RED nodes to ESPhome devices
|
|
21
21
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
## Prerequisites
|
|
23
|
+
Your ESPHome device must be configured with the ESPHome API enabled.
|
|
24
|
+
|
|
25
|
+
In your device.yaml configuration file:
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
# Example configuration entry
|
|
29
|
+
api:
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See [ESPHome documentation on api configuration](https://esphome.io/components/api.html) for more information.
|
|
33
33
|
|
|
34
34
|
## Installation
|
|
35
35
|
|
package/build/nodes/in.html
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
name: {},
|
|
8
8
|
device: {value: '', type: 'esphome-device'},
|
|
9
9
|
entity: {value: ''},
|
|
10
|
+
topic: {value: ''},
|
|
10
11
|
bleaddress: {value: ''}
|
|
11
12
|
},
|
|
12
13
|
outputs: 1,
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
$('#node-input-device').on('change', selectEntity);
|
|
88
|
-
$('#node-input-entity').on('change', function() {
|
|
89
|
+
$('#node-input-entity').on('change', function () {
|
|
89
90
|
let $val = $(this).val() || node.entity;
|
|
90
91
|
$val == 'ble' ? $('#ble-show').show() : $('#ble-show').hide();
|
|
91
92
|
});
|
|
@@ -115,6 +116,11 @@
|
|
|
115
116
|
<select id="node-input-entity" style="width: 70%;" disabled></select>
|
|
116
117
|
</div>
|
|
117
118
|
|
|
119
|
+
<div class="form-row">
|
|
120
|
+
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
|
|
121
|
+
<input type="text" id="node-input-topic" placeholder="Topic" />
|
|
122
|
+
</div>
|
|
123
|
+
|
|
118
124
|
<div id="ble-show" style="display: none;">
|
|
119
125
|
<div class="form-row">
|
|
120
126
|
<label for="node-input-bleaddress"><i class="fa fa-bluetooth"></i> Address</label>
|
|
@@ -124,16 +130,18 @@
|
|
|
124
130
|
</script>
|
|
125
131
|
|
|
126
132
|
<script type="text/html" data-help-name="esphome-in">
|
|
127
|
-
<p>
|
|
128
|
-
<h3>
|
|
133
|
+
<p>Subscribes to an ESPHome Device's entity & outputs on state change</p>
|
|
134
|
+
<h3>Message properties</h3>
|
|
129
135
|
<dl class="message-properties">
|
|
130
136
|
<dt class="required">payload<span class="property-type">object</span></dt>
|
|
131
|
-
<dd>state</dd>
|
|
137
|
+
<dd>information about the event, such as state, brightness, position, etc</dd>
|
|
132
138
|
<dt class="required">device<span class="property-type">object</span></dt>
|
|
133
|
-
<dd>information of device</dd>
|
|
134
|
-
<dt class="required">config<span class="property-type">object</span></dt>
|
|
135
|
-
<dd>config attr of entity</dd>
|
|
139
|
+
<dd>information of the device, such as name & model</dd>
|
|
136
140
|
<dt class="required">entity<span class="property-type">object</span></dt>
|
|
137
|
-
<dd>information of entity</dd>
|
|
141
|
+
<dd>information of the device's entity, such as name & type</dd>
|
|
142
|
+
<dt class="required">entity.config<span class="property-type">object</span></dt>
|
|
143
|
+
<dd>config attributes of the entity</dd>
|
|
144
|
+
<dt class="required">topic<span class="property-type">string</span></dt>
|
|
145
|
+
<dd>Sets a topic for the messages generated by the node</dd>
|
|
138
146
|
</dl>
|
|
139
|
-
</script>
|
|
147
|
+
</script>
|
package/build/nodes/in.js
CHANGED
|
@@ -39,6 +39,7 @@ module.exports = (RED) => {
|
|
|
39
39
|
};
|
|
40
40
|
const onState = (state) => {
|
|
41
41
|
const payload = Object.assign({}, state);
|
|
42
|
+
const topic = self.config.topic === undefined ? '' : self.config.topic;
|
|
42
43
|
if (payload.key != config.entity) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
@@ -51,6 +52,7 @@ module.exports = (RED) => {
|
|
|
51
52
|
setStatus({ fill: 'yellow', shape: 'dot', text: text }, 3000);
|
|
52
53
|
const entity = self.deviceNode.entities.find((e) => e.key == config.entity);
|
|
53
54
|
self.send({
|
|
55
|
+
topic: topic,
|
|
54
56
|
payload: payload,
|
|
55
57
|
device: self.deviceNode.device,
|
|
56
58
|
entity: entity
|
package/build/nodes/in.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in.js","sourceRoot":"","sources":["../../src/nodes/in.ts"],"names":[],"mappings":";;AACA,wCAAoC;AAEpC,MAAM,CAAC,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE;IAChC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,UAAqB,MAAW;QACnE,4DAA4D;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEnC,SAAS;QACT,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAE7B,IAAI,CAAC;YACH,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,WAAW;QACb,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAG,CAAC,OAAO,GAAG,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AAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAM,EAAE,IAAe,EAAE,EAAE;YAC3C,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACxD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1D,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-esphome",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Node-RED nodes to ESPhome devices",
|
|
5
5
|
"homepage": "https://github.com/twocolors/node-red-contrib-esphome",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@2colors/esphome-native-api": "1.3.
|
|
32
|
+
"@2colors/esphome-native-api": "1.3.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^
|
|
35
|
+
"@types/node": "^22.5.0",
|
|
36
36
|
"@types/node-red": "^1.2.1",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
38
|
-
"@typescript-eslint/parser": "^
|
|
39
|
-
"eslint": "
|
|
40
|
-
"eslint-config-prettier": "^
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
38
|
+
"@typescript-eslint/parser": "^8.3.0",
|
|
39
|
+
"eslint": "9.24.0",
|
|
40
|
+
"eslint-config-prettier": "^10.0.1",
|
|
41
41
|
"eslint-plugin-node": "^11.1.0",
|
|
42
42
|
"eslint-plugin-prettier": "^5.0.0",
|
|
43
43
|
"prettier": "^3.0.0",
|
package/src/nodes/in.ts
CHANGED
|
@@ -44,6 +44,7 @@ module.exports = (RED: NodeAPI) => {
|
|
|
44
44
|
|
|
45
45
|
const onState = (state: any) => {
|
|
46
46
|
const payload: any = {...state};
|
|
47
|
+
const topic: any = self.config.topic === undefined ? '' : self.config.topic;
|
|
47
48
|
|
|
48
49
|
if (payload.key != config.entity) {
|
|
49
50
|
return;
|
|
@@ -62,6 +63,7 @@ module.exports = (RED: NodeAPI) => {
|
|
|
62
63
|
const entity: any = self.deviceNode.entities.find((e: any) => e.key == config.entity);
|
|
63
64
|
|
|
64
65
|
self.send({
|
|
66
|
+
topic: topic,
|
|
65
67
|
payload: payload,
|
|
66
68
|
device: self.deviceNode.device,
|
|
67
69
|
entity: entity
|