New Node-RED add-on

Hi Kory,

Yeah, best practice I guess.

The issue with the nodes is kinda like this;

Previously, the ‘event’ nodes from HA would indicate their latest event state.
I.e. on/off and a timestamp on when that event fired for a binary sensor.

Now, it just has ‘connected’ with a green LED for the ‘start’ event, but all other nodes are blank. No time stamp, no json output nothing. This was really handy for debugging without using a debug node cluttering up the flows.

Now this ‘may’ be from the HA plugin for node-red itself, but not sure.

Also, btw, upon rebooted my PI, I get this;
Only happened with the 1.6 afaik…
Forced me to manually start node-red on a reboot of the PI. Not ideal.

Any ideas?

21 Feb 23:04:06 - [red] Uncaught Exception:
21 Feb 23:04:06 - TypeError: Cannot read property ‘state’ of null
at ServerStateChangedNode.shouldHaltIfState (/share/node-red/node_modules/node-red-contrib-home-assistant/nodes/server-events-state-changed/server-events-state-changed.js:53:83)
at ServerStateChangedNode.onHaEventsStateChanged (/share/node-red/node_modules/node-red-contrib-home-assistant/nodes/server-events-state-changed/server-events-state-changed.js:28:45)
at emitOne (events.js:121:20)
at HaEvents.emit (events.js:211:7)
at HaEvents.onClientMessage (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:59:22)
at EventSource.client.on (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:27:49)
at emitOne (events.js:116:13)
at EventSource.emit (events.js:211:7)
at _emit (/share/node-red/node_modules/eventsource/lib/eventsource.js:222:17)
at parseEventStreamLine (/share/node-red/node_modules/eventsource/lib/eventsource.js:237:9)

My bad Kory. I shouldn’t have made this edit but create a new post to make it more clear.

I did a little more testing today after you confirmed again that you can’t reproduce it and found the culprit. For whatever reason my flows are causing the problem. Everything works as expected but as soon as I import my flows using the clipboard import function it starts to malfunction.

I’ve tested if deleting the settings file, deleting the whole node-red folder or doing a fresh install of your add-on solves the issue but it always returns after importing my flows.

It’s pretty strange because I’m not doing anything special there. Just some Home Assistants nodes, some functions, triggers, debug nodes and a catch all node…

I might recreate my flows manually at some point and test if/when the problem returns. For now I’m fine using the workaround when required.

@viperIII I’m seeing the same as you. It would seem the problem is with the node-red-contrib-home-assistant update itself.

As far as Node-RED not starting on reboot, this is a common issue. Again, we’re pretty sure this has to do with the node-red-contrib-home-assistant palette. I’ve created this issue to track it, but haven’t had much time to work on it yet.

@Florian, that’s really strange. The run.sh script that modifies the config doesn’t ever even look at the flows file. If you can send me an example of the file that causes the issue, I can try and see what’s going on.

1 Like

Looks like you don’t need my flows. It’s enough to alter the add-on’s options.

You can try it with this config to reproduce it (mind the admin_users):

{
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "admin_users": [],
  "http_user": {
    "username": "",
    "password": ""
  }
}

First start with above’s config:

starting version 3.2.4
created default settings
SSL Enabled
Admin Authentication Disabled
HTTP Authentication Disabled
4 Mar 10:57:21 - [info] 
Welcome to Node-RED
===================
4 Mar 10:57:21 - [info] Node-RED version: v0.18.3
4 Mar 10:57:21 - [info] Node.js  version: v8.9.3
4 Mar 10:57:21 - [info] Linux 4.4.50 arm LE
4 Mar 10:57:22 - [info] Loading palette nodes
4 Mar 10:57:24 - [warn] Cannot find Pi RPi.GPIO python library
4 Mar 10:57:28 - [warn] ------------------------------------------------------
4 Mar 10:57:28 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
4 Mar 10:57:28 - [warn] ------------------------------------------------------
4 Mar 10:57:28 - [info] Settings file  : /share/node-red/settings.js
4 Mar 10:57:28 - [info] User directory : /share/node-red
4 Mar 10:57:28 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
4 Mar 10:57:28 - [info] Flows file     : /share/node-red/flows.json
4 Mar 10:57:28 - [info] Creating new flow file
4 Mar 10:57:28 - [info] Starting flows
4 Mar 10:57:28 - [info] Started flows
4 Mar 10:57:28 - [info] Server now running at https://127.0.0.1:1880/

Subsequent starts with above’s config:

