This is the current situation with a template fan created on ESPhome.
I want to control the from both the Home Assistant UI and the IR remote controller. In trying to achieve this I now got an endless loop:
Pulse the fan direction button on the IR controller THEN:
- The physical fan efectively changes direction (this is OK)
- The fan direction on HA is updated/synchronised:
remote_receiver:
pin:
number: GPIO15 #D15
inverted: true
dump: nec ##el log mostrará sólo los códigos de NEC que aparezcan
on_nec:
- if:
condition:
- lambda: return (x.command==0xF807); # get IR code
then:
- fan.turn_on:
id: ventilador_techo_dormitorio
direction: !lambda |-
if (id(ventilador_techo_dormitorio).direction == esphome::fan::FanDirection::FORWARD) {
return esphome::fan::FanDirection::REVERSE;
} else {
return esphome::fan::FanDirection::FORWARD;
}
- switch.turn_on: switch_ventilador_techo_dormitorio
This code turn on a switch that stores the on/off state of the fan and update the direction of the fan on Home Assistant BUT
When the direction is changed on Home Assistant…
fan:
- platform: template
name: "Ventilador techo dormitorio"
id: ventilador_techo_dormitorio
speed_count: 6
has_direction: true
restore_mode: ALWAYS_OFF
[....]
on_direction_set:
- remote_transmitter.transmit_nec:
address: 0x7F80
command: 0xF807
… the fan sends the IR code (this is necessary to control the fan from HA) and efectiveley changes AGAIN the direction…
And because of the IR code sent I have an endless loop.
Any idea on how to break this loop?