Posted

Introduction

Investigating the integration of Zigbee-based thermostatic valves with Domoticz, enabled by Zigbee2Tasmota, reveals a practical method for home automation. Although the task may appear complex, the logical progression of information renders it a feasible undertaking.

Note: The specific devices used in this setup are Tuya Zigbee-based thermostatic valves, compatible with various smart home systems.

Tuya Cloud vs. Standalone Systems: Privacy and Control

Utilizing Tuya devices with their native cloud services provides convenience, yet it also entails transmitting and storing your usage data on Tuya's cloud servers. This scenario might lead to concerns regarding privacy and data security. By integrating these devices with a standalone system like Domoticz via Zigbee2Tasmota, you gain greater control over your data. This approach keeps your usage information within your private network, enhancing security and ensuring that your smart home remains just that – smart and private. Additionally, a standalone system often provides more customization and flexibility, allowing you to tailor the setup to your specific needs without being tied to a cloud provider's limitations or policies.

Alternative Setup: Zigbee2MQTT and MQTT Auto Discovery

An alternative and often simpler setup involves using Zigbee2MQTT with MQTT Auto Discovery Client Gateway. This method is typically more straightforward and user-friendly, as it leverages the MQTT protocol for easy device discovery and integration. In this particular scenario, the choice of Zigbee2Tasmota was dictated by the limitations of the network environment. The use of a small Raspberry Pi, which cannot accommodate an additional Zigbee2MQTT USB device, necessitated a more customized solution like Zigbee2Tasmota to effectively integrate the Zigbee-based thermostatic valves with Domoticz.

A Technical Overview of Zigbee2Tasmota

Zigbee2Tasmota started as a solution to bridge Zigbee devices with Tasmota firmware, addressing a need in the smart home ecosystem for a comprehensive and flexible interface. The project has expanded via contributions from an international community of developers. Although the possibilities are limited, it provides a good alternative to a Zigbee2MQTT bridge for a constrained, existing setup.

Understanding Zigbee-Based Thermostatic Valves (Enhanced Heating Control)

Zigbee-based thermostatic valves, particularly those from Tuya, represent a very welcomed equipment for the hobbyist and not only :

  • Zigbee Connectivity: Seamlessly integrates with smart home networks, providing reliable and efficient communication.
  • Adjustable Temperature Settings: Enables precise control over room temperatures, enhancing comfort and efficiency.
  • Energy Efficiency: These valves are designed to optimize heating, leading to notable energy savings and eco-friendliness.
  • Price: They are quite affordable, comparable now to the mechanical valves.

Zigbee2Tasmota: Bridging Technologies

Zigbee2Tasmota acts as a valuable connector within the smart home network, guaranteeing compatibility and communication between Zigbee devices and Tasmota-enabled controllers:

  • Versatile Compatibility: Supports a wide array of Zigbee devices, making it a versatile tool in smart home setups.
  • Customization Options: Offers extensive customization possibilities to cater to specific user needs and preferences.
  • Monitoring Capabilities: Provides real-time monitoring, essential for maintaining optimal performance of smart devices.

Integrating the Thermostatic Valve with Zigbee2Tasmota

Rebuild zigbee2tasmota

