Turning on the fan by humidity

Hello everyone. I don’t speak English, I write through a translator. I know very little about Home assistant. I have a fan in the bathroom, a zigbee switch, two humidity sensors, one of which is in the bathroom, the other in the room. I’m trying to set up automation based on the humidity difference between the bathroom and the bathroom according to this article: https://dzen.ru/a/X5mZOCYDsg1Rb4TE. When the humidity increases, the fan turns on, when it decreases, the Home assistant writes that the automation has worked, but the fan also remains on. If automation is forcibly turned on, the fan turns off. What am I doing wrong?

alias: Включение вентилятора по датчику влажности
trigger:
  - platform: numeric_state
    entity_id: sensor.lumi_lumi_weather_humidity
    value_template: >-
      {{(states('sensor.lumi_lumi_weather_humidity') | float - 
      states('sensor.sonoff_th01_humidity') | float) | round(2)}}
    above: 20
action:
  - type: turn_on
    device_id: 248ee871f78b65d2e1a3949c8be8faf5
    entity_id: 293a9610c91399f16aa985d4d90146b4
    domain: light
initial_state: true
alias: Выключение вентилятора по датчику влажности
trigger:
  - platform: numeric_state
    entity_id: sensor.lumi_lumi_weather_humidity
    below: 45
  - platform: numeric_state
    entity_id: sensor.sonoff_th01_humidity
    value_template: >-
      {{(states('sensor.lumi_lumi_weather_humidity') | float - 
      states('sensor.sonoff_th01_humidity') | float) | round(2)}}
    below: 10
condition:
  - condition: state
    entity_id: button.ewelink_switch_zr02_identify
    state: "on"
action:
  - type: turn_off
    device_id: 248ee871f78b65d2e1a3949c8be8faf5
    entity_id: 293a9610c91399f16aa985d4d90146b4
    domain: light
initial_state: true

Please format your code properly so it can be read and understood.

Not sure what you did above, seems a combination of two automations

My proposal is to create a automation that triggers on the state of a (more) sensor humidity , i.e. do not check for value
Then skip conditions and add actions “choose”, e.g.

  1. if condition lumi > 20 turn on
  2. if condition th01 < 20 turn off
  3. if condition lumi < 45 turn off