Using a SONOFF TH10 sensor

The example supplied controls the switch of a Sonoff device, moreover reads the temperature and humidity values returned by the sensors and shows them on the UIs 


Classic UI or mobile App
Basic UI

Once defined, the items are part of the OpenHAB environment and can be used as shown in a single panel or integrated in a more complex dashboard that collects the values from other sensors, with different technologies.

SONOFF devices integration

Some examples about different Sonoff devices installation in OpenHAB

To interface a Sonoff device with applications other than the original app, requires flashing a new firmware on the board and an MQTT broker. The firmware, valid for all the Sonoff family, is available on Github. An installation tutorial is available on Youtube.

  • Install MQTT broker.
  • Setup the client for connection to CM3-Home MQTT broker using the web configuration page of Sonoff-Tasmota:
  • Configure MQTT binding.
  • Link the MQTT topics to OpenHAB items:


Switch Sonoff1 "Sonoff SW"  (sonoff) {mqtt=">[broker1:cmnd/TH10_sensor/POWER:command:*:default],<[localbroker:stat/TH10_sensor/POWER:state:default]"}
Number Sonoff1Temp "Temp. North [%.1f °C]"  (sonoff) {mqtt="<[broker1:tele/TH10_sensor/SENSOR:state:JSONPATH($.SI7021.Temperature)]"}
Number Sonoff1Hum "Humidity North [%.1f %%]"  (sonoff) {mqtt="<[broker1:tele/TH10_sensor/SENSOR:state:JSONPATH($.SI7021.Humidity)]"}

Using either out (>) and in (<) configuration, enables the reading of the Sonoff device switch status, in order to update the OpenHAB UIs even if the power is driven by the device physical button.

The Sonoff TH10/16 device is available also with temperature and humidity sensors. Subscribing also the tele/# topic those values can be used in OpenHAB.

To use the switch with Basic or Classic UI configure sitemap:


Frame label="Sonoff"
    	Text label="Sonoff" icon=switch
    		Switch item=Sonoff1
    		Text item=Sonoff1Temp valuecolor=[>25="red",>20="green",<=20="blue"] 
Text item=Sonoff1Hum valuecolor=[>60="blue",>40="green",<=40="orange"]
} }