Shelly devices support both the http and the MQTT protocol and you can use either protocol to control and change the settings of Shelly devices.
Just as with Tasmota devices you can use either the standard HTTP and MQTT nodes or alternatively install the Shelly nodes.
Shelly HTTP Nodes
These are installed via the manage Pallete option and are called node-red-contrib-shelly.
When you install them a menu group called Shelly is created with three nodes as shown below:
To use you simple drag and drop into the workspace. A simple flow is shown below:
Before you can use it you will need to configure the node.You will need to add.
- IP or host name of the device
- description -optional
- User name -optional device dependant
- Password –optional device dependant
- relay type
- Polling or Callbacks
- Callback settings if callbacks used
- Polling interval if polling used.
- Polling Interval
- enable status output after poll and each command should normally be enabled
Polling and Callbacks
These are ways of determining the status of the Shelly device. The node documentation has a good description of these options.
Polling is easy to use and configure and is is old an trusted technique.
All you need to do is to set the polling interval. I choose 5 secs as a reasonable compromise.
Node Output
Provided you have enabled status output after each poll then you should see the device status along with other data on the output node.
Node Input
You need to inject a JSON array on msg.payload.
You can change device settings and also give device commands. In the case of a simple relay like Shelly 1 this is simply turning the device on and off.
Again the documentation gives examples. The example flow has two examples to turn the device off with a timer (turns back on after time out) and to turn off without timer.
Shelly Nodes vs Generic HTTP nodes
Using the Shelly nodes as opposed to the generic HTTP node is much easier as you don’t need to worry about building the correct URL.
Shelly MQTT Node
This you need to install via the manage pallete.It is called node-red-contrib-shelly–mqtt.
It creates a single node in the nodes menu under the shelly group
The node is a wrapper for the MQTT node and allows you to send a single action to a single Shelly device.
It also allows you to monitor the state of a single device.
The big advantage is that you don’t need to understand the topic or payload structure to use it.
Documentation is here
Shelly MQTT Nodes vs Generic MQTT Node
The Shelly MQTT node is useful if you only have one or two Shelly devices but not really of use if you have lots of devices.
It doesn’t allow you to set any device settings like you can with the generic MQTT node.
Summary
Although the Shelly HTTP and MQTT nodes are useful for getting started and managing a few Shelly devices they are not really suitable for more than a few devices with basic control requirements.
Related Tutorials and resources: