Package detail

node-red-contrib-tasmota

davemds529MIT1.0.0

Node-RED integration for Tasmota flashed devices

node-red, tasmota, sonoff, home automation

readme

node-red-contrib-tasmota

License npm version node tasmota JavaScript Style Guide

npm total npm montly npm weekly

Run NPM tests

Tasmota devices integration for building automation inside Node-RED.

The goal of the project is to support a wide set of features exposed by the Tasmota firmware over MQTT.

Getting Started

This assumes you have Node-RED already installed and working, if you need to install Node-RED see here.

Install via Node-RED Manage Palette interface

node-red-contrib-tasmota

Install via npm

$ cd ~/.node-red
$ npm install node-red-contrib-tasmota
# then restart node-red

Nodes configuration

Basic config:

  • Broker set here your MQTT broker connection params, you should use a single broker configuration for all your Tasmota nodes, so that a single connection is shared for all nodes.
  • Device is the name of the Tasmota device, it must match the Topic field in your tasmota MQTT configuration.
  • Name it's just a label that is shown on the node itself, you can choose any name you like or leave it blank.
  • Send enable/disable messages if you connect the Tasmota nodes to a Node-Red dashboard node then you can use this flag to automatically disable the dashbord widget when the device goes offline.

Advanced config:

  • Full topic must match the Full Topic field in the Tasmota MQTT configuration, you can leave blank if you did not changed the default Tasmota value.
  • cmnd, stat, tele if you changed this parametes in your Tasmota config then you also need to set them here.

Example:

config

Available Nodes

Tasmota Switch node

Lets you control your tasmota switch, and of course give you messagges on state changes. The value is also requested on startup, so the state should always be accurate.

Support up to 8 channals devices, the node can be configured to send all the status changes to a single output (in this case the topic is used to distinguish channels) or can be configured to have N outputs (one for each channel).

Switch Flow1 Switch Flow2

Tasmota Sensor node

This node listen for telemetry from the tasmota device and fire a messagge with the JSON data received. On any input messagge fresh data is requested.

Outputs can be freely configured to extract only the data you are intrested in, you can configure as many output as you like, giving a JSONata expression for each output channel.

Sensor Flow1 Sensor Flow2

Tasmota Button node

This node receive button presses from a tasmota button device, it support all the tasmota button actions (TOGGLE, HOLD, SINGLE, DOUBLE, TRIPLE, etc...) and also multi buttons devices. The action is sent as a simple string on the node output. The node can be configured to send all press actions to a single output (in this case the topic is used to distinguish channels) or can be configured to have multiple outputs (one for each channel).

NOTE: Tasmota changed the Buttons/Switch functionality in firmware 9.1.0! This node support both formats, but it's raccomended to update to a recent Tasmota firmware.

See the detailed Tasmota documentation page for an in deep explanation. Also look at: SwitchMode, SetOption73, SetOption114, SetOption1, SetOption13, SetOption32 and setup the tasmota device to suite your needs.

Button Flow

Tasmota Light node

Lets you control your tasmota light bulb/controller, and of course give you messagges on state changes. The value is also requested on startup, so the output state is always accurate and full of all the available light info.

Light Flow1 Light Config

Turn on/off (simple mode)

To simply changes the light on / off state just send a msg.payload (without any topic) using one of the following values:

Topic Payload Values
boolean true / false
int 1 / 0
string 1 / 0 / on / off / true / false / toggle

Input (topic mode)

To change a single light property send a msg.payload with a specific topic:

Topic Payload Information
on same as simple mode Turn on / off / toggle the light
bright int Change the light brightness, range 0 to 100
ct int Color temperature, values (from warm to cold) can be expressed in Mired (500-153), Kelvin(2000-6500) or percent(0-100)
rgb int array or string Change the RGB colors, can be a string: "255,0,0" (for red) or an array of int: [255, 0, 0]
hsb int array or string Change the HSB values, like rgb can be a string or an array. Ranges are: 0-360, 0-100, 0-100
hex string Hexadecimal color notation: #CWWW, #RRGGBB, #RRGGBBWW or #RRGGBBCWWW (with or without the starting #)
color string Can be red, green, blue, orange, lightgreen, lightblue, amber, cyan, purple, yellow, pink, white, or +/- to switch to next/previous color

Input (object mode)

The same values of the topic-mode can be used all togheter in a single js object. To issue multiple commands at the same time just send a msg.payload without any topic like: {'on': true, 'bright': 25, 'color': 'red'} and so on, the same rules of the topic mode apply.

Input aliases

To provide a bit of compatibility with other famous nodes (like node-red-contrib-huemagic) a set of aliases is provided for the commands. Aliases can be used in both topic-mode and object-mode:

Command Aliases
on state, power
bright brightness, dimmer
ct colorTemp
hsb hsbColor
rgb rgbColor
hex hexColor

Node output(s)

The light node output can be configured to suite your need, there are two main modes:

  • Single output mode. In this mode the node will have a single output and will send a js object with the following msg.paylod properties:
Property Type information
on boolean true or false
bright int Brightness, range from 0 to 100
ct int Color temperature, can be configured to send values in Kelvin, Mired or percent
color Any Light colors, can be configured to be RGB [0-255,0-255,0-255], HSB [0-360,0-100,0-100], or Channels [0-100, 0-100, 0-100]
  • Otherwise you can configure the node to have from 2 to 4 outputs, providing a single value of the table above on each separate output. First output for on, second for bright, third for ct and fourth for color.

