diff --git a/Rule-Cookbook.md b/Rule-Cookbook.md
index d07e853b..f6912d62 100644
--- a/Rule-Cookbook.md
+++ b/Rule-Cookbook.md
@@ -8,21 +8,23 @@
- [Setting Variables](#setting-variables)
- [Control device LEDs with Relays](#control-device-leds-with-relays)
- [Thermostat Example](#thermostat-example)
+- [Solar heater control](#solar-heater-control)
+- [Energy Saving Smart Switch](#energy-saving-smart-switch)
- [Staircase Timer](#staircase-timer)
- [Advanced PIR rules for Staircase](#advanced-pir-rules-for-staircase)
-- [Energy Saving Smart Switch](#energy-saving-smart-switch)
- [Controlling Timers Enabled from a switch](#controlling-timers-enable-from-a-switch)
- [Toggle a Relay only when holding the button for 2 seconds](#toggle-a-relay-only-when-holding-the-button-for-2-seconds)
-- [Make sure light is on at night](#rule-to-make-sure-light-is-on-at-night)
-- [Enable a PIR Switch only at night](#rule-to-enable-a-pir-switch-only-at-night)
- - [PIR Config](#Wemos-D1-Mini-and-HC-SR501-PIR-Motion-Sensor#alternative-tasmota-configuration-with-rules-recommended-method)
+- Using Sunrise and Sunset
+ - [Make sure light is on at night](#make-sure-light-is-on-at-night)
+ - [Enable a PIR Switch only at night](#enable-a-pir-switch-only-at-night)
+ - [PIR Configuration](Wemos-D1-Mini-and-HC-SR501-PIR-Motion-Sensor#alternative-tasmota-configuration-with-rules-recommended-method)
+ - [Using clock timer to control a luminance-triggered switch only in mornings](#using-clock-timer-to-control-a-luminance-triggered-switch-only-in-mornings)
- [Using an external button with single press - double press and hold](#using-an-external-button-with-single-press---double-press-and-hold)
-- [Enable or disable doorbell relay with HTTP call](#rule-to-enable-or-disable-doorbell-relay-with-http-call)
-- [Force automatic reconnection to MQTT server via SD DNS](#rule-to-force-automatic-reconnection-to-mqtt-server-via-sd-dns)
-- [Change distance to percentage](#rule-to-change-distance-to-percentage)
-- [Rules to distinguish Switch1 and Switch2 without the use of Relay1 and Relay2](#rules-to-distinguish-switch1-and-switch2-without-the-use-of-relay1-and-relay2)
-- [Rule for receiving state of intercom doorbell (or anything that triggers your SWITCHX more than one times).](#rule-for-receiving-state-of-intercom-doorbell-or-anything-that-triggers-your-switchx-more-than-one-times)
-- [Invoking rules using clock timer to control a luminance-triggered switch only in mornings](#invoking-rules-using-clock-timer-to-control-a-luminance-triggered-switch-only-in-mornings)
+- [Enable or disable doorbell relay with HTTP call](#enable-or-disable-doorbell-relay-with-http-call)
+- [Force automatic reconnection to MQTT server via SD DNS](#force-automatic-reconnection-to-mqtt-server-via-sd-dns)
+- [Change distance to percentage](#change-distance-to-percentage)
+- [Distinguish Switch1 and Switch2 without the use of Relay1 and Relay2](#distinguish-switch1-and-switch2-without-the-use-of-relay1-and-relay2)
+- [Receiving state of anything that triggers SWITCH more than one time](#receiving-state-of-anything-that-triggers-switch-more-than-one-time)
- [Prevent Wemos D1 mini load overcurrent](#prevent-wemos-d1-mini-load-overcurrent)
- [Using dummy relays to send Serial codes to the MCU](#Using-dummy-relays-to-send-Serial-codes-to-the-MCU)
- [Arithmetic Commands to be used with VARs](#arithmetic-commands-to-be-used-with-vars)
@@ -31,7 +33,6 @@
- [Switch relays via serial interface](#Switch-relays-via-serial-interface)
- [Using BREAK to simulate IF..ELSEIF..ELSE..ENDIF](#Using-BREAK-to-simulate-IFELSEIFELSEENDIF)
- [Adjust PowerDelta according to current Power values](#adjust-powerdelta-according-to-current-power-values)
-- [Solar heater control](#solar-heater-control)
- [IR Forward](#ir-forward)
- [Garage Door Opener](#Garage-Door-Opener)
- [Remote Control Button Multi-press](#Remote-Control-Button-Multi-press)
@@ -43,11 +44,11 @@
Activate long press action with `Switchmode 5` and shorten long press time to 2 seconds (`Setoption32 20`).
-Long pressing on switch1 sends `POWER 2` (toggle action) command to the `sonoff02` device
+Long pressing on switch1 sends `POWER 2` (toggle action) command to the `tasmota02` device
```
SwitchMode 5
SetOption32 20
-Rule on switch1#state=3 do cmnd/sonoff02/POWER 2 endon
+Rule on switch1#state=3 do cmnd/tasmota02/POWER 2 endon
Rule 1
```
Notice we use `Rule` which edits `Rule1` rule set. They can be used interchangeably.
@@ -68,7 +69,7 @@ Hardware
- Sonoff 4CH
Software
-- Sonoff-Tasmota with define USE_RULES enabled
+- Tasmota with USE_RULES enabled
- Disable ButtonTopic as it overrides rules for buttons: `ButtonTopic 0`
Rule
@@ -92,7 +93,7 @@ Hardware
- Sonoff 4CH
Software
-- Sonoff-Tasmota with define USE_RULES enabled
+- Tasmota with USE_RULES enabled
- Configure timer5 for rule execution when activated: `timer5 {"Arm":1,"Mode":0,"Time":"16:00","Days":"1111111","Repeat":1,"Action":3}`
Rule
@@ -135,7 +136,7 @@ Hardware
- AM2301 Temperature and Humidity sensor
Software
-- Sonoff-Tasmota with define USE_RULES enabled
+- Tasmota with USE_RULES enabled
- Home Automation tool Domoticz configured with a virtual sensor Temp+Hum using Idx 134
Rule
@@ -160,7 +161,7 @@ Hardware
- WS2812 LED
Software
-- Sonoff-Tasmota with define USE_RULES enabled
+- Tasmota with USE_RULES enabled
Rule
- `on analog#a0div10 do dimmer %value% endon`
@@ -230,7 +231,7 @@ mqtt: `cmnd/[topic]/event anyname=number`
Everything together:
-`Rule on event#togglevar1 do event toggling1=%var1% endon on event#toggling1<1 do event setvar1=1 endon on event#toggling1>0 do event setvar1=0 endon on event#setvar1 do var1 %value% endon on event#getvar1 do var1 endon on event#message do publish stat/sonoff/log %value% endon`
+`Rule on event#togglevar1 do event toggling1=%var1% endon on event#toggling1<1 do event setvar1=1 endon on event#toggling1>0 do event setvar1=0 endon on event#setvar1 do var1 %value% endon on event#getvar1 do var1 endon on event#message do publish stat/mqttTopic/log %value% endon`
**NOTE**
@@ -286,10 +287,10 @@ Initial config on console:
* `SetOption26 1` <- use power1 on mqtt messages
* `SetOption0 0` <- dont save relay status on eeprom
* `poweronstate 0` <- start all relays off
-* `mem1 0` <- thermostat status: 0-off 1-enabled - View or set by MQTT cmnd/sonoff/mem1
-* `mem2 25` <- setpoint Temp upper limit - View or set by MQTT cmnd/sonoff/mem2
-* `mem3 23` <- setpoint Temp lower limit - View or set by MQTT cmnd/sonoff/mem3
-* `var1 0 ` <- thermostat actual status: 1-OK 0-NOT READY - View by MQTT cmnd/sonoff/var1
+* `mem1 0` <- thermostat status: 0-off 1-enabled - View or set by MQTT cmnd/mqttTopic/mem1
+* `mem2 25` <- setpoint Temp upper limit - View or set by MQTT cmnd/mqttTopic/mem2
+* `mem3 23` <- setpoint Temp lower limit - View or set by MQTT cmnd/mqttTopic/mem3
+* `var1 0 ` <- thermostat actual status: 1-OK 0-NOT READY - View by MQTT cmnd/mqttTopic/var1
Rules:
@@ -315,22 +316,22 @@ Thermostat can be turned On by:
* pushing button
* by command on local console: mem1 1
-* by command on any other console: publish cmnd/sonoff/mem1 1
-* or MQTT at: cmnd/sonoff/mem1 1
+* by command on any other console: publish cmnd/mqttTopic/mem1 1
+* or MQTT at: cmnd/mqttTopic/mem1 1
Thermostat can be turned Off by:
* pushing button
* by command on local console: mem1 0
-* by command on any other console: publish cmnd/sonoff/mem1 0
-* or MQTT at: cmnd/sonoff/mem1 0
+* by command on any other console: publish cmnd/mqttTopic/mem1 0
+* or MQTT at: cmnd/mqttTopic/mem1 0
To get the status:
-* `mem1` <- thermostat status: 0-off 1-enabled - View or set by MQTT cmnd/sonoff/mem1
-* `mem2` <- setpoint Temp upper limit - View or set by MQTT cmnd/sonoff/mem2
-* `mem3` <- setpoint Temp lower limit - View or set by MQTT cmnd/sonoff/mem3
-* `var1` <- thermostat actual status: 1-OK 0-NOT READY - View by MQTT cmnd/sonoff/var1
+* `mem1` <- thermostat status: 0-off 1-enabled - View or set by MQTT cmnd/mqttTopic/mem1
+* `mem2` <- setpoint Temp upper limit - View or set by MQTT cmnd/mqttTopic/mem2
+* `mem3` <- setpoint Temp lower limit - View or set by MQTT cmnd/mqttTopic/mem3
+* `var1` <- thermostat actual status: 1-OK 0-NOT READY - View by MQTT cmnd/mqttTopic/var1
Everything together:
@@ -364,6 +365,99 @@ TIMERS:
* With the above the timers can be used to control mem1 and add a schedule to when the thermostat will be enabled
`Rule2 on Clock#Timer=1 do mem 1 endon on Clock#Timer=2 do mem 0`
+[Back To Top](#top)
+
+------------------------------------------------------------------------------
+
+#### Solar heater control
+
+In a swimming pool, a filter pump and a solar panel is installed. When the sun is shining, the pump should push water through the solar panel, to heat the pool. When it's night or cloudy, the pump should be off, to avoid cooling the pool water through the solar panel. The pump is controlled by a Sonoff TH10 with 2x DS18B20 sensors connected.
+
+3 rules:
+
+* Pump should start when solar panel is more than 2 deg warmer than the pool water
+* Pump should stop when solar panel is less than 1 deg warmer than the pool water
+* Pump should not start if the solar panel is below 25 deg celsius.
+
+`t1`: pool temp
+
+`t2`: panel temp
+
+`var1`: in valid panel temp range?
+
+`var2`: off threshold temp for panel
+
+`var3`: on threshold temp for panel
+
+`mem3`: lowest valid panel temp
+
+```
+mem3 25
+rule1
+ on DS18B20-1#temperature do
+ event t1=%value%
+ endon
+ on DS18B20-2#temperature do
+ event t2=%value%
+ endon
+ on event#t2>%mem3% do
+ var1 1;
+ endon
+ on event#t2<=%mem3% do
+ var1 0;
+ endon
+ on event#t1 do
+ backlog
+ var2 %value%;
+ add2 1;
+ endon
+ on event#t1 do
+ backlog
+ var3 %value%;
+ add3 2;
+ endon
+ on event#t2>%var3% do
+ power1 %var1%;
+ endon
+ on event#t2<%var2% do
+ power1 0;
+ endon
+rule1 1
+```
+
+To test the rule without having the sensors in place, simply enter the events for `t1` and `t2` in the console:
+
+```
+event t1=21
+event t2=30
+```
+
+And watch the relay turn on and off based on the values.
+
+Please note that this example does not support manual override or handle missing sensor data. Take a look at [Thermostat Example](#thermostat-example) for examples.
+
+[Back To Top](#top)
+
+------------------------------------------------------------------------------
+
+#### Energy Saving Smart Switch
+
+Example of a switch controlling a light with a condition of a required amount of lux.
+
+When the switch is on, the light will turn on but only when you have less than 100 lux in that room. While if the switch is off the light will be off.
+
+```
+on switch1#state=1 do var1 100 endon
+on switch1#state=0 do backlog var1 0; power1 off endon
+on APDS9960#Ambient<%var1% do power1 on endon
+```
+
+_All together to work as a rule:_
+
+```
+Rule 1
+Rule on switch1#state=1 do var1 100 endon on switch1#state=0 do backlog var1 0; power1 off endon on APDS9960#Ambient<%var1% do power1 on endon
+```
[Back To Top](#top)
@@ -447,31 +541,6 @@ The LEDs turn off after the RuleTimer expires
* Rule3 is active on daylight and pipe the PIR signal in a power1 off signal. The LEDs stay off.
-
-[Back To Top](#top)
-
-------------------------------------------------------------------------------
-
-#### Energy Saving Smart Switch
-
-Example of a switch controlling a light with a condition of a required amount of lux.
-
-When the switch is on, the light will turn on but only when you have less than 100 lux in that room. While if the switch is off the light will be off.
-
-```
-on switch1#state=1 do var1 100 endon
-on switch1#state=0 do backlog var1 0; power1 off endon
-on APDS9960#Ambient<%var1% do power1 on endon
-```
-
-_All together to work as a rule:_
-
-```
-Rule 1
-Rule on switch1#state=1 do var1 100 endon on switch1#state=0 do backlog var1 0; power1 off endon on APDS9960#Ambient<%var1% do power1 on endon
-```
-
-
[Back To Top](#top)
------------------------------------------------------------------------------
@@ -538,15 +607,16 @@ Rule 1
------------------------------------------------------------------------------
-#### Rule to Make Sure Light is on at Night
+#### Make Sure Light is on at Night
-Using Timers, you can be set to turn on and off a light for illuminate a street/patio by night. But if the Sonoff Device has no power at the trigger time, then, when it powers up, the light will be off all night. So, as a failsafe, can be implemented a conditional control to be checked at Sonoff Startup with rules.
+Using Timers, you can set a light to turn on and off to illuminate a street/patio by night. But if the device has no power at the trigger time, then, when it powers up, the light will be off all night. So, as a failsafe, implement a conditional control to be checked at Tasmota Startup.
Set Timers to turn on your light at Sunset and Turn off at sunrise.
-Use `poweronstate 0` in order to start with lights off when powering up your Sonoff.
+Use `poweronstate 0` in order to start with lights off when powering up your device.
Set the following rules:
```
+Rule1
on Time#Initialized do backlog event checksunrise=%time%; event checksunset=%time% endon
on event#checksunset>%sunset% do power1 1 endon
on event#checksunrise<%sunrise% do power1 1 endon
@@ -561,7 +631,7 @@ IF %time%>%sunset DO power1 1 / IF %time%<%sunrise DO power1 1
------------------------------------------------------------------------------
-#### Rule to enable a PIR Switch only at night
+#### Enable a PIR Switch only at night
PreInfo:
- PIR HC-SR501
@@ -585,6 +655,57 @@ Rule1 1
------------------------------------------------------------------------------
+#### Using Clock Timer to control a Luminance triggered switch (only in mornings)
+
+**Background:**
+Tasmota powers a Sonoff Basic attached to a TS-2561 Luminance Sensor. This switch toggles a lamp ON or OFF. The switch should work as below:
+i) during daytime (sunrise-sunset): ON when it is too dark (<150 lx) and OFF when it gets brighter (>175 lx).
+ii) during evenings it ignores the sensor and turns on at sunset and turns off after about 5 hours
+
+**Approach:**
+Used a combination of Clock Timers and Rule to do this.
+
+**Timer 1:** Power ON switch at Sunset
+Powers on the switch at sunset with an offset of 20 minutes. Repeats every day.
+
+```
+Timer1 {"Arm":1,"Mode":2,"Time":"-00:20","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":1}
+```
+
+**Timer 2:** Power OFF switch at Night.
+Turns power OFF at 23.00hrs. Repeats every day.
+
+```
+Timer2 {"Arm":1,"Mode":0,"Time":"23:00","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":0}
+```
+
+**Timer 3:** Trigger Luminance Rule at Sunrise
+Start watching the Lux sensor 15 minutes after sunrise.
+
+```
+Timer3 {"Arm":1,"Mode":1,"Time":"00:15","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":3}
+```
+
+**Rule 1:** Main Rule to check Luminance
+If Luminance is less than 150lx, power ON. If it goes beyond 175lx, power OFF.
+
+```
+Rule1 on tele-TSL2561#Illuminance<150 do power1 1 endon on tele-TSL2561#Illuminance>175 do power1 0 endon
+Rule1 1
+```
+
+**Rule 2:** Trigger Rule1 only in the Mornings
+This ensures that Rule1 is triggered when Timer3 starts (in the morning) and stops when Timer1 starts (in the evenings).
+
+```
+Rule2 on Clock#Timer=3 do Rule1 1 endon on Clock#Timer=4 do Rule1 0 endon
+Rule2 1
+```
+
+[Back To Top](#top)
+
+------------------------------------------------------------------------------
+
#### Using an external button with single press - double press and hold
@@ -661,7 +782,7 @@ Rule 1
------------------------------------------------------------------------------
-#### Rule to enable or disable doorbell relay with HTTP call
+#### Enable or disable doorbell relay with HTTP call
When you want to send MQTT messages ( we use domoticz in this example ) and choose when you want the relay (GPIO12) on or off, by simply sending HTTP commands to trigger an event.
@@ -671,8 +792,8 @@ In this example we're using rules.
- PushButton Doorbell
- GPIO14 12 Switch4 (Sonoff Basic)
-Connect the PushButton to GND and GPIO14 on your sonoff basic.
-To be sure put a 4.7k resistor between VCC(3.3v) and GPIO14, this prevents ghost switching (capacitor is optional) See: [YouTube](https://www.youtube.com/watch?v=aq8_os6g13s)
+Connect the PushButton to GND and GPIO14 on your Sonoff Basic.
+Be sure put a 4.7k resistor between VCC(3.3v) and GPIO14. This prevents ghost switching (capacitor is optional) See: [YouTube](https://www.youtube.com/watch?v=aq8_os6g13s)
_Dont forget to change the IDX value_
**Commands:**
@@ -693,7 +814,7 @@ on switch4#state=0 do power1 0 endon
Rule1 1
```
-
**Usage:**
+
**Usage:**
Now you can call the event using HTTP to turn off the relay ( GPIO12 ).
```
@@ -704,8 +825,10 @@ and to turn on the relay ( GPIO12 ) use this one below.
http:///cm?cmnd=event%20doorbell=1
```
-
If your tasmota device is password protected, which is most common then use the following HTTP commands instead.
-Make sure you change tasmotaUsername and tasmotaPassword
+
+If your Tasmota device is password protected, which is most common then use the following HTTP commands instead.
+Make sure you change tasmotaUsername and tasmotaPassword
+
Off:
```
http:///cm?&user=&password=&cmnd=event%20doorbell=0
@@ -719,7 +842,7 @@ http:///cm?&user=&password=&cmnd=ev
------------------------------------------------------------------------------
-#### Rule to force automatic reconnection to MQTT server via SD DNS
+#### Force automatic reconnection to MQTT server via SD DNS
In order to search for the MQTT server using SD-DNS service (a.k.a. Bonjour or Zero Network Configuration) the suggested configuration is to leave the MQTT Host field blank.
@@ -742,7 +865,7 @@ Rule1 on Mqtt#Disconnected do MqttHost 0 endon
If the MqttHost field already contains an IP, you have to delete it using the web interface or the following MQTT command:
```
-mosquitto_pub -h mqtt_server.local -t "cmnd/sonoff-0657/MqttHost" -m ''
+mosquitto_pub -h mqtt_server.local -t "cmnd/mqttTopic/MqttHost" -m ''
```
@@ -750,7 +873,7 @@ mosquitto_pub -h mqtt_server.local -t "cmnd/sonoff-0657/MqttHost" -m ''
------------------------------------------------------------------------------
-#### Rule to change distance to percentage
+#### Change distance to percentage
When measuring distance and you have the need to see it in percentage of distance.
In the example 100% is everything below 69cm and 0% is everything above 128cm.
@@ -769,7 +892,7 @@ on event#pubdata do publish tele/pannrum-temp/SENSOR %var1% endon
------------------------------------------------------------------------------
-#### Rules to distinguish Switch1 and Switch2 (without the use of Relay1 and Relay2)
+#### Distinguish Switch1 and Switch2 (without the use of Relay1 and Relay2)
When two (or more) switches are defined as input and you want to distinguish these in the RESULT topic without the use of Relays, then consider the following rules.
@@ -815,10 +938,9 @@ Output:
------------------------------------------------------------------------------
-#### Rule for receiving state of intercom doorbell (or anything that triggers your SWITCHX more than one times).
+#### Receiving state of anything that triggers SWITCH more than one time
-With analog intercoms you can take out info about ringing from speaker voltage. You can connect GPIO to it via optoisolator and resistor to take out state.
-But even with those speaker voltage is dropping so it switches Sonoff multiple times.
+With analog intercom doorbells you can take out info about ringing from speaker voltage. You can connect GPIO to it via optoisolator and resistor to take out state. But even with those speaker voltage is dropping so it switches the device multiple times.
```
14:03:00 MQT: cmnd/doorbell/POWER2 = OFF (retained)
14:03:01 MQT: cmnd/doorbell/POWER2 = ON (retained)
@@ -853,57 +975,6 @@ In this case we have lock for 60 seconds for multiple people calls or to be resi
[Back To Top](#top)
-------------------------------------------------------------------------------
-
-#### Invoking Rules using Clock Timer to control a Luminance triggered switch (only in mornings)
-
-##### Background:
-Tasmota powers a sonoff basic attached to a TS-2561 Luminance Sensor. This switch toggles a lamp ON or OFF. The switch should work as below:
-i) during daytime (sunrise-sunset): ON when it is too dark (<150 lx) and OFF when it gets brighter (>175 lx).
-ii) during evenings it ignores the sensor and turns on at sunset and turns off after about 5 hours
-
-##### Approach:
-Used a combination of Clock Timers and Rule to do this.
-
-##### Timer 1 : Power ON switch at Sunset
-Powers on the switch at sunset with an offset of 20 minutes. Repeats every day.
-
-```
-Timer1 {"Arm":1,"Mode":2,"Time":"-00:20","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":1}
-```
-
-##### Timer 2: Power OFF switch at Night.
-Turns power OFF at 23.00hrs. Repeats every day.
-
-```
-Timer2 {"Arm":1,"Mode":0,"Time":"23:00","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":0}
-```
-
-##### Timer 3: Trigger Luminance Rule at Sunrise
-Start watching the Lux sensor 15 minutes after sunrise.
-
-```
-Timer3 {"Arm":1,"Mode":1,"Time":"00:15","Window":0,"Days":"1111111","Repeat":1,"Output":1,"Action":3}
-```
-
-##### Rule 1: Main Rule to check Luminance
-If Luminance is less than 150lx, power ON. If it goes beyond 175lx, power OFF.
-
-```
-Rule1 on tele-TSL2561#Illuminance<150 do power1 1 endon on tele-TSL2561#Illuminance>175 do power1 0 endon
-Rule1 1
-```
-
-##### Rule 2: Trigger Rule1 only in the Mornings
-This ensures that Rule1 is triggered when Timer3 starts (in the morning) and stops when Timer1 starts (in the evenings).
-
-```
-Rule2 on Clock#Timer=3 do Rule1 1 endon on Clock#Timer=4 do Rule1 0 endon
-Rule2 1
-```
-
-[Back To Top](#top)
-
------------------------------------------------------------------------------
#### Prevent Wemos D1 mini load overcurrent
As a WS2812 24 led ring draws approximately 24x3x20 mA = 1.44A and the Wemos D1 mini powered from a PC's USB port can only provide up to 0.5A it would be nice to have some kind of mechanism in place to limit the amount of current to the WS2812 LEDring to 0.1A. This is still enough to light all 24 leds up to color 202020.
@@ -914,7 +985,7 @@ Hardware
- WS2812 LEDring with 24 LEDs powered by the Wemos D1 mini 5V thru the INA219 sensor
Software
-- Sonoff-Tasmota with define USE_RULES enabled
+- Tasmota with USE_RULES enabled
Rule
- `on INA219#Current>0.100 do Backlog Dimmer 10;Color 10,0,0 endon`
@@ -992,8 +1063,8 @@ When it is needed that a sensor value is only sent when it changes a delta, can
```
Rule
-on SI7021#temperature>%var1% do backlog var1 %value%; publish stat/sonoff/temp %value%; var2 %value%; add1 2; sub2 2 endon
-on SI7021#temperature<%var2% do backlog var2 %value%; publish stat/sonoff/temp %value%; var1 %value%; add1 2; sub2 2 endon
+on SI7021#temperature>%var1% do backlog var1 %value%; publish stat/mqttTopic/temp %value%; var2 %value%; add1 2; sub2 2 endon
+on SI7021#temperature<%var2% do backlog var2 %value%; publish stat/mqttTopic/temp %value%; var1 %value%; add1 2; sub2 2 endon
```
#### Adjust the value of a sensor and send it by MQTT
@@ -1003,7 +1074,7 @@ This example adds 2 degrees to the measured temperature and then sends that valu
```
Rule
on tele-SI7021#temperature do backlog var1 %value%; add1 2; event sendtemp endon
-on event#sendtemp do publish stat/sonoff/temp %var1% endon
+on event#sendtemp do publish stat/mqttTopic/temp %var1% endon
```
[Back To Top](#top)
@@ -1020,14 +1091,14 @@ Write the following rules:
receiving `on` and `off` results in
```
-MQT: tele/sonoff-1585B3/RESULT = {"SSerialReceived":"on"}
+MQT: tele/mqttTopic/RESULT = {"SSerialReceived":"on"}
RUL: SSERIALRECEIVED#DATA=ON performs "power1 1"
-MQT: stat/sonoff-1585B3/RESULT = {"POWER":"ON"}
-MQT: stat/sonoff-1585B3/POWER = ON
-MQT: tele/sonoff-1585B3/RESULT = {"SSerialReceived":"off"}
+MQT: stat/mqttTopic/RESULT = {"POWER":"ON"}
+MQT: stat/mqttTopic/POWER = ON
+MQT: tele/mqttTopic/RESULT = {"SSerialReceived":"off"}
RUL: SSERIALRECEIVED#DATA=OFF performs "power1 0"
-MQT: stat/sonoff-1585B3/RESULT = {"POWER":"OFF"}
-MQT: stat/sonoff-1585B3/POWER = OFF
+MQT: stat/mqttTopic/RESULT = {"POWER":"OFF"}
+MQT: stat/mqttTopic/POWER = OFF
```
[Back To Top](#top)
@@ -1146,77 +1217,6 @@ ELSE // ENERGY#Power changed (i.e. LE 5)
------------------------------------------------------------------------------
-#### Solar heater control
-
-In a swimming pool, a filter pump and a solar panel is installed. When the sun is shining, the pump should push water through the solar panel, to heat the pool. When it's night or cloudy, the pump should be off, to avoid cooling the pool water through the solar panel. The pump is controlled by a Sonoff TH10 with 2x DS18B20 sensors connected.
-
-3 rules:
-
-* Pump should start when solar panel is more than 2 deg warmer than the pool water
-* Pump should stop when solar panel is less than 1 deg warmer than the pool water
-* Pump should not start if the solar panel is below 25 deg celsius.
-
-`t1`: pool temp
-
-`t2`: panel temp
-
-`var1`: in valid panel temp range?
-
-`var2`: off threshold temp for panel
-
-`var3`: on threshold temp for panel
-
-`mem3`: lowest valid panel temp
-
-```
-mem3 25
-rule1
- on DS18B20-1#temperature do
- event t1=%value%
- endon
- on DS18B20-2#temperature do
- event t2=%value%
- endon
- on event#t2>%mem3% do
- var1 1;
- endon
- on event#t2<=%mem3% do
- var1 0;
- endon
- on event#t1 do
- backlog
- var2 %value%;
- add2 1;
- endon
- on event#t1 do
- backlog
- var3 %value%;
- add3 2;
- endon
- on event#t2>%var3% do
- power1 %var1%;
- endon
- on event#t2<%var2% do
- power1 0;
- endon
-rule1 1
-```
-
-To test the rule without having the sensors in place, simply enter the events for `t1` and `t2` in the console:
-
-```
-event t1=21
-event t2=30
-```
-
-And watch the relay turn on and off based on the values.
-
-Please note that this example does not support manual override or handle missing sensor data. Take a look at [Thermostat Example](#thermostat-example) for examples.
-
-[Back To Top](#top)
-
-------------------------------------------------------------------------------
-
#### IR Forward
Using one IR receiver and one sender (or both extender) you can simply forward signals from one to another using the following rule
@@ -1229,7 +1229,7 @@ rule1 on IRreceived#Data do publish cmnd/irsideboard/irsend {Protocol:NEC,Bits:3
------------------------------------------------------------------------------
#### Garage Door Opener
-([#3942](https://github.com/arendst/Sonoff-Tasmota/issues/3942#issue-365226844))
+([#3942](../issues/3942#issue-365226844))
// Set the relay on time to signal the opener
`PulseTime 7`