Homepage    |    GitHub    |    API    |    Wiki    |    FAQ

Joplin/Node-RED/Home Assistant Synergy

There's a set of Node-RED nodes, node-red-contrib-joplin, that enable relatively simple interface to Node-RED and Home Assistant via the Joplin API. The capabilities that the integration of the three enable are mind-boggling to me. I'm wondering how many Joplin users are also Node-RED and/or Home Assistant users. How are you using it? What have you created?

I've dabbled in using Node-RED to render Home Assistant templates and create/update Joplin notes to self-document my HA configuration and log various "events" around my home based on motion sensors, door/contact sensors. I'm still a relative newbie, but the automation capabilities are amazing.

If you try to implement this and your Node-RED instance is on a different host than your Joplin client, you have to deal with the fact that the Joplin client only binds to 127.0.0.1 to listen for API requests from the localhost. Here's part of my Joplin note that documents my procedure:

Install node-red-joplin-contrib Nodes to the Node-RED Pallette

  1. Launch Node Red
  2. From the menu, select Manage Pallette
  3. Select the Install tab
  4. In the Search Modules field, enter node-red-contrib-joplin
  5. Click Install

Configure the Joplin Data API

  1. In Joplin, Tools - Options - Web Clipper
  2. If not already activated, activate the Web Clipper Service as it is required for the Jopln Data API to run.
  3. In the Web Clipper configuration section, copy your Authorization Token as it will be required to configure the Joplin Configuration node in Node-RED.

Configure Access to the Joplin Data API

The Joplin Data API listens on port 41184, but it only binds to 127.0.0.1 to accept traffic from the localhost only. Requests originating from other hosts will be refused. To circumvent this "security feature", implement a port proxy on the system hosting Joplin. The port proxy will listen for requests on a port other than 41184 from hosts other than the localhost and will retransmit the request to 41184 on the localhost.

For Windows 10, the built-in command, netsh, can perform this function.

  1. To activate a port proxy to listen for requests from any host on port 41185 and retransmit them to 41184 on the localhost, execute the following command
 netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=41185 connectaddress=127.0.0.1 connectport=41184
  1. Open port 41185 on the firewall, if present. If using the built-in Windows Defender, this can be accomplished one of two ways:
    1. Use netsh to add a new firewall rule: netsh advfirewall firewall add rule name="Open Port 41185" dir=in action=allow protocol=TCP localport=41185

    2. On modern Windows machines, this can also be done via PowerShell commands: New-NetFirewallRule -Name JoplinAPI -DisplayName "JoplinAPI 41185" -Direction Inbound -Protocol tcp -LocalPort 41185 -Action Allow -Enabled True

To deactivate the port proxy:

  1. Execute the following command
    netsh interface portproxy reset
    
  2. To close the previously opened firewall port either:
    1. Remove the firewall rule using netsh: netsh advfirewall firewall del rule name="Open Port 41185"
    2. Remove the firewall rule using PowerShell: Remove-NetFirewallRule -Name JoplinAPI 41185
2 Likes

Interesting I use home assistant and manually paste in my config into joplin. Not too familiar with NodeRed tried to start using it but did not have enough time to learn how to make use of it. Maybe I will give it another go cause this is surely something I would use