Tasmota Generic node

This is a generic Tasmota node, can send and receive any command/message to/from any Tasmota device.

With this node you can issue any command as you can do in the Tasmota console. Any received messages will be forwarded to the node output, with the topic and the payload untouched.

To issue a command just send a msg to the node using one of following syntaxes:

  1. string payload: CMD <param>
  2. JSON list payload: ["CMD <param>", "CMD <param>", ...]
  3. JSON object payload: {"CMD": "param", "CMD": "param", ...}

CMD can be any valid tasmota command and param is specific for each command. Refer to the official Tasmota documentation for the full commands reference.

Note that the object format does not guarantee the order of delivered messagges, thus if commands order is important you must use the list format.

Send custom Tasmota commands

All the nodes support an additional mode where you can send any Tasmota command or a list of commands to the device. This can be used for example to change device configuration or to send specific commands not supported by the node itself.

The payload format is the same as explained in the Generic node above, the only difference is that the message topic must be set to command and the commands result is not catched (If you need the command results you must use the Generic node).

Example:

To send the command BlinkCount 12 to a tasmota switch device, create a tasmota-swich node and set the device id(topic) to the correct value for your device. Then add an inject node and connect it. In the Inject node settings, set the topic to command. Set the payload type to string and the payload to BlinkCount 3.

To send a list of commands set the payload type to JSON. An example of a command list syntax is: ["BlinkCount 12", "BlinkTime 3", "Power blink"]

Authors

@DaveMDS

@josephdouce

Initially forked from contrib-sonoff-tasmota

changelog

v1.0.0 (2024-01-04)

Finally switch to version 1, not going to break until 2.x

Bug Fixes

  • Fix usage of Qos and Retain advanced options

v0.9.13 (2023-11-04)

Features

  • Switch/Button: new option to don't set the topic on output messages
  • NodeRed 3.1.0 compatibility: async JSONata usage to silence NodeRED errors
  • More documentation for the basic nodes configuration
  • Switch: support up to 48 channels
  • Show output names when multiple channels selected
  • Upgraded mqtt dependency to 4.3.7

v0.9.12 (2022-02-06)

Bug Fixes

  • Light: don't let other nodes in the flow modify our internal cache object

v0.9.11 (2021-11-14)

Bug Fixes

  • Fix sending commands with empty values, introduced in 0.9.10 :(

v0.9.10 (2021-11-14)

Bug Fixes

  • Fix sending numbers as Cmd payload
  • Raised MQTT.js version to 4.2.8 (as NodeRed itself)

v0.9.9 (2021-04-06)

This is fast-fix release! Try to prevent any bad error while upgrading from the old mqtt-broker to the new one. Sorry for any inconvenience, but the changes was necessary, marching fast to a stable 1.0 release.

v0.9.8 (2021-04-06)

!!! WARNING !!! With this release you need to setup again the mqtt-broker node for all your deployed nodes. As we do not use anymore the mqtt-broker-node included in NodeRed.

Features

  • A new custom mqtt broker node, no more use the standard one
  • A new Generic Node that can send and receive any command/response
  • Sensor: Add ability to choose a fixed output topic
  • Add qos and retain options, for ALL published messages
  • Button: support for 48 channels devices

Bug Fixes

  • Light: Fix setting color and dim with the same msg
  • Broker: Fixed the wrong ClientID usage (was be prefixed by "Tasmota_")

v0.9.7 (2020-11-08)

Features

  • Button: support for new Tasmota message format (fw >= 9.1.0)

v0.9.6 (2020-10-17)

!!! WARNING !!! The outpuf format of the Light node is changed in this release, to make it simpler, more consistent and more configurable. Sorry for the inconvenience.

Features

  • Light: input commands can be passed by topic or by a js object
  • Light: light color can be changed in RGB, HSB, HEX or Color
  • Light: output now always include all the relevant info, not only che changed one
  • Light: output can be a single js object or up to 4 different output for status, ct, bright and color
  • Light: output temps can be configured to be in Kelvin, Mired or percent
  • Light: output color can be configured to be in HSB, RGB or Channels
  • Light: better status label, now also include bright and ct
  • Light: more command aliases for better compatibility with other nodes
  • Light: all input commands are now not case sensitive
  • Light: better documentation

v0.9.5 (2020-10-11)

Features

  • Added the new Button node

v0.9.4 (2020-05-04)

Features

  • Implemented a custom mqtt client, the node-red one is not for public usage
  • Shortened palette labels to be consistent with other nodes
  • New icons for all different nodes
  • Switch and Light: always accept 'on' and 'off' (not case sensitive)
  • New raw/custom tasmota command can be sent using the 'command' topic (all nodes)
  • standardjs

Bug Fixes

  • Fixed node status label in case of errors, fix issue #4
  • Removed on/off/toggle config from Switch and Light (Tasmota does not support this)

v0.9.3 (2020-03-24)

Features

  • Add Light node, by josephdouce

v0.9.2 (2020-01-07)

Bug Fixes

  • Fix wildcard subscription for multi channels switch devices

v0.9.1 (2019-12-22)

Features

  • Add custom full topic support
  • Multiple outputs ability for the Sensor node

Bug Fixes

  • Minor bugs fixed

v0.9.0 (2019-12-08)

  • First public release