starting version 3.2.4
SSL Enabled
Admin Authentication Disabled
HTTP Authentication Disabled
4 Mar 11:04:31 - [info] 
Welcome to Node-RED
===================
4 Mar 11:04:31 - [info] Node-RED version: v0.18.3
4 Mar 11:04:31 - [info] Node.js  version: v8.9.3
4 Mar 11:04:31 - [info] Linux 4.4.50 arm LE
4 Mar 11:04:41 - [info] Loading palette nodes
4 Mar 11:04:43 - [warn] Cannot find Pi RPi.GPIO python library
4 Mar 11:04:46 - [warn] ------------------------------------------------------
4 Mar 11:04:46 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
4 Mar 11:04:46 - [warn] ------------------------------------------------------
4 Mar 11:04:46 - [info] Settings file  : /share/node-red/settings.js
4 Mar 11:04:46 - [info] User directory : /share/node-red
4 Mar 11:04:46 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
4 Mar 11:04:46 - [info] Flows file     : /share/node-red/flows.json
4 Mar 11:04:46 - [info] Creating new flow file
4 Mar 11:04:46 - [info] Starting flows
4 Mar 11:04:46 - [info] Started flows
4 Mar 11:04:46 - [info] Server now running at http://127.0.0.1:1880/

@Florian thanks! I tracked the bug down and it’s fixed in version 1.7. Please let me know if you have any more issues with it.

I also changed the networking to Host networking.

Finally, I added some Home Assistant detection that I hope will fix the issue of the add-on crashing on device startup. @viperIII (and anyone else who can), can you try version 1.7 and see if the add-on starts correctly on restart?

1 Like

@korylprince, No issues thus far.
Thanks!!!

Any chance we can roll back to the older version of the HA plugin?
The lack of flow info is very frustrating.

That said, I have a colleague who is using the same revision, and he has the flow info’s shown :confused:

I sometimes find that node-red does not pick up modified nodes correctly. Opening the config of the node and saving it (without revision) often solves it.

@viperIII, I had already been thinking about adding that feature!

I finally got around to it today, and version 1.8 with the palette_version option is now released.

Let me know if you have any trouble with it.

Hey. I have big problem after install and run addon.
When node-red start, HA is very unstable.
A lot of:

Timer out of sync

Normal HA ui works very unstable, Light switch change after 0:25 second to 2 minutes.
Open HASSio window takes forever.

After stop Node-Red everything back to normal.

I run my HASSio on NUC with i5 processor and 8gb of ram.

For all of those struggling with SSL, receiving “Connection to home assistant could not be established with config” errors over and over again, I solved the problem by using the SSL port 443, and making sure that the server address did not end with a slash:

So:

 https://mydomain.com:443

Worked, but…

 https://mydomain.com:443/ 

… or any combination of 8123, 443, did not.

As a reminder, restart the node-red addon to clear out all other errors.

@MrEd, that’s the first I know of anyone having that issue. Are you running the official Hass.io image?

Can you post the add-on logs and the supervisor logs?

having some problems with this addon stopping recently.

once every few days it seems to crash, here’s the last bit of the logs:

15 Apr 00:08:26 - [info] [mqtt-broker:server] Disconnected from broker: mqtt://192.168.16.5:1883
15 Apr 00:08:41 - [info] [mqtt-broker:server] Connected to broker: mqtt://192.168.16.5:1883
15 Apr 10:44:43 - [warn] [api-current-state:Off Already?] entity could not be found in cache for entity_id: group.livingroom, sending empty payload
16 Apr 00:05:54 - [info] [mqtt-broker:server] Disconnected from broker: mqtt://192.168.16.5:1883
16 Apr 00:06:09 - [info] [mqtt-broker:server] Connected to broker: mqtt://192.168.16.5:1883
16 Apr 10:42:46 - [warn] [api-current-state:Off Already?] entity could not be found in cache for entity_id: group.livingroom, sending empty payload
16 Apr 12:44:39 - [red] Uncaught Exception:
16 Apr 12:44:39 - TypeError: Cannot read property ‘state’ of null
at ServerStateChangedNode.onHaEventsStateChanged (/share/node-red/node_modules/node-red-contrib-home-assistant/nodes/server-events-state-changed/server-events-state-changed.js:38:42)
at emitOne (events.js:121:20)
at HaEvents.emit (events.js:211:7)
at HaEvents.onClientMessage (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:59:22)
at EventSource.client.on (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:27:49)
at emitOne (events.js:116:13)
at EventSource.emit (events.js:211:7)
at _emit (/share/node-red/node_modules/eventsource/lib/eventsource.js:222:17)
at parseEventStreamLine (/share/node-red/node_modules/eventsource/lib/eventsource.js:237:9)
at IncomingMessage. (/share/node-red/node_modules/eventsource/lib/eventsource.js:200:11)

