Sensor (wattage) between 2 values continuously for 30 minutes -> trigger automation

I have a kitchen hood that works on RF and a hob that send commands using IR. In between is an ESP32 that translates and for example turns on the hood, when the hob requests.

Unfortunately i cannot get any feedback from the hood, other than registering its wattage usage. What i want to achive is the following:

  • register the IR code ‘hood on’ from the hob (i already have a sensor for this)
  • from that moment start monitoring the wattage
  • if the wattage is between 10 and 14 watts for 30 minutes continuously, turn off the light. If the wattage goes below of above, abort.

So if my wife decides to turn the fan on again the trigger should be discarded. Can someone give me a YAML example on how i can achieve this?

trigger:
  - platform: numeric_state
    entity_id: sensor.hood_power
    below: 14
    above: 10
    for:
      minutes: 30
action:
  - service: light.turn_off
    target:
      entity_id: light.hood

Any excursion outside the 10 to 14 W range (e.g. if the fan is turned on) resets the 30 minute timer and it will not start timing again until back inside that range and thus not trigger unless it stays in that range for 30 minutes continuously.

Thanks for the quick reply.
I want to enable this trigger only when the hood receives a specific RF code. How would i do this?

Set an input boolean when the code is received (using another automation) and use that in a state condition in the first automation.