How to replace yaml with lambda? Help please

Friends, help me figure it out. I am not a programmer, so it is difficult to use lambda.
I need to create a stand-alone fan control module depending on the humidity sensor.

But it is also important that the on and off levels can be changed from the HA.

For this, I have used global variables, services and sensors for HA from various sources. But the automation itself does not work (How can the numbers (60, 90 )in this code be replaced with global variables? Or how can the automation itself be replaced with lambda?

globals:
  - id: min_${device_name}
    restore_value: true
    initial_value: '70'
    type: int
  - id: max_${device_name}
    type: int
    restore_value: true
    initial_value: '90'
  
sensor:
  - platform: dht
    pin: 00
    model: AM2302
    temperature:
      name: "Bathroom Temperature"
    humidity:
      name: "Humidity ${device_name}"
      id: hum_${device_name}
      on_value_range:
        - above: 90.0
          then:
            - switch.turn_on: dehumidifier1
        - below: 70.0
          then:
            - switch.turn_off: dehumidifier1