I am trying to call hassio restart addon service which I used to restart the other Node red addon and it’s failing here

2018-04-19 10:47:38 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1524152858.7908459, level=ERROR, message=Invalid service data for hassio.addon_restart: invalid slug f16403dc_node-red (try f16403dc_nodered) for dictionary value @ data[‘addon’]. Got ‘f16403dc_node-red’, exception=, source=core.py>

maybe something with the - in the name?

Same issue, It shuts down a few times a day and does not restart.

Node red hassio addon log:

28 Apr 01:46:46 - TypeError: Cannot read property ‘state’ of null
at ServerStateChangedNode.onHaEventsStateChanged (/share/node-red/node_modules/node-red-contrib-home-assistant/nodes/server-events-state-changed/server-events-state-changed.js:38:42)
at emitOne (events.js:121:20)
at HaEvents.emit (events.js:211:7)
at HaEvents.onClientMessage (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:59:22)
at EventSource.client.on (/share/node-red/node_modules/node-home-assistant/lib/ha-events.js:27:49)
at emitOne (events.js:116:13)
at EventSource.emit (events.js:211:7)
at _emit (/share/node-red/node_modules/eventsource/lib/eventsource.js:222:17)
at parseEventStreamLine (/share/node-red/node_modules/eventsource/lib/eventsource.js:237:9)
at IncomingMessage. (/share/node-red/node_modules/eventsource/lib/eventsource.js:200:11)

Supervisor logs:

18-04-28 05:24:04 INFO (SyncWorker_0) [hassio.docker.homeassistant] Start homeassistant homeassistant/qemux86-64-homeassistant with version 0.68.0b1
18-04-28 05:25:44 INFO (MainThread) [hassio.homeassistant] Detect a running Home-Assistant instance
18-04-28 05:27:16 INFO (SyncWorker_8) [hassio.docker.interface] Clean korylprince/hassio-node-red-amd64 docker application
18-04-28 05:27:16 INFO (SyncWorker_8) [hassio.docker.addon] Start docker addon korylprince/hassio-node-red-amd64 with version 1.8
18-04-28 05:27:23 INFO (MainThread) [hassio.api.security] /homeassistant/info access from fxxxxdc_node-red
18-04-28 05:30:19 INFO (SyncWorker_3) [hassio.docker.interface] Clean korylprince/hassio-node-red-amd64 docker application
18-04-28 05:30:20 INFO (SyncWorker_3) [hassio.docker.addon] Start docker addon korylprince/hassio-node-red-amd64 with version 1.8
18-04-28 05:30:26 INFO (MainThread) [hassio.api.security] /homeassistant/info access from f16403dc_node-red
18-04-28 10:22:58 INFO (MainThread) [hassio.updater] Fetch update data from https://raw.githubusercontent.com/home-assistant/hassio/rc/version.json
18-04-28 10:22:58 INFO (MainThread) [hassio.addons.git] Pull addon https://github.com/bestlibre/hassio-addons repository
18-04-28 10:22:58 INFO (MainThread) [hassio.addons.git] Pull addon https://github.com/hassio-addons/repository repository
18-04-28 10:22:58 INFO (MainThread) [hassio.addons.git] Pull addon https://github.com/james-fry/hassio-addons repository
18-04-28 10:22:58 INFO (MainThread) [hassio.addons.git] Pull addon https://github.com/korylprince/hassio-apcupsd repository

Hello all. Sorry for the radio silence. I’ve not had much time to work on this project lately. Luckily, it seems the crashing issue has been fixed.

I’ve release version 1.9 which bundles 0.3.2.

@shaddow, see this post for an explanation and work-around.

1 Like

Can you enable the Node RED Projects feature in this add-on?

Nevermind. Edited the settings.js to add the Projects feature.

Do we have a central location for people to share their flows? Would be interesting to see what others have been able to achieve with node-red

I think that the new category (for node-red) under third party integrations would be a good place for them.

May be include the exported flow, a screen shot with what it looks like and a short description of what it does.

https://community.home-assistant.io/c/third-party/node-red

1 Like

+1 for a new node red subcategory