New Node-RED add-on

I just pushed version 1.6. The container was missing git which caused trying to update node-red-contrib-home-assistant to fail. I’m not sure if there was a change on the npm package or what.

In any case, 0.3.0 is included in the new image.

Updated, and its rooted my flows.
states are now not updated, but some randomly work… almost impossible to debug.

Anyone else have the same?

Also get this on the log;

20 Feb 21:23:41 - [warn] Cannot find Pi RPi.GPIO python library
20 Feb 21:23:45 - [warn] ------------------------------------------------------
20 Feb 21:23:45 - [warn] [node-red/rpi-gpio] Warning : Cannot find Pi RPi.GPIO python library
20 Feb 21:23:45 - [warn] ------------------------------------------------------

@viperIII I’m sorry to hear that. By “rooted” you just mean “messed up”, right?

Are the nodes not appearing, or do they just not seem to be working?

I’ve seen issues before where if Node-RED is restarted the current-state nodes won’t work and Home Assistant sends a new state for that node. i.e. It doesn’t check the state when Node-RED is started, it waits for the state to come in. Could that be the issue you’re having?

Please restart the add-on, wait a couple of minutes, and then post the add-on logs.

The log messages are a known issue. Until the GPIO API for Hassio is fixed, I can’t include it in my add-on.

I can’t find any combination of slug, repository, dashes or not…that will let me trigger the hassio.addon_start with this addon.

I tried:

  • f16403dc_node-red
  • node-red
  • nodered

The error is that the addon doesn’t exist, or the slug was invalid. Example:

Invalid service data for hassio.addon_start: invalid slug f16403dc_node-red (try f16403dc_nodered) for dictionary value @ data['addon']. Got 'f16403dc_node-red'

@fearoffish

This is an issue with Home Assistant itself. The service won’t take the - in the name. I’ve filed an issue.

For the time being you can call the Hassio API directly using the RESTFul Command component:

rest_command:
  start_node_red:
    url: 'http://hassio/addons/f16403dc_node-red/start'
    method: 'post'
  stop_node_red:
    url: 'http://hassio/addons/f16403dc_node-red/stop'
    method: 'post'

Then just call the rest_command.start_node_red or rest_command.stop_node_red services.

Hey Kory, thanks for the reply.

I had to enter each node and then close it. The flows then worked. Guess with the update the flow logic needed to regenerate.

However state updates still aren’t shown :-/
Just shows connected on the start point of each flow and that’s it. Seems to just be the HA nodes. Others appear to work.

Btw, thanks for the addon. Appreciate your efforts for the community.

I think the suggestion is normally to move a node or something then redeploy the flow. I don’t usually have issues with it.

I don’t seem to have any issues with states. If I use the “events: state” node and filter on, say a lamp state, and plug that into debug, turning the lamp on and off generates the proper events.

If I insert a “current state” node between the previous two nodes and set it to the same lamp state with “Halt if” being set to “off”, only the “on” events show in debug.

That would indicate to me that everything is working, but I admit that I don’t have very complex flows.

This release also includes a “poll state” node which might help you overcome some of the issues you’ve been having.

@Florian

I just now saw your edit as I read your first reply soon after you posted it.

I’m afraid I can’t replicate your issue. I’ve tried "ssl": true and restarting the add-on several times. I also tried removing settings.js and letting it be recreated, then restarting the add-on several times.

Every time it worked as expected: the add-on started with HTTPS and I never saw the comment issue you mentioned.

Can you post your add-on options JSON (with passwords redacted)?

Also the add-on logs after a minute of running? That can help me troubleshoot what’s going 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?