Getting started with Tasmota devices on ThingsLog platform

Introduction

Tasmota is a very promising open-source firmware project for EST-based chipsets. ESP supports arduino and is one of the most popular Arduino chipset manufacturers with built-in wifi network support. Getting started with Tasmota devices and how to integrate them with ThingsLog.

More about Tasmota can be found on their own community based portal.

There is also another ESP32 project called Tuya. Tasmota is a free open-source alternative to Tuya. The important bit to be mentioned here is that there are really a lot of hardware devices based on ESP32 and Tuya, and pretty much all of them could be flashed with Tasmota firmware with the right device template.

Those devices range from smart plugs to smart bulbs, smart rely, controllers, valves, fuses, and many other sensors and other “smart” devices.

More about Tasmota’s currently supported devices and what is a device template could be learned here.

ThingsLog aims to support open firmware

In ThingsLog, no matter how hard we try, we never will be able to design, build, and program as many devices as the Tasmota or Tuya and, generally, the ESP32 and Arduino communities. ESP-based devices are not low-power, they don’t support mobile networks well, or, let’s say, if they do, the way they work is not comparable to ThingsLog LPMDL data loggers.

At the same time, ESP32 is wonderful for home, semi-professional, and even professional purposes if there is a WIFI network around.

TingsLog’s goal is to support that project, integrate it with our platform, and help our customers add such devices to their ThingsLog platform accounts

Below is an example of getting started with Tasmota and how to add Tasmota smart plugs/relays to your ThingsLog account.

Setting up a Tasmota device

The example below will be demonstrated with a Tasmota smart plug.

Read the manual of your smart Tasmota device

Typically Tasmota devices come with a short manual or getting started guide. If not, check the Tasmota currently supported devices or vendor web page.

Connect the Tasmota device to your wifi network

  1. When the Tasmota device initially starts typically it will annonce its own WiFi Access point network.
  2. Connect to that AP. In many cases, it is named “Tasmota-XXXXXX-YYYY”. Connect to it and open in the browser 192.168.4.1 to access the web interface and set up the connection to a local WIFi network.

Note: The address might differ between different Tasmota devices and firmware builds but the principle is the same. You have to connect to the first IP of the network from which you got and address.

  1. Set the Tasmota device to connect to your own network in the Tasmota web interface
Tasmota setting wifi

Tasmota successful connection to wifi

  1. Connect the Tasmota device to the newly provided IP address from your own network.

If the procedure does not work or you make a mistake with your password you will have to perform a hard reset of the device.

Hard reset: Hold the power button for about 30 seconds. After the LED button is turned on, release it. Typically, the LED light of the device will start flashing.

Now, the device has been reset and the above configuration procedure could be repeated.

Enable MQTT telemetry

From “Main menu > Configuration > Configure Other” it needs to check “MQTT enable”

From “Main menu > Configuration > Configure MQTT

Tasmota setting MQTT parameters

  • Host – mqtt broker address – x.thingslog.com
  • Port – mqtt broker port
  • Client – device number (device name). ‘%08X’ uses the last eight digits from mac address as the device number.
  • ‘User’ and ‘Password’ – credentials for MQTT broker.
    • Note: You will have to ask ThingsLog support for an account for the ThingsLog MQTT platform broker.
  • Topic – the main topic for the current device. Need to be unique. ThingsLog platform expects the main topic to be set to thingslog/%08X
  • Full topic – full topic definition – set it as in the example above.

Note: %08X is the device number you will have to use for creating your Tasmota device on the ThingsLog platform

To verify the connection status go to Main Menu/Console and you should see something like the output below:

Tasmota console output

Setting up Thingslog for getting telemetry data from a Tasmota device

Add the Tasmota device to ThingsLog Platform

In the ThingsLog platform from the Inventory, page has to be created a new “TASMOTA” device.

Add device to ThingsLog platform

Adding telemetry sensors to your Tasmota device

Once created from the “Sensor parameters” page for the device there have to be added sensors that match the data coming from the Tasmota device.

Once selected the following dialog has to be populated.

  • Sensor index – ThingsLog platform will suggest
  • Port type – depending on your Tasmota device port type.
  • Sensor type – platform will be suggested based on the selected port type.
  • Sensor name – whatever your sensor is.

Note: Digital sensors are “counters” with increasing values. For digital sensors, you also have to set-up other parameters such as K factor, flow rate, units, and others.

Note: Analog sensors are “gauge” sensors where values can go up and down. For analog sensors, you may also have to set other parameters such as conversion formulas, units, and others.

The exact number of sensors and their type depends on the Tasmota device. The principle that ThingsLog is using is to match certain parameters from Tasmota MQTT messages to parameters in the ThingsLog sensor config.

Matching Tasmota telemetry data to the sensors in ThingsLog

Here are some example MQTT messages from two different smart plugs with Tasmota. That output could be monitored directly in the Tasmota device web console.

The device number in this example is A314BDCF.

04:55:45.152 MQT: tele/thingslog/A314BDCF/SENSOR = {“Time”:”2024-12-07T04:55:45″,”ANALOG”:{“Temperature”:28.4},”ENERGY”:{“TotalStartTime”:”2024-12-07T04:42:38″,”Total”:0.000,”Yesterday”:0.000,”Today”:0.000,”Period”:0,”Power”:0,”ApparentPower”:0,”ReactivePower”:0,”Factor”:0.00,”Voltage”:0,”Current”:0.000},”TempUnit”:”C”}

In the JSON payload, sensor group names (e.g., ENERGY, ANALOG) are found in the main object, while the sensor data is located in a nested object for example “Temperature”:28.4.

To extract readings from the MQTT payload, in the ThingsLog platform sensor configuration has to be defined two additional parameters: dataGroup (in our case this is ENERGY or ANALOG) and sensorType (in our Case this is “Temperature” for group ANALOG and any of “Total”, “Yesterday”, “Today”, “Period”, “Power”, “ApparentPower”, “ReactivePower”, “Factor”, “Voltage”, “Current” for the group “ENERGY”

In the main Tasmota menu there you can check the full list of the telemetry parameters available from your smart plug.

Tasmota parameter statistics

Here is their mapping to ThingsLog port/sensor types and parameters

Sensor nameMeasurement typeThingsLog Port typeThingsLog

Sensor Type

Matching parameters

dataGroup/sensorType

Total power consumption (kWh)Power ConsumptiondigitalTasmota_digital_sensorENERGY / Total
Active power (kW)Active PoweranalogTasmota_analog_sensorENERGY / Power
Voltage (V)VoltageanalogTasmota_analog_sensorENERGY / Voltage
Current (A)CurrentanalogTasmota_analog_sensorENERGY / Current
Temperature (°C) [only for Refoss P11]TemperatureanalogTasmota_analog_sensorANALOG / Temperature
Apparent power (VA)Apparent PoweranalogTasmota_analog_sensorENERGY / ApparentPower
Reactive power (VAr)Reactive PoweranalogTasmota_analog_sensorENERGY / ReactivePower
Power factorPower FactoranalogTasmota_analog_sensorENERGY / Factor
Today’s energy consumption (kWh)Power ConsumptiondigitalTasmota_digital_sensorENERGY / Today
Yesterday’s energy consumption (kWh)Power ConsumptiondigitalTasmota_digital_sensorENERGY / Yesterday

The approach could be used for modeling almost any sensor for which a Tasmota device is sending data.

Note that by default Tasmota devices are sending telemetry data every 5 minutes.

Tasmota console output

Setting ThingsLog for managing Tasmota relays

How does a Tasmota device work with relays

As you may notice in the Tasmota main menu if there are relay ports on your Tasmota device you will see the status of the relay port and a big “Toggle” button under it. If there are more relay ports you will see a list of them.

If you press the button and navigate to the console you will notice something like this.

The same would happen if you play directly in the console with the Tasmota power command.

Basically what we see is the output of the Tasmota “power” command. If the device has more relays it will have indexes like Power 1, 2, 3, etc. If you execute just the power command that would mean switching on/off all the relays at the same time.

Note: that if you have one relay on your Tasmota device it has index 1 and can be switched on/off with the POWER 1 command. If you execute the POWER command it will switch on/off/toggle all your relay ports simultaneously.

Adding Tasmota relay ports to ThingsLog

To add a relay port on your Tasmota device simply add a new on/off output port with sensor type “Tasmota Relay Sensor”

Then in the configuration of the sensor in the power parameter you will have to match the Power index of the Tasmota actual relay port.

Note: 0 in power parameter would mean a Relay sensor able to execute POWER command without index e.g switching on/off all relay ports on your Tasmota device simultaneously.

Sending Power commands to a Tasmota device from the ThingsLog platform

Currently, there are two ways for sending commands to a Tasmota device from ThingsLog – from the ThingsLog management interface, from the ThingsLog solutions portal, and from the ThingsLog mobile app.

Sending commands from the ThingsLog management interface

For this purpose navigate to the ThingsLog management interface and execute the Tasmota relay switch command.

The relay index has to match the POWER parameter index and the status could be 0 (OFF), 1 (ON), 2 (TOGGLE).

Sending commands from ThingsLog solutions portals

The Tasmota ON/OFF output ports will appear as any other output port of a ThingsLog controller device.

You may switch them on or off as any other relay port.

Tasmota tips and tricks

In that section will be presented some tips and tricks related to Tasmota devices and the way they generate data or execute relay commands.

Setting time zone of your Tasmota device

If you want to get data properly in ThingsLog platform you should set the timezone of your devices. For more reference check here: https://Tasmota.github.io/docs/Timezone-Table/.

For example, for Europe/Sofia you should execute in Console the following command.

17:23:30.866 CMD: Backlog0 Timezone 99; TimeStd 0,0,10,1,4,120; TimeDst 0,0,3,1,3,180

17:23:30.901 MQT: stat/thingslog/6C3AF314/RESULT = {“Timezone”:99}

17:23:31.021 MQT: stat/thingslog/6C3AF314/RESULT = {“TimeStd”:{“Hemisphere”:0,”Week”:0,”Month”:10,”Day”:1,”Hour”:4,”Offset”:120}}

17:23:31.051 MQT: stat/thingslog/6C3AF314/RESULT = {“TimeDst”:{“Hemisphere”:0,”Week”:0,”Month”:3,”Day”:1,”Hour”:3,”Offset”:180}}

Changing the data logging frequency

Data telemetry export could be controlled from the menu, configuration, and logging.

setting tasmota telemetry data push period

Executing commands on a schedule

A good example of such a task is to start lamps at sunset and stop them at sunrise. Tasmota supports timers and you can set them in such a way as to achieve even such tasks.

For this purpose navigate to the Main menu, configuration, and set timer. The menu is a UI of the “timers command https://Tasmota.github.io/docs/Timers/.

setting tasmota timer

Up to 16 timers could be set based on various triggers, the menu allows broad kinds of configurations that trigger the relay ports.

If that is not sufficient you can check what the Tasmota rules do https://Tasmota.github.io/docs/Rules/.

If this is insufficient, well try the Berry scripting language https://Tasmota.github.io/docs/Berry/

Enjoy!

Share:

Facebook
LinkedIn

Related Posts

FrenchBulgaria