We are going to use Berry scripting support for tasmota. The bridge I received has firmware build time 2023-07, but certain zigbee related functionality was missing, so I decided to rebuild latest tasmota. See [here] (https://www.blackwire.ro/articles/rebuilding-tasmota-with-zigbee-support) how to rebuild tasmota for zigbee2mqtt.

Thermostatic valve

The exact one purchased was this one This model includes a dial, allowing for effortless manual adjustment of the temperature, similar to a mechanical thermostat. Additionally, there are other versions available that support touch controls, but the dial is more practical.

Steps

  1. Setting Up Zigbee2Tasmota:

Confirm that the Zigbee2Tasmota bridge is correctly configured and connected.

  1. Pairing the thermostatic valve:

Initiate and complete the pairing process between the valve and Zigbee2Tasmota.

  • Put the tasmota bridge in pairing mode
  • Set device 'OFF', then press the dial bottom for 5 seconds.
  • Wait for the device to be recognized
  • Write down the ID of the new device (e.g. 0x927f)

Note: 0x927f is the ID specific to this tutorial, replace it wherever encountered with the ID found in your setup.

  1. Device Recognition:

Verify the valve's recognition in the Zigbee2Tasmota interface. Open the console window and look for something similar to:

14:46:52.769 MQT: tele/tasmota_C2A2F4/SENSOR = {"ZbReceived":{"0x927F":{"Device":"0x927F","ModelId":"TS0601","Manufacturer":"_TZE200_p3dbf6qs","ZCLVersion":3,"AppVersion":67,"PowerSource":3,"0000/FFFE":0,"Endpoint":1,"LinkQuality":87}}}

Alternatively, issue zbInfo 0x927f command in the console and check out the output for the device ID.

We will need following information for writing a small plugin:

"Device":"0x927F","ModelId":"TS0601","Manufacturer":"_TZE200_p3dbf6qs"

  1. Configuration
  • Assign a unique identifier to the valve for easy management, e.g.:

    ZbName 0x927f, "Dorm3_tstat"
  • Create a thermostat.zb file, containing:

    #Z2Tv1
    ## Tuya thermostatic radiator valve
    :TS0601,_TZE200_p3dbf6qs
    EF00/0204=0201/0012,mul:10 ## OccupiedHeatingSetpoint
    EF00/0205=0201/0000,mul:10 ## LocalTemperature
  • Tasmota Zigbee Configuration Explained

    • The configuration lines below are part of Tasmota's setup for handling Zigbee messages, specifically for devices using the EF00 cluster:

      • OccupiedHeatingSetpoint Configuration

        EF00/0204=0201/0012,mul:10 ## OccupiedHeatingSetpoint
        • EF00 - Tuya specific
        • 0204 - Heating setpoint attribute, device specific. If unsure, use the thermostat dial and watch the zigbee2tasmota console output for the proper value
        • =0201/0012 - Maps to the Thermostat cluster (0201) and the OccupiedHeatingSetpoint attribute (0012).
        • ,mul:10 - The value being read is multiplied by 10 (the plugin will convert to float and divide it by 10 when reporting, inverted logic).
      • LocalTemperature Configuration

        EF00/0205=0201/0000,mul:10 ## LocalTemperature
        • EF00 - Tuya specific
        • 0205 - Local temperature attribute, device specific.
        • =0201/00000 - Maps to the Thermostat cluster (0201) and the LocalTemperature attribute (0000).
        • ,mul:10 - The value being read is multiplied by 10
      • See Tasmota Zigbee Reference for details about configuration mappings.

  • Upload the file to the tasmota2mqtt file system, and then reset device (it will be automatically reloaded on startup) or issue the command:

    zbload thermostat.zb

After a while, you should see more meaningful information in the Tasmota interface:

thermostatic_valve

  • Ensure that SetPoint can be modified manually (using e.g. mosquitto_pub) - C2A2F4 is the zigbee2tasmota device address in my own setup.
    mosquitto_pub -h 10.8.3.10 -p 1883 -t cmnd/tasmota_C2A2F4/zbsend -m "{\"Device\": \"0x927F\", \"Write\": {\"EF00/0204\": 320}}"

Linking Zigbee2Tasmota with Domoticz

  • MQTT bridge must be already running in Domoticz, while zigbee2tasmota is also configured to use the same MQTT server.
  • With the valve integrated into Zigbee2Tasmota, it's ready to be incorporated into the Domoticz platform.
  • Create two virtual devices and note down the IDs (e.g. 404 and 405):
    • Temperature sensor
    • Temperature setpoint

Domoticz Sensor

  • There is no suitable Domoticz plugin that I know of, but there are several ways to to retrieve LocalTemperature and OccupiedHeatingSetpoint, and to set OccupiedHeatingSetpoint. The general problem we are trying to solve is the loop that is created between Tasmota and Domoticz, as for each setpoint command there will be a response. We cannot ignore that response, because we should be able to also reflect manual modifications of the setpoint in Domoticz. Here are the alternatives:
    • Use NodeRed to create a bridge between Domoticz and Tasmota. While this is quite a solid approach, it also means significant additional overhead on the server running Domoticz.
    • Use Tasmota rules. The disadvantage is that the scripting only allows for 2x16 internal variables, and I already have them used by temperature sensors. Also, each device addition would mean some cryptic command line setup.
    • Use Berry script interface. This is relatively new in Tasmota, but it proves to be quite powerful, and can help made things generic. It can also be extended in the future to handle other devices as well.

Configuring a Berry driver on Tasmota

  • Download and then upload "zigbeemqtt.be" to the filesystem from https://github.com/cpetra/smartHome or directly from here

  • Create a domoticz_config.txt file in Tasmota's rootfs, similar to this one:

    405, 0x927f, OccupiedHeatingSetpoint, EF00/0204
    404, 0x927f, LocalTemperature 

    This is a .csv format, where:

    • The first column is the domoticz id for the corresponding sensor
    • The second column is the thermostat ID
    • The third column is the endpoint type
    • Only for Setpoint type, we need to configure the endpoint ID (ToDo - check if this can be made transparent)
  • Issue the following command:

    load("/zigbeemqtt.be")
  • Following this, we will be able to control the thermostatic valve through Domoticz

  • More thermostats can be added in the same way, the only thing that changes is "domoticz_config.txt"

  • To load the script at startup, create or modify "autoexec.be" in the root folder, containing:

    load("/zigbeemqtt.be")

    Note: The "/" is optional.

  • ToDo

    • Add support for temperature/humidity sensors.
    • Add thermostat position if possible

Troubleshooting and Practical Tips

  • Device Pairing Issues: Should the initial pairing fail, a reset followed by a second attempt might rectify the problem..
  • Network Stability: Ensure a robust network connection for uninterrupted smart device operation.
  • Regular Firmware Updates: Keep Zigbee2Tasmota and Domoticz updated to maintain compatibility and access new features.

Conclusion

Effectively integrating Zigbee-based thermostatic valves with Domoticz via Zigbee2Tasmota marks an important advancement in improving your home's heating efficiency using affordable (yet reliable) smart devices. The only thing that remains is to create suitable Domoticz scripts to control these devices.

Additional Resources for Further Exploration

Author

Posted

Purpose

The default build does not work correctly with MQTT data in Berry scripts (slightly older 2023-07).

Preconditions

Make sure you have platformio installed.

Clone tasmota directory

git clone git@github.com:arendst/Tasmota.git
cd tasmota

Configure build

Follow the build instructions Instructions - change user_config_override.h and platformio_override.ini

Add to user_config_override.h

  #define USE_BERRY_DEBUG
  #undef USE_DOMOTICZ      // Suspecting  the messages from "domoticz/out" are not relayed to the Berry script engine. 

Replace in platformio_override.ini:

extends                 = env:tasmota32

with

extends                 = env:tasmota32_base

Build

Execute:

platformio run -e tasmota32-EWELINK

The result should be available in build_output/firmware/tasmota32-EWELINK.bin

Author