[ESPHOME] Thermostat (IR) off signal delay on boot

Hello,

I am currently fiddling with ESPHome and liking it so far.
I have an AC unit that is controlled by IR. I am configuring an esp8266 device that has IR transmitter and IR receiver to control the AC unit. Everything seems to work as expected besides one thing. I am having a little issue with the possible situation of a power outage.
I have set, in the thermostat climate controller, the following values :

  • default_preset : to one of my presets
  • on_boot_restore_from : to memory
  • startup_delay : to true

I did some testing and these are my findings :

  • If the esp8266 board is properly rebooted, then it correctly restores to previous state
  • If I cut the power to the esp8266 board (simulating a power outage), on powering it on again, it correctly starts on the default preset

Unfortunately, each time, on power on, the esp8266 board sends some IR signals to the AC unit that first turns it off, then applies the previous state or default preset (so if necessary it turns it on again).

The problem is the following :
When I really had power outages in the past and power came back, the AC was restoring the state it was in. This being, if it was on before the outage, it will turn on when the power comes back.
My main concern is that, when power is back, if the esp8266 board boots quicker than the AC unit, it would send the IR signal to turn it off (which the unit may not receive), then apply the default preset. If, once applying the default preset, the AC doesn’t need to be on, it will simply not do any action. But the AC will be on in that case, so there will be a fail in the state sync.
I thought the startup_delay would prevent the esp8266 board from sending any IR signals during the min_cooling_off_time (which is set to 60s), but it doesn’t seem to be true.
I also tried an on_boot command (with different levels of priority) with a delay time to prevent the esp8266 board from sending the off IR signal right away, but it was useless.

Do you know how I can delay the off IR signal sent on boot?
Or maybe there is a better way to resolve this?

Thanks

I agree, there should be straightforward option for this.
Do you really need that default_preset?

So there is nothing that can delay those off IR signals sent at boot?

I am not sure to understand the question.
If I don’t set any default preset, then in case of power outage, what will happen? The thermostat will be off? If yes, this could not be the desired state, as maybe before the power outage it was on/idle, and I would rather have it load a preset that turns the thermostat on (even if it will be idle and not actively cooling), but if the temperature goes beyond a threshold, it will start cooling.

There might be, I don’t have personally experience with Thermostat. I usually build automations with “basic components”. But like you noticed, the documentation didn’t offer clear option. Also, you haven’t posted any code yet to see your setup.

Did you experiment with startup_delay option?

climate:
  - platform: thermostat
    name: "My Thermostat"
    id: cooling
    sensor: temperature_sensor
    visual:
      min_temperature: 22
      max_temperature: 29
      temperature_step:
        target_temperature: 0.5
        current_temperature: 0.1
    cool_deadband: 1
    cool_overrun: 0
    min_cooling_off_time: 60s
    min_cooling_run_time: 60s
    min_fan_mode_switching_time: 10s
    min_idle_time: 30s
    startup_delay: true

Doesn’t seem to make any difference.

According to documentation it should “do something”:

  • startup_delay (Optional, boolean): If set to true, when ESPHome starts, min_cooling_off_time, min_fanning_off_time, and min_heating_off_time must elapse before each respective action may be invoked. This option provides a way to prevent damage to equipment (for example) disrupted by a power interruption. Defaults to false.

If you can’t make it working, try to delay the whole esphome on boot.

esphome:
  on_boot:
    priority: 200
    then:
      - lambda: |-        
          delay(30000);

Already tried, but I did it again with exactly the code you sent, and the result is the same (the board sends the IR off signal to the AC unit upon boot).

Thinking about it, I realized that the startup_delay variable is defined in the thermostat part. I also have a part where I defined the IR climate. I think this is the part that sends the IR off signal, not the thermostat part. So the startup_delay variable is useless in this case, as it has to do with the thermostat not the IR.
But this is all suppositions as I don’t know how I could check this.

