-
Notifications
You must be signed in to change notification settings - Fork 0
2. Download and prepare Node Red
Steps:
- Download and load
- (Re)configure the MQTT broker
- Enable persistence (required!)
- Download the template JSON-file from the github repository at https://github.com/balk77/node-red-buttonplus-menu
- Open your node-red configuration page and create a new flow.
- Import the flows (As mentioned, a fairly good understanding of Node-red is required. Google might be your friend here.)
- Two new flows will be created:
- ‘Button+ modes’ and
- Button+
The Flow has a preconfigured MQTT broker; the IP-address/domain name of your broker is most likely different from the one in the template, as (hopefully) are the user name and password. You have to change the credentials in the various mqtt nodes across the flow. For now, we assume there is only one broker in the configuration. If you have more than one broker, you have to change each and every node-red node that receives or sends MQTT. In a common configuration using one broker, it is advisable to change the configuration of the broker in the template.
To do so:
- Look for an MQTT-node in the button+-flow, like the purple node below:
- Double click on that node
- A dialog will open with the default server’s IP-address. Click on the pencil to the right of the field:
- A new dialog box will open:
- In the connection tab, change the IP-address to the IP-address or domain name of your broker
- In the Security tab, change the username and password to a user you created in your broker:
If you like, you can supply a name in the name-box. Otherwise it will use the IP-address as default Note: The username is case sensitive as well as the password. (Normally a username is not case sensitive.)
- Click on Done until you are back in the button+ flow.
- Verify that the node is connected to the broker, indicated by the green dot and the word ‘connected’:
If not, double check your configuration. Troubleshooting such an issue is beyond the scope of this document.
As the configuration of the Button+ dynamically changes based on various states in the flow, the button+ flow leans on retained configuration parameters, not only between the sent and received topics, but also across reboots of the broker. This means that the variables should be saved to and read from disk. Most brokers do not have that optiop enabled in the default configuration. The most used broker is Mosquitto (https://mosquitto.org/). We will use the configuration as an example, look in the documentation of your broker on how to enable retained variables across reboots.
- Open the mosquito configuration file (default: C:\Program Files\mosquitto\mosquitto.conf) and look for the following section:
In the default configuration, there are hashes (‘#’) in front of the three lines starting with ‘persistence’. The location of the database is not important, as long as the broker has write access.
- Restart mosquito for the change to take effect.
- Approach the
addon_configsshare of your Home Assistant instance through Samba. - Go to the folder named
<some_code>nodered. - Open the file
settings.jsin a text editor and scroll all the way down. - Add the following just before the closing `};':
,
contextStorage: {
default: "memoryOnly",
memoryOnly: { module: 'memory' },
file: { module: 'localfilesystem' }
}
Make sure you also copy the comma between contextStorage and the existing }.
- Restart Node Red addon