Humidity meter

Hello
Sorry for the bad English.
I have a sonoff relay, a motion sensor and a door open sensor, as well as a humidity meter.
I would like to resolve that if the humidity is higher than 76 percent, turn on the sonoff relay. Also … If the door is open, turn it off. This has been resolved so far, but something is still needed.
If motion is detected, still turn off the relay and if not, but the humidity is above 76, turn it back on. Unfortunately, this part is not going. How could this be solved?

First automation. If the humidity is low.
‘’’
alias: Alacsony a pára
description: ‘’
trigger:

  • type: humidity
    platform: device
    device_id: c4b5b57809c8b4c7a5a4cac1160fad2b
    entity_id: sensor.lumi_lumi_sens_f7ae8304_humidity
    domain: sensor
    above: 0
    below: 76
    condition: []
    action:
  • service: sonoff.send_command
    data:
    device: 1000c2059d
    switch: ‘off’
    mode: single
    ‘’’
    Second. If the humidity is high.
    ‘’’
    alias: Magas a pára
    description: ‘’
    trigger:
  • type: humidity
    platform: device
    device_id: c4b5b57809c8b4c7a5a4cac1160fad2b
    entity_id: sensor.lumi_lumi_sens_f7ae8304_humidity
    domain: sensor
    above: 76
    condition: []
    action:
  • service: sonoff.send_command
    data:
    device: 1000c2059d
    switch: ‘on’
    mode: single
    ‘’’

Third. When the door is open.
‘’’

alias: Nyitva az ajtó
description: ‘’
trigger:

  • type: opened
    platform: device
    device_id: 47fb5d442140bd6d36280841062f91c0
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_2b6f5a04_on_off
    domain: binary_sensor
    condition:
  • condition: and
    conditions:
    • condition: state
      entity_id: switch.sonoff_1000c2059d
      state: ‘on’
      action:
  • service: sonoff.send_command
    data:
    device: 1000c2059d
    switch: ‘off’
    mode: single
    ‘’’

Fourth. If the door is closed.

‘’’
alias: Zárva az ajtó
description: ‘’
trigger:

  • type: not_opened
    platform: device
    device_id: 47fb5d442140bd6d36280841062f91c0
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_2b6f5a04_on_off
    domain: binary_sensor
    condition:
  • condition: and
    conditions:
    • condition: state
      entity_id: switch.sonoff_1000c2059d
      state: ‘off’
    • condition: and
      conditions:
      • type: is_humidity
        condition: device
        device_id: c4b5b57809c8b4c7a5a4cac1160fad2b
        entity_id: sensor.lumi_lumi_sens_f7ae8304_humidity
        domain: sensor
        above: 76
        action:
  • service: sonoff.send_command
    data:
    device: 1000c2059d
    switch: ‘on’
    mode: single
    ‘’’

I’m here for now. If I also install the motion sensor, it will not work. :frowning: