A solution for using Thermostat Logic


I am in the process of migrating from Blynk to Home Assistant and OMG this thing is AMAZING.

I am still figuring out plenty of things so, if anyone is kind enough I would appreciate some guidance.

I need to set some pins LOW then back HIGH on a Tasmota device only for a short period of time, periodically. Doing this for a PIN or another should be controlled by the Thermostat.

The long version:
All my iOT devices are esp32 and esp8266 running Tasmota. Some are Sonoff devices, some are diy things built by me.

I am trying to use the Thermostat to control the heating system via RF. The RF controlled relay is connected to the heating system.

The BridgeRF I have is not strong enough to send signals for more than 2 meters away from the RF relay, don’t know why, but I connected to it an RF transmitter module with 4 pins. Each pin has its own code and it needs to be set on LOW for the code to be sent. I suspect the a signal is being sent for as long as only one of the pins is set on LOW. The Receiver RF Relay works either way, but I prefer to send periodic signals rather than keeping the signal continuously.

The RF transmitter has a code on a pin, and another code on a different pin. One pins sends the CLOSE relay command, the second pin sends the OPEN relay command whether is being sent continuously, or for a brief time. Which pin to be used needs to be controlled by the Thermostat Logic.

Later I am planning to use different scheduling for each day, as well as Geofence so I can control the Thermostat Logic, but I think I can manage that if I figure out how to achieve this thing first.

What would be the best way to achieve this?

From my understanding, the periodic signal and the duration can be set using min_cycle_duration and keep_alive. So how do I send the ON command on a pin, and the Off command on another pin

So I eventually made it, but I also need to work on the fail safe situations, as well as the scheduling logic

Fail-safe Issues discovered yet

  1. It needs to send OFF commands when the Heating logic is turned Off.
  2. The hardware device that sends the RF commands: BridgeRF running Tasmota, needs to set all the pins to 0 for soft restart, not just for the hard Restart

On the harware device I set:

SetOption19 1 - HA sync/autodetect
PowerOnState 0 - Turn all pins to OFF after powerup
SwitchMode 3 - I am not yet sure I clearly understand it, but this might now be relevant
BlinkTime 5
BlinkCount 2

The commands:

Power1 3 for turning Off the Heating
Power2 3 - for turning On the Heating

On Home Assistant:


#RF Heating Command
  - platform: mqtt
    name: "Heating Relay Commands"
    command_topic: "cmnd/bridgerf/Backlog"
    state_topic: "tele/bridgerf/RESULT"
    payload_on: "Power1 3"
    payload_off: "Power2 3"
    state_on: "Heating"
    state_off: "Not Heating"
    optimistic: true
    retain: false
    qos: 2      
  - platform: generic_thermostat
    name: "Thermostat"
    unique_id: switch.house_thermostat
    heater: switch.send_thermostat_relay_commands
    target_sensor: sensor.office_am2301_temperature_2
    min_temp: 15
    max_temp: 26
    ac_mode: false
    target_temp: 17
    cold_tolerance: 0.4
    hot_tolerance: 0
      seconds: 1
      minutes: 1
    initial_hvac_mode: "off"
    away_temp: 16
    precision: 0.1

Feel free to let me know what would you change and why. Thank you!