[SOLVED] SONOFF TH how to make the relay switch ON and OFF

I am trying to make the sonoff change state depending on the temperature, something very simple I presume… not for me it isnt.

This is my item

Number Temp1 "Temperature Garage [%.1f °C]" <temperature> { mqtt="<[broker:tele/sonoff-28/SENSOR:state:JSONPATH($.AM2301.Temperature)]" }

This is my rule

rule "Temperature Garage"
    Item Temp1 changed
 if (Temp1.state < 22) {
 if (Temp1.state >= 22) {


I know the rule is working because the LED in the rule which is connected to a GPIO pin is toggling.

Just one other slight issue, it only seems to get the temperature every 5 minutes, is there am way i can get updates more often


Hi @utronix,

You have to configure a second Item for the mqtt power topic of the th.
Your current item only provides the temperature value of the connected sensor.

Switch Sonoff_Garage "Sonoff TH - Garage Relais" { mqtt=

I didn’t work with sonoff sensors yet, but it seems that your firmware is pushing those updates in a 5min intervall, so maybe there is a corresponding setting in the firmware you are using.

You are sending the ON and OFF commands to an item that is:

  1. Of type Number (where ON/OFF have no meaning)
  2. Not defined with an outbound binding (only inbound for the temperature updates)

I am not sure what firmware you have loaded, and how you have configured the Sonoff, but for this to work you need an item of type Switch that has an outbound binding to the correct MQTT topic.

The mqqt topics, look like he has used Tasmota.
The sonoff devices that i am using with Tasmota have a similar binding structure.

I have looked at my sonoff config and it seems you can’t configure the updating interval for sensors on the webinterface.
(But maybe it only doesnt work with the Basic Model that i have choosen in my configuration.)

After hitting “Enter” on the topic, I realised that I needed to configure the MQTT which I have now done, and can send sendCommond(ON) successfully (even though it is defined as a number). Yes its Tasmota, I will have a search around in the code to see if i can find an update setting.


TelePeriod		Show current telemetry period in seconds
TelePeriod	0 / off	Disable telemetry messages
TelePeriod	1	Reset telemetry period to user_config.h (TELE_PERIOD)
TelePeriod	<secs>	Set telemetry period between 10 and 3600 seconds

Tasmota commands

Yes, I tried setting it to 10 seconds but nothing changed

keep the tasmota web console open, to see the MQTT messages it produces and how frequent.