twocolors / node-red-contrib-home-assistant-discovery Goto Github PK
View Code? Open in Web Editor NEWNodes for controlling Home Assistant MQTT Discovery devices in Node-RED
Nodes for controlling Home Assistant MQTT Discovery devices in Node-RED
pi@raspberrypi:~ $ node -v
v16.19.0
pi@raspberrypi:~ $ npm -v
8.19.3
Node-red version 3.0.2
So this is the flow i am trying to do (similar to one of the examples):
[
{
"id": "8cd3a6b74dd73dcb",
"type": "ha-discovery-out",
"z": "f97c15c91ed475df",
"name": "Zimmer",
"server": "3a9b250ba5d6b411",
"dev_id": "zigbee2mqtt_0x00124b0024cb2366",
"uniq_id": "0x00124b0024cb2366_switch_zigbee2mqtt",
"qos": "0",
"retain": "false",
"payload": "payload",
"payload_type": "msg",
"x": 500,
"y": 340,
"wires": []
},
{
"id": "c30268b42210b258",
"type": "inject",
"z": "f97c15c91ed475df",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "ON",
"payloadType": "str",
"x": 270,
"y": 320,
"wires": [
[
"8cd3a6b74dd73dcb"
]
]
},
{
"id": "f2225d4772bee672",
"type": "inject",
"z": "f97c15c91ed475df",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "OFF",
"payloadType": "str",
"x": 270,
"y": 380,
"wires": [
[
"8cd3a6b74dd73dcb"
]
]
},
{
"id": "3a9b250ba5d6b411",
"type": "ha-discovery",
"name": "",
"server": "bff4588a2c004522",
"topic": "homeassistant/#"
},
{
"id": "bff4588a2c004522",
"type": "mqtt-broker",
"name": "local broker",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
The flow can be deployed, but whe triggering one of the Injectors, it sucesfully publishes to mqtt, but crashes node-red as a whole. This is the commad line output:
Welcome to Node-RED
23 Feb 23:58:08 - [info] Node-RED version: v3.0.2
23 Feb 23:58:08 - [info] Node.js version: v16.19.0
23 Feb 23:58:08 - [info] Linux 5.10.103+ arm LE
23 Feb 23:58:24 - [info] Loading palette nodes
23 Feb 23:58:45 - [info] Settings file : /home/pi/.node-red/settings.js
23 Feb 23:58:46 - [info] Context store : 'default' [module=memory]
23 Feb 23:58:46 - [info] User directory : /home/pi/.node-red
23 Feb 23:58:46 - [info] Projects directory: /home/pi/.node-red/projects
23 Feb 23:58:48 - [info] Server now running at http://127.0.0.1:1880/
23 Feb 23:58:48 - [info] Active project : pi
23 Feb 23:58:48 - [info] Flows file : /home/pi/.node-red/projects/pi/flow.json
23 Feb 23:58:48 - [warn] Using unencrypted credentials
23 Feb 23:58:48 - [info] Starting flows
23 Feb 23:58:50 - [info] Started flows
23 Feb 23:58:51 - [info] [mqtt-broker:local broker] Connected to broker: mqtt://127.0.0.1:1883
23 Feb 23:58:51 - [info] [ha-discovery:discovery @ local broker] MQTT fetch devices ...
23 Feb 23:59:14 - [red] Uncaught Exception:
23 Feb 23:59:14 - [error] TypeError: Cannot convert undefined or null to object
at Function.keys ()
at getKeyByValue (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-discovery/nodes/server.js:158:14)
at /home/pi/.node-red/node_modules/node-red-contrib-home-assistant-discovery/nodes/server.js:162:19
at Array.some ()
at getKeyByValue (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-discovery/nodes/server.js:158:24)
at /home/pi/.node-red/node_modules/node-red-contrib-home-assistant-discovery/nodes/server.js:183:23
at Array.forEach ()
at MqttClient.onMessage (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-discovery/nodes/server.js:181:22)
at MqttClient.emit (node:events:513:28)
at MqttClient._handlePublish (/usr/lib/node_modules/node-red/node_modules/mqtt/lib/client.js:1547:12)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=20s expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 15.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
23 Feb 23:59:54 - [info]
Welcome to Node-RED
23 Feb 23:59:54 - [info] Node-RED version: v3.0.2
23 Feb 23:59:54 - [info] Node.js version: v16.19.0
23 Feb 23:59:54 - [info] Linux 5.10.103+ arm LE
24 Feb 00:00:11 - [info] Loading palette nodes
24 Feb 00:00:33 - [info] Settings file : /home/pi/.node-red/settings.js
24 Feb 00:00:33 - [info] Context store : 'default' [module=memory]
24 Feb 00:00:33 - [info] User directory : /home/pi/.node-red
24 Feb 00:00:33 - [info] Projects directory: /home/pi/.node-red/projects
24 Feb 00:00:34 - [info] Server now running at http://127.0.0.1:1880/
24 Feb 00:00:35 - [info] Active project : pi
24 Feb 00:00:35 - [info] Flows file : /home/pi/.node-red/projects/pi/flow.json
24 Feb 00:00:35 - [warn] Using unencrypted credentials
24 Feb 00:00:36 - [info] Starting flows
24 Feb 00:00:38 - [info] Started flows
24 Feb 00:00:38 - [info] [mqtt-broker:local broker] Connected to broker: mqtt://127.0.0.1:1883
24 Feb 00:00:38 - [info] [ha-discovery:discovery @ local broker] MQTT fetch devices ...
Help please.
I have this node-red-contrib-ha-mqtt installed
https://flows.nodered.org/node/node-red-contrib-ha-mqtt
and I think this node is causing this error
Here is the Docker Nodered Log:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.