Home Assistant Community Add-on: Node-RED

To manually use the spartan fork, add this to your node-red addon, but remember that it might change whenever the spartan fork is updated. You’ll need to update all your current_state nodes by editing it, removing the last letter and choose the correct entity again.

“npm_packages”: [
GitHub - Spartan-II-117/node-red-contrib-home-assistant-llat: Home Assistant + Node-Red
],

Also, the spartan fork changes how the msg.payload is presented, the payload after a current_state node is “msg.payload.state”, but there are also more information to get from it, like “last_changed” and “last_updated”

Here’s an example of the payloads from a current_state node

21/07/2018, 13:52:06node: 2633ed48.6f65c2
msg.payload : Object
object
attributes: object
entity_id: “input_select.dygn_status_dropdown”
last_changed: “2018-07-21T10:51:07.657639+00:00”
last_updated: “2018-07-21T10:51:49.900134+00:00”
state: “Dag”

Please note, the example might be wrong, since the remote fork updates as well. The example shows v0.3.3 as the pinned version, nevertheless, the fork might be on a newer version already. I know for a fact, that @Spartan.II.117 works/worked on a fix for this, to gain more backwards compatibility. So I would suggest you take a look at the fork and use the latest version which works for you.

Oh by the way, the log of the add-on itself says:
[error] [server:Home Assistant] Error: Request failed with status code 403 over and over again.
172.30.32.2: banned_at: '2018-07-21T12:10:18' keeps getting added to my ip_bans.yaml as well.

Interesting case @tielemans.jorim. I’ve installed the add-on with all the latest and greatest version of everything, but am unable to reproduce it.
Could you provide some more information? Like:

  • are using the new Auth system (which is tech preview)?
  • What URL do you have configured in your Node-RED?
  • Did you manually specify a password for Home Assistant in Node-RED?

@tielemans.jorim PS, this is what your server settings in Home Assistant should look like:

image

No, I’m not using the new Auth system.
image
Currently I don’t even have any flows setup in Node-RED,
just a clean installed add-on a few days ago on a fresh HassOS install.
1 user, default port, ssl and require_ssl true.

By the way, already saw another user with those problems.
Asked him to chime in here this morning: Simple thing, spent hours to no avail

According to your log posted earlier, the “disconnection” was only temporary? (Maybe during Home Assistant upgrade?)

Secondly, you said:

Currently I don’t even have any flows setup in Node-RED

So I wonder, how did you conclude it is not working?

I just wanted to report I have errors, just made a quick flow (tried to toggle/turn on a switch) and can confirm it didn’t work.

Sytem log shows that the toggle service is called:

18-07-21 14:45:35 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered
18-07-21 14:45:36 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream close
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/states access from a0d7b954_nodered
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered
18-07-21 14:45:37 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/services/switch/toggle access from a0d7b954_nodered
18-07-21 14:45:38 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered
18-07-21 14:45:39 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 14:45:39 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 14:45:39 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream close
18-07-21 14:45:39 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/states access from a0d7b954_nodered
18-07-21 14:45:39 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered
18-07-21 14:45:40 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/config access from a0d7b954_nodered

Yeah, that is correct behavoir, since it should… :confused:

As in, the correct calls are made, the reason why the switch is not working in your case… dunno?

I will test this.

Node-RED add-on log show something else now:

21 Jul 16:54:02 - [error] [server:Home Assistant] Error: Request failed with status code 403
21 Jul 16:54:03 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:03 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:04 - [error] [server:Home Assistant] Error: Request failed with status code 403
21 Jul 16:54:05 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:05 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:05 - [warn] [api-call-service:ad6228ba.003498] Error calling service, home assistant api error
21 Jul 16:54:05 - [error] [api-call-service:ad6228ba.003498] Error calling service, home assistant api error
21 Jul 16:54:06 - [error] [server:Home Assistant] Error: Request failed with status code 403
21 Jul 16:54:07 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:07 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:08 - [error] [server:Home Assistant] Error: Request failed with status code 403
21 Jul 16:54:09 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>
21 Jul 16:54:09 - [error] [server:Home Assistant] Home assistant connection failed with error: Connection to home assistant could not be established with config: http://hassio/homeassistant <password redacted>