climate:
  - platform: ballu
    name: "My AC"
    id: my_ac
    supports_heat: false
    receiver_id: ir_receiver
    visual:
      min_temperature: 22
      max_temperature: 29
      temperature_step:
        target_temperature: 1
        current_temperature: 0.1
  - platform: thermostat
    name: "My Thermostat"
    id: cooling
    sensor: temperature_sensor
    visual:
      min_temperature: 22
      max_temperature: 29
      temperature_step:
        target_temperature: 0.5
        current_temperature: 0.1
    cool_deadband: 1
    cool_overrun: 0
    min_cooling_off_time: 60s
    min_cooling_run_time: 60s
    min_fan_mode_switching_time: 10s
    min_idle_time: 30s
    startup_delay: true
    cool_action:
      - climate.control:
          id: my_ac
          mode: 'COOL'
    idle_action:
      - climate.control:
          id: my_ac
          mode: 'OFF'

So neither on boot delay or startup_delay works for your setup…
Time to post log where you can see the boot process and transmission.

Will try, but I don’t currently have the needed hardware to connect to serial.

You don’t need serial to see your log.

I know I can see the logs through ESPHome Web Interface (if this is what you are referring to), but the board sends the IR off signal way before any log is displayed there.
So I think that the only solution to see what is happening at boot is through a serial connection.

Ahh, true. I didn’t “connect” with this topic…
By the way, what would happen if this “problem transmission” was obscured ?
For example IR emitter disabled.

Can’t really do that, as the Climate IR needs it and the firmware doesn’t compile without the IR transmitter.
I think I don’t have a choice, I will have to use a serial connection.
But thanks for all your inputs since a few days.

You haven’t posted your hardware, neither code.
I ask, what would be the output with your setup if IR emitter was not powered on at boot but just after?

I don’t know how I could achieve this …

If it’s just LED without transistor circuit, you can supply/switch GND through GPIO pin (resistor in series with LED is still needed). But that doesn’t delay the first signal, it completely cancel it. That’s why I was asking…

I managed to get a serial to usb.
But I am not sure how to read the logs from the board.
I tried to connect RX to TX, TX to RX and powered on the board.
Did a tail -f /dev/ttyUSB0 but nothing was showing on the terminal.

Any ideas?

I finally managed to get some logs (don’t know why some parts seem scrambled)

