Change fan direction

Hi there the if statemen for the fan change direction is not working

remote_receiver:
  pin:
    number: GPIO15 #D15
    inverted: true
  dump: nec  ##el log mostrará sólo los códigos de NEC que aparezcan
  on_nec: 
    then:
    ## Comandos del ventilador #################
       - if:
           condition:
            - lambda: return (x.command==0xE01F);  # ON/OFF fan
           then: 
            - fan.toggle: ventilador_techo_dormitorio
            - switch.toggle: switch_ventilador_techo_dormitorio
       - if:
           condition:
            - lambda: return (x.command==0xF807); # fan direction
           then: 
            - fan.turn_on:
                id: ventilador_techo_dormitorio
                direction: !lambda |-
                  if (id(ventilador_techo_dormitorio).direction=="forward") {
                    return reverse;
                  } else {
                    return forward;
                  }
            - switch.turn_on: switch_ventilador_techo_dormitorio    

Error says:


/config/esphome/luz-ventilador-dormitorio.yaml: In lambda function:
/config/esphome/luz-ventilador-dormitorio.yaml:306:49: error: no match for 'operator==' (operand types are 'esphome::fan::FanDirection' and 'const char [8]')
  306 |                   if (id(ventilador_techo_dormitorio).direction=="forward") {
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
      |                                        |          |
      |                                        |          const char [8]
      |                                        esphome::fan::FanDirection
/config/esphome/luz-ventilador-dormitorio.yaml:307:16: error: 'reverse' was not declared in this scope
  307 |                     return reverse;
      |                ^    ~~
/config/esphome/luz-ventilador-dormitorio.yaml:307:16: note: suggested alternatives:
In file included from /data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/algorithm:85,
                 from src/esphome/core/optional.h:19,
                 from src/esphome/components/socket/socket.h:5,
                 from src/esphome/components/api/api_frame_helper.h:12,
                 from src/esphome/components/api/api_connection.h:5,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/pstl/glue_algorithm_defs.h:249:1: note:   'std::reverse'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
In file included from /data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/algorithm:63:
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/bits/ranges_algo.h:1292:33: note:   'std::ranges::reverse'
 1292 |   inline constexpr __reverse_fn reverse{};
      |                                 ^~~~~~~
/config/esphome/luz-ventilador-dormitorio.yaml:309:16: error: 'forward' was not declared in this scope; did you mean 'std::forward'?
  309 |                     return forward;
      |                ^    ~~
      |                std::forward
In file included from /data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/bits/stl_pair.h:61,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:64,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/array:43,
                 from src/esphome/components/api/api_frame_helper.h:2:
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/xtensa-esp-elf/include/c++/14.2.0/bits/move.h:82:5: note: 'std::forward' declared here
   82 |     forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
      |     ^~~~~~~
*** [.pioenvs/luz-ventilador-dormitorio/src/main.cpp.o] Error 1
========================== [FAILED] Took 8.32 seconds ==========================

Read the docs, they have examples there:

if (id(my_fan).direction == FanDirection::FORWARD)