Tweaking energy saver Smartpps?

I would like to tweak the Energy Saver smartapps so that when the power in the plug drops before 1 kw my lights would turn on. I think I have it but since I’m using this for my dryer it will be on 0 when the dryer is finished so when I turn my lights off a few minutes later they turn back on. How could I set it up so it will only happen once until I start the dryer again. Here the code that I changed:

There a couple of things to think about

  1. When your dryer goes below the watts level does it stay that way or does it have an ‘anti-crease’ which means it starts every few minutes to run the drum and obviously uses some power to do this.

  2. You could have a variable that would be set when the switches go on then won’t get reset unless the wattage goes above 1kw again

For example:
After your switches.on() statement you could have

state.again = false

Then if the power goes above 1kw (when you switch on again)

state.again = true

That way you could make the switch on of lights conditional on the state.again being true.

E.g.
if(state.again == true){
switches.on()
state.again = false
}