(SOLVED) Timer help, turn device off IF wattage <X for 2minutes

You might already be aware of this: they sell a power strip that has “Master / Slave” thing. When the load on the Master is low, it turns off the slave outlets.

Example (and there are many out there): Amazon.com: APC P8GT 8 Outlets 120V Power-Saving Home/Office SurgeArrest with Phone Protection White, 9.1 x 14.0 x 1.5 : Electronics

Anyway, for your original question, it can be implemented in jruby like this:

require 'openhab'

LOW_POWER = 0|'W'...10|'W'
HIGH_POWER = 10|'W'..

rule 'Turn on the receiver' do
  changed TV_PowerDraw, from: LOW_POWER, to: HIGH_POWER, for: 5.seconds
  run { Receiver_Power.ensure.on }
end

rule 'Turn off the receiver' do
  changed TV_PowerDraw, from: HIGH_POWER, to: LOW_POWER, for: 2.minutes
  run { Receiver_Power.ensure.off }
end

The for: argument above ensures that the rule only executes if the item’s state remains in the to state for the specified duration. You won’t need to manually create your own timer to keep track of it.

The ensure will not send the on/off command if the item is already in that state.