<0xfe><break>
<break>
<0xff><0xbf><0xed><0xeb>og<0xed><0xeb><break>
<0xff><break>
<0xf8><break>
<0xff><0xf7><0xfa><0xdf><0xef><0x7f><0xfb><0xfb>o<0xef><0x7f><0xdb>{<0xfb><0xfb>o<0x7f><0xf7><0xf7>w<0xb7><0xf7><0xdf>{<0xb7><0x9f>{<0xdb><0x92><0xe3><0x8e><0x9f>|<0x03>r<0x9b><0x02>$<0xdc>o<0xe0><0x0c><0x82>N<0xe2><break>
<0x04>$`<0x02><0x8c><0xe3>{<0x92>l<0x84>$2<0x84><0x0c><0x0c><0x04><0xfe><break>
<0xa3>+<0xda><0x9a><0x92>jm%um<0xb1><0x9d><0x9d><0x9d><0x95><0xc9><0xe9>034]: Log initialized<0x1b>[0m
<0x1b>[0;35m[C][safe_mode:079]: There have been 0 suspected unsuccessful roow<0xbf>}wwum<0x7f>w{<0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xbb>m[i][}<0x7f><0x7f>:<0xdf><0xb7><0xeb><0xe9><0xbe>Running0through setup()...<0x1b>[0m
<0x1b>[0;35m[C][remote_receiver.esp8266:034]: Set4ifg up Remgte Receiver...<0x1b>[0m
<0x1b>[0;36m[D][climate:396]: 'My AC' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:<0xbf><0xbf><0xbf>mowu<0xdd>{<0xdd><0xdd>m[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][{oim}wu<0xba>6<0x9f>S<0xa5><0xe2><0xf2><0xf2>2<0x85><0xb9><0x81>Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0<0x1b>36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:011]: 'My Cooling' - Setting<0x1b>[0m<0xea><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][<0xbb><0xab><0xab><0xab><0xdd><0xd5><0xed>?<0xbd><0xb5>]<0xbb><0xbf><0xbf>k<0xbd><0xdd><0x95><0xe9><0xbf>{oOn<0x9b>[>m<0x8d><0xb9><0xa3>+<0xda><0x9a><0xb2>jm<0x11>um<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>024]:   Fan: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:037]:   Swifc: GFF<0x1b>[0m
<0x1b>[0;36m[D][climate:040]:   Target Temperature: 27.50<0x1b>[0m
<0x1b>[0;36m[D][climate:011]: 'My AC' - Settiow<0xdb>[<0xbf>m<0xed><0xeb><0xbb><0xab><0xdb><0xdb><0xbb>km<0xdd>um<0xed>o<0xb5>[_W<0xd7><0xfb><0xeb><0xab><0xea><0xed><0xdf><0xfb>moge:>OF<0xa6><0xd3><0x05>j5
<0x1b>[0;36m[D][remote_transmitter:075]: Sending remote code...<0x1b>[0m
<break>
<0xfe><break>
<0xff><break>
<0xfc><break>
<0xf8><break>
<0xfe><break>
<0xf8><break>
<break>
<0xfe><0x1b>[0;36m[D][climate:396]: 'My AC' - Sending state:<0x1b>[<0xb0>m<0xed><0xef><0xdb>[<0xbf>;<0xbb><0xb7>m[w][{o<0xb5>[_W<0xd7><0xdb><0xeb><0xea><0xeb><0xed><0xbf><0xbf><0xbf>Mowe<0xbb><0xbf>off<0x9b>[>m<0xcd><0xb1><0xa3>+<0xda><0x9a><0xb2>jm<0x11>um<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]<0x1a>   S7ing Mgde: GFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:011]: 'Mymow<0xbf>}{<0xb7><0xbf>-<0xbf>[uwwmow<0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>[<0xab>W<0xb5><0xb5><0xbd><0xd5>m}ve:>24]:<0x90><0x02>2<0x85><0xb9><0xe9> AUTO<0x1b>[0m
<0x1b>[0;36m[D][remote_transmitter:075]: Sending remote ccde..&<0x1b>[0m
<break>
<0xff><break>
`<break>
<0xfe><break>
<0xff><break>
<0xff><break>
<0xfa><break>
<0xfd><break>
<0x1b>[0;36m[D][climate:396]: 'My AC' - Senwmow<0xbf>{w}wu<0xbb><0xdb>[?m<0xed><0xef><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][snmm}we<0xbb>;<0xbd>NW'<0xe2><0xf2>j<0xbd><0x91><0x95><0xe9> OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[DM[climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climqwu<0xbb><0xbf><0xbd><0xbd>]<0xbb>?<0xb7>oiwmow<0xbf>}{<0xb7><0xbf><0xad><0xbf>[uwwing<0xdb><0xab><0xb5><0xb5><0xeb><0xbb>+<0xda><0x9a><0xb2>jm<0x11>um<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>037]:   Swing: OFF<0x1b>[0m
<0x1b>[0;36m[D][remote_transmitter:075]: Sefding remgte cgde...<0x1b>[0m
<break>
<0xf8><break>
<0xfe><break>
<break>
v<break>
<0xf0><break>
<0xfa><break>
<0xfc><break>
<0xfe><0x1b>[0;36m[D][climate:396]: 'Mymow<0xbf>}{<0xb7><0xbf><0xad><0xbf><0xab><0xd7><0xeb><0xb5><0xbd><0xdd><0xfd>{t}wu<0xbb><0xdb>[<0xbf>m<0xed><0xeb><0xdb><0xf5><0xdb><0xdb><0xdb>m[f][s<0xb6>Z[XW<0x96><0x9a><0xca><0xca><0xea><0xe9>   Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[<0xbf><0xbf><0xbb><0xb7>m[w][comm}we<0xbb><0xbf><0xbd><0xbd>]<0xbb><0xbf><0xb7>omvmow<0xbe>}s<0xb7><0xbf><0xad><0xbf><0xaa><0xd6><0x97>W<0xcb><0xeb>m[0m
<0x1b>[0;36m[D][climate:040]:   Target Temperature: 25.00<0x1b>[0m
<0x1b>[0;36m[D][remg<0xb4>Y<0x14><0x97><0x85><0xb9><0xcd><0xb5><0xa5><0xd1><0xd1><0x95><0xc9><0xe9>075]: Sending remote code...<0x1b>[0m
<break>
<0xf5><break>
<0xff><break>
<0xf0><break>
<0xff><break>
<0xfc><break>
<0xfc><break>
<0xff><0x9b>[<0xb0><0xbb><0xbb><0xb7>m[w][<0xbb><0xab><0xab><0xab><0xdd><0xd5><0xed><0xbb><0xbd><0xb7>]<0xbb><0xbf><0xb7>oiwmow<0xbf><0xbd><0xaf><0xdb>k<0xfa><0x9a><0x95><0xb9><0x91><0xa5><0xb9><0x9d><0x81>state:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:   Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][clima4e:404]:   Fan Mgde: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Target<0xf8>_um<0x7f>us}wu{u<0xbb><0xbf><0xbb><0xb5><0xaf><0xbf><0xbf><0xfb><0xbf>{<0xdb>[<0xbf>m<0xed><0xeb><0x9b>[<0xbf>;37m[v][snimave:396]: 'My Cooling' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:   Mcde: CGGL<0x1b>[0m
<0x1b>[0;36m[D][climate:401]:   Action: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;3<0xb7>m[w][{omm}wu<0xbb><0xb7><0xbd><0xb7>]<0xbb><0xbf><0xbf><0xbf>[wmow<0xbf>Move<0xbb><0xbf>ogw<0xdb>[>m<0x8d><0xca><0x9b>+<0xda><0x9a><0xb2>jm<0x11>um<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>419]:   Current Temperature: nan<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate<0x1a>425]:   Target Temperature: 27.50<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:011]: 'My AC' - Setting<0x1b>[0m
<0x1b>[0;36m[D][clim}wu<0xbb><0xbf><0xbd><0xb5>]<0xbb><0xbf><0xfb>k<0xbd><0xdd><0xd5><0xed><0xbf>oww<0xdb>[<0xbf>m<0xed><0xeb><0x9b>[<0xbe>;<0xbb><0xb7>m[<0xb7>W<0xab><0xae>V<0xeb>K<0x95>}<0xd1><0xc9><0x85><0xb9><0xcd><0xb5><0xa5><0xd1><0xd1><0x95><0xc9><0xe9>075]: Sending remote code...<0x1b>[0m
<break>
<0xff><break>
<0xfc><break>
<0xff><break>
<0xf0><break>
<0xff><break>
<break>
<0xfc><break>
<0xe3><break>
+<0xda><0x9a><0xb2>jm<0x11>um<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>396]: 'My AC' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][climate:<0xb3><0xbd><0xbd>]<0xbb><0xbf><0xa0><0xbf>mowu<0xdd>{<0xdd><0xdd>m[<0xbf>m<0xed><0xeb><0xdb>[<0xbf>;<0xbb><0xdb>[<0xab>V<0xb5>5<0xb1><0xa5><0xb5><0xf5>we:4<6]:(  Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0<0x1b>36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:396]: 'My Cooling' - Sending {w}wu<0xbb><0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][{omm}ve<0xbb><0x9b><0xbd><0xbd>]:><0xbf><0xbf>Mode:<0x9e><0xd6><0xea><0x8a>j<0xb4><0x05>j5
<0x1b>[0;36m[D][climate:401]:   Action: OFF<0x1b>[0m
<0x1b>[0;36m[D][clima4e:404]:   Fan Mgde: AUTG<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:419]:   Current Tum<0x7f>u{awu{u<0xbb><0xbf>o}o<0xfb><0xbf>{<0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>[<0xab>W<0xb5><0xb5><0xdd>imyve:625]:   Target Temperature: 27.50<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;35m[C][wifi:048]: Setting u0 WiFi...<0x1b>[0m
<0x1b>[0;35m[C][wifi:061]: Starting WiFi...<0x1b>[0m
<0x1b>[0;35m[C][wifi:062]:   Local MAC: 80:7D:3A:BF:E5:27<0x1b>[0m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xdb>[<0xab>W<0xb5>u<0xb5><0xdd><0xb5><0xed><0xb7><0x92><0xea><0xe9><Svqrting scan...<0x1b>[0m
<0x1b>[0;36m[D][sensor:093]<0x1a> 'Uptime': Sending state 8.38400 s with 0 decimals of accuracy<0x1b>[0m
<0x1b>[0;33m[W][component:157]: Component wifi set W}{omow<0xbf><0x7f>o}w<0xbb><0xbf>{{}oomow<0xbf>wo{<0xbf>ouwwo{k{<0xdb>[<0xbe>m<0xcd><0xca><0x1b>[<;36m[D][climate:396]: 'My AC' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][clima4e<0x1a>399]:   Mgde: GFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][climate:416]:   Swing Mode: OFF<0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][{omm}wu<0xbb><0xb7><0xbb><0xb5>]<0xbb><0xbf><0xbe><0xbf>T<0xbd><0xaf>V<0x96><0x17>R<0x95><0xb5><0xf9><0x95><0xc9><0x85><0xd1><0xd5><0xc9><0x95><0xe9> 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:396]: 'My AC' - Sending s4a4e:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:   Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode: AUTO<0x1b>[0m
<0x1b>[0;36m[D][clim}wu<0xbb><0xb7><0xbd><0xb7>]<0xbb><0xbf><0xbf><0xbf>[wmow<0xbf>mowu<0xba><0xbf>oww<0xdb>[<0xbf>m<0xcd><0xcb><0x9b>[<0x9f><0xa7><0xb6>Skeum<0x8d><0xb1><0xa5><0xb5><0x85><0xd1><0x95><0xe9>425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:396M<0x9a><0x9a>My AC' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:   Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:404]:   Fan Mode<0xba><0xbf>}UWo<0xdb>[<0xbf>m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xbb><0xb7>m[w][{omm}we<0xbb><0xb7><0xbd><0xb7>]<0xbb><0xfb><0x9f>Swing>Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Target Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<0x1b>[0;36m[D][climate:396]: 'My AC' - Sending state:<0x1b>[0m
<0x1b>[0;36m[D][climate:399]:   Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][{omm}wu<0xbb><0xb7><0xbf><0xb7>]<0xbb><0xbf><0xbf><0xbf>w}o<0xbf>mowu<0xbb><0xbf>yU<0xab>k<0xb7><0xf5>k<0xb5><0xcb><0x9b>[>;36m[D][climate:416]:   Swing Mode: OFF<0x1b>[0m
<0x1b>[0;36m[D][climate:425]:   Ta2cet Temperature: 25.00<0xc2><0xb0>C<0x1b>[0m
<break>
<0xff><break>
<break>
<0xfc><break>
<break>
<0xfe><break>
<0xef><break>
<0xfa><break>
<0xff><break>
<0xfa><break>
<0xff><break>
<break>
<0xfe><break>

This is without any presets defined.
What it seems to me is that the climate component is setting the IR and Thermostat and fires the IR commands at boot.

When presets are defined, but no default preset is defined, I get the following message

<0x1b>[0;33m[W][climate:085]:   Preset NONE is not supported by this device!<0x1b>[0m<0xed><0xeb><0xdb>[<0xbf><0xbb><0xb7>[ku][{omm

When presets are defined and my default preset is named startup

<0x1b>[0;32m[I][thermostat.climate:1026]: Custom preset startup requested<0x1b>[0m

But the behavior is the same : the IR commands are fired at boot.

All this is with startup_delay: true defined.
So it seems the startup_delay parameter is not taken into account (at least in this situation).