That’s just a part of it but wanted to show logs corresponding with the service call.

Edit: Hm, the ip ended up in the ban list again: 172.30.32.2; I’ll try to remove it and try again.
Edit2: Yeah, just keeps getting added to the list, was considering to add it as trusted_networks but that won’t fix the problem that it can’t login correctly: Login attempt or request with invalid authentication from 172.30.32.2.

HI I also getting the same error.
I have duckdns but Ima using inside the nodered as https://192.168.1.190:8123 is working (loaded) but in the log I can see lot off errors. What that is mean ?

Home assistant connection failed with error: Connection to home assistant could not be established with config: https://192.168.1.190:8123

If somebody has a solution :slight_smile:

Thx Robert.

That is not the recommended setup. You are either using an different add-on, or modified the settings yourself.
That will causes issues and is not supported by this add-on.

I almost feel like the API key is broken somewhere?
Could you try un-installing the add-on, removing the node-red folder from your config directory, install it again, try it again?

I know that this is not a solution in general, but it should provide a new API token for Node-RED to use.

Same thing happens.
As soon as Home Assistant and the add-on is starting up the IP gets blocked for failed login attempts.
Any other logs I can provide or things I should try out?

This is the add-on config I’m using:

{
  "log_level": "info",
  "credential_secret": "MarryPoppinsSupercalifragilisticexpialidocious",
  "users": [
    {
      "username": "admin",
      "password": "secret",
      "permissions": "*"
    }
  ],
  "http_node": {
    "username": "",
    "password": ""
  },
  "http_static": {
    "username": "",
    "password": ""
  },
  "port": 1880,
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_ssl": true,
  "system_packages": [],
  "npm_packages": [],
  "init_commands": []
}

Well… at this point, I’m unable to produce this. Have tried on different platforms and installation types :weary:

So recap: I was able to reproduce the issue.
@pvizeli Found the bug and a new Hass.io Supervisor release will be put out to fix it. :tada:

1 Like

Hi guys,

I’m trying to install the node-red node node-red-contrib-modbustcp through the “manage palette” menu. unfortunately this doesn’t seem to work on the Hass.io version.
The logging shows me some errors: apparently something with node-pre-gyp install.
Any ideas whats wrong?

21 Jul 21:35:55 - [info] Installing module: node-red-contrib-modbustcp, version: 1.2.1
21 Jul 21:38:35 - [warn] Installation of module node-red-contrib-modbustcp failed:
21 Jul 21:38:35 - [warn] ------------------------------------------
21 Jul 21:38:35 - [warn] 
> [email protected] install /config/node-red/node_modules/jsmodbus/node_modules/serialport
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/5.0.0/serialport-v5.0.0-node-v57-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI) (falling back to source compile with node-gyp) 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Linux 4.4.50
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release"
gyp ERR! cwd /config/node-red/node_modules/jsmodbus/node_modules/serialport
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/config/node-red/node_modules/jsmodbus/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.4.50
node-pre-gyp ERR! command "/usr/bin/node" "/config/node-red/node_modules/jsmodbus/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /config/node-red/node_modules/jsmodbus/node_modules/serialport
node-pre-gyp ERR! node -v v8.11.3
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/config/node-red/node_modules/jsmodbus/node_modules/serialport/build/Release' (1)
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-21T19_38_33_973Z-debug.log

kind regards
Pascal

1 Like

It is in the logs!

I think you should specify extra Node-RED nodes in the add-on options under npm_packages
From the docs:

Option: npm_packages
Allows you to specify additional NPM packages or Node-RED nodes to be installed to your Node-RED setup (e.g., node-red-dashboard, node-red-contrib-ccu).

Note: Adding many packages will result in a longer start-up time for the add-on.

ok, can’t find python. And how do I install Python on Hass.io?

Pascal