node-red-contrib-lgtv-notify 1.0.0 → 1.0.2
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 +6 -0
- package/nodes/lgtv-notify.html +1 -1
- package/nodes/lgtv-notify.js +20 -3
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -94,6 +94,12 @@ return msg;
|
|
|
94
94
|
- Notifications only appear when the TV is on and displaying content
|
|
95
95
|
- Maximum message length is 60 characters
|
|
96
96
|
|
|
97
|
+
## Support
|
|
98
|
+
|
|
99
|
+
If you find this useful, consider buying me a coffee:
|
|
100
|
+
|
|
101
|
+
[](https://buymeacoffee.com/rcaldeira)
|
|
102
|
+
|
|
97
103
|
## License
|
|
98
104
|
|
|
99
105
|
MIT
|
package/nodes/lgtv-notify.html
CHANGED
package/nodes/lgtv-notify.js
CHANGED
|
@@ -40,6 +40,7 @@ module.exports = function(RED) {
|
|
|
40
40
|
|
|
41
41
|
node.connection.on('error', (err) => {
|
|
42
42
|
node.error(`Connection error: ${err.message}`);
|
|
43
|
+
node.warn(`Full error: ${JSON.stringify(err)}`);
|
|
43
44
|
node.connected = false;
|
|
44
45
|
node.connecting = false;
|
|
45
46
|
});
|
|
@@ -56,7 +57,8 @@ module.exports = function(RED) {
|
|
|
56
57
|
node.connection.on('connect', () => {
|
|
57
58
|
node.connected = true;
|
|
58
59
|
node.connecting = false;
|
|
59
|
-
node.log(`Connected to ${node.host}`);
|
|
60
|
+
node.log(`Connected to TV at ${node.host}`);
|
|
61
|
+
node.warn(`Connection established - clientKey: ${node.connection.clientKey ? 'present' : 'missing'}`);
|
|
60
62
|
|
|
61
63
|
// Save client key for future connections
|
|
62
64
|
if (node.connection.clientKey && node.connection.clientKey !== node.clientKey) {
|
|
@@ -82,16 +84,26 @@ module.exports = function(RED) {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
this.sendToast = function(message, callback) {
|
|
87
|
+
node.warn(`sendToast called - connected: ${node.connected}, message: "${message}"`);
|
|
88
|
+
|
|
85
89
|
if (!node.connected) {
|
|
90
|
+
node.warn(`Not connected, queuing message. Queue size: ${node.queue.length + 1}`);
|
|
86
91
|
node.queue.push({ message, callback });
|
|
87
92
|
node.connect();
|
|
88
93
|
return;
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
node.warn(`Sending toast request to TV...`);
|
|
91
97
|
node.connection.request(
|
|
92
98
|
'ssap://system.notifications/createToast',
|
|
93
99
|
{ message: message },
|
|
94
100
|
(err, res) => {
|
|
101
|
+
if (err) {
|
|
102
|
+
node.error(`Toast request failed: ${err.message || err}`);
|
|
103
|
+
node.warn(`Full error object: ${JSON.stringify(err)}`);
|
|
104
|
+
} else {
|
|
105
|
+
node.warn(`Toast response: ${JSON.stringify(res)}`);
|
|
106
|
+
}
|
|
95
107
|
if (callback) callback(err, res);
|
|
96
108
|
}
|
|
97
109
|
);
|
|
@@ -127,16 +139,21 @@ module.exports = function(RED) {
|
|
|
127
139
|
this.on('input', function(msg, send, done) {
|
|
128
140
|
const message = msg.payload || config.message || 'Notification';
|
|
129
141
|
|
|
142
|
+
node.warn(`Input received - payload type: ${typeof msg.payload}, message to send: "${message}"`);
|
|
130
143
|
node.status({ fill: 'yellow', shape: 'dot', text: 'sending...' });
|
|
131
144
|
|
|
132
145
|
node.tv.sendToast(message, (err, res) => {
|
|
146
|
+
node.warn(`Callback received - err: ${err ? JSON.stringify(err) : 'null'}, res: ${JSON.stringify(res)}`);
|
|
147
|
+
|
|
133
148
|
if (err) {
|
|
134
149
|
node.status({ fill: 'red', shape: 'dot', text: 'error' });
|
|
150
|
+
node.error(`Failed to send toast: ${err.message || JSON.stringify(err)}`, msg);
|
|
135
151
|
if (done) done(err);
|
|
136
|
-
else node.error(err, msg);
|
|
137
152
|
} else {
|
|
153
|
+
node.warn(`Toast sent successfully - toastId: ${res ? res.toastId : 'unknown'}`);
|
|
138
154
|
node.status({ fill: 'green', shape: 'dot', text: 'sent' });
|
|
139
|
-
msg.toastId = res.toastId;
|
|
155
|
+
msg.toastId = res ? res.toastId : null;
|
|
156
|
+
msg.tvResponse = res;
|
|
140
157
|
send(msg);
|
|
141
158
|
if (done) done();
|
|
142
159
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-lgtv-notify",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Send toast notifications to LG webOS TVs from Node-RED. Works with webOS 10+ (2025 TVs).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
"smart-home",
|
|
14
14
|
"home-automation"
|
|
15
15
|
],
|
|
16
|
-
"author": "rcaldeira",
|
|
16
|
+
"author": "rcaldeira <ricardo.caldeira.00@gmail.com>",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "git+https://github.com/Ricardo-Miguel-Caldeira/node-red-contrib-lgtv-notify.git"
|
|
21
21
|
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/Ricardo-Miguel-Caldeira/node-red-contrib-lgtv-notify/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/Ricardo-Miguel-Caldeira/node-red-contrib-lgtv-notify#readme",
|
|
22
26
|
"node-red": {
|
|
23
|
-
"version": ">=2.0.0",
|
|
24
27
|
"nodes": {
|
|
25
28
|
"lgtv-notify": "nodes/lgtv-notify.js"
|
|
26
29
|
}
|