Help with microwave finished rule

A little background so it's understood what I'm trying to accomplish.
My wife regularly reheats her coffee in the microwave and then forgets about it. At least once a day, almost every day. So I'm trying to create a rule to notify when the power level (using a Zooz ZEN15 power plug) has dropped below a specific level, and a contact sensor has not been opened after a few minutes.

I appreciate any help, but you must also understand how I have setup the contact sensor. Our microwave is installed in-cabinet above our regular oven, with a trim kit. So there isn't enough room for a magnet to be mounted to the door. I solved this in a way that I felt comfortable with. When the internal light turns on (as happens when the door is opened), a relay closes and the contact sensor indicates open. Of course the only downside I need to contend with this method is that when the microwave is running, the light is also on, so the contact sensor will also read open. When the microwave stops, the light turns off and the contact sensor indicates closed.

Another important piece of info. I do my regular announcements with Alexa Routines. So Alexa Microwave is a simple piece of code that creates virtual switch as motion sensor. When the switch is active in HE, Alexa sees a motion sensor active in the routine, and says my custom phrase.

What I'm not able to figure out is how to use these parameters to cancel the repeating action if the microwave is not running. My rule seems to work, but I'm expecting the change in the contact sensor when the microwave is not running, to evaluate the conditions and stop the repeating actions, but it doesn't. I've been at this one for a while and could use some help please.

Okay...I think I see your problem here. You are using a virtual switch, Alexa MIcrowave. I assume that this switch is a regular virtual switch without an "Auto-off" function defined in it? Well, you need to do one of two things. Either you need to enable the auto-off function on the virtual switch and then remove the off commands from this rule. Or you need to remove the repeats from this rule and move them to the rule that is reading this Alexa Microwave switch.

Or you could do the REALLY easy thing and forget all about using a completely unnecessary virtual switch and just put the announcement where the virtual switch turning on is located and remove the off commands from the rest of the rule.

But you have forgotten one thing. What about when the door is closed and the power is low? You don't want the announcements to happen then, right? I find it easier in cases like this to have the one instance I want the announcement to play defined in the rule and then use the else to catch all the instances when I don't. So, you only want it to happen the first time the power is low and the door is closed. Then you want it to not happen the next time the power is low and the door is closed? What you need is to have a variable set to "true" when the power goes above a certain point and then false again when the door gets opened. That way, when you close the door and the variable is false, the announcement won't start.

OK, sorry I left out an important bit, so I'll update the original post in a minute. Maybe that doens't is doesn't make a difference, or maybe it does.

I do my regular announcements with Alexa Routines. So Alexa Microwave is needed. It's a virtual switch as motion sensor using this code. When the switch is active in HE, Alexa sees a motion sensor active in the routine, and says my custom phrase.

metadata {
	definition (name: "Virtual motion with Switch", namespace: "cw", author: "cwwilson08") {
		capability "Sensor"
		capability "Motion Sensor"
        capability "Switch"
	}   
}

def on() {
    sendEvent(name: "motion", value: "active")
    sendEvent(name: "switch", value: "on")
    runIn(12, off)
}

def off() {
    sendEvent(name: "motion", value: "inactive")
    sendEvent(name: "switch", value: "off")
}

def installed() {
}

okay...so, if the switch is turning itself off, why do you have commands to turn it off in the rule? Those are not needed and can be removed. The issue you're having is not having any way to know that the mivrowave has just run. A boolean variable set to turn when the power goes high and then false when the door is opened will sort you out.

All of this would have been a LOT easier if you're used a Sensative Strip sensor. :stuck_out_tongue: jk.

Maybe I'm looking at it wrong and I do realize that it gets a bit wacky because of the way that my contact sensor works. If I open the door, the microwave internal light turns on and the contact sensor opens, but when the microwave runs the microwave internal light also turns on , and the contact sensor opens.

The power level being below threshold and the the light not being on (contact closed) should cause the ELSE statement to start the repeating action, which it does. But when the door is opened, a change occurs and I was expecting that the first action would be to stop the repeating action. I know that the microwave just ran because the contact changed and the power value is below the threshold.

Maybe Exit Rule instead of Stop Repeating and OFF: Alexa Microwave after the IF conditions? :thinking:

No....your problem is, how do you distinguish between the first time the microwave is in Low power, light off than all the rest of the time that the microwave is in low power light off. Here's a table.

1    Cycle Starts      Light on      Power high
2    Cycle Complete    Light off     Power low
3    Door open         Light on      Power low
4    Door closed       Light off     Power low

Do you see how lines 2 and 4 are the same? You have to have something to distinguish between those two. I went through the same thing with my washing machine rule. You want to trip the rule when the power first drops low but not while it remains low. You are triggering off the contact sensor (light) so the rule will fire when you close the door at step #4.

Thanks. After a lot of trial and heavy dose of errors, I have something workable. I appreciate the table you created. That's something I really should be doing instead of trying to work it out in my head all the time.

My issues were compounded by the contact sensor I was using too. Despite having tested it many times, it had failed at some point and at first the new rule didn't work at all, which was a real head scratcher until I found the issue. Replaced it with a hacked SmartThings MultiSensor for dry contacts, and it works now. No more cups of cold coffee left in the microwave hopefully :grin: Either that or an express ticket to the dog house for me :joy:


I don't understand why you have the PB in the other rule...but okay. You also need to keep trakc of whether Alexa Microwave is on or not. If you add that as a condition in the 2nd rule, that should prevent you from getting all your announcements.

Are you using Hub Connect? Did you make a change to isStateChange like I read in another post?

I should make a correction. Made a change and then forgot to test it because I needed to use the microwave for actual food. :wink: Before I had OFF: Alexa Microwave after the On: Alexa Microwave --> delayed: 0:01:00 (cancel) and that was causing the repeating only seconds apart, every time the power state changed. I removed it, as shown in the screen shot and it now repeats every minute until the door opens, which is fine.

The state of the Alexa Microwave turns out is not important to track here, as it is actually turning itself off. I think the Alexa services are doing it after the routine runs. I'm not sure why, but it works out.

I couldn't understand how to put it in the same rule when I'm using the power level change to trigger. I need the PB to be true only when the power level exceeds 800 watts, but I also need the state of the PB to be evaluated in the same rule based on a change in the power state and then flip that back in the same rule when the power level is below 800 watts.

What would you suggest? A separate IF/ THEN in front of the one I have here?

No...I would have my first if be if Power level >800 and PB is false then set PB true and change your first if to an Else-If. The power level should only be over 800 when the door is closed, right? Hopefully you're not running it with the door open. :wink:

1 Like

OK, I'll give that a try at some point. This has been a pain. Rules don't come as easy for me, so I need to step away from it and just relish the fact that I was even able to get it working. And remember to NEVER again make my trigger be the same as the device itself running! :roll_eyes:

1 Like

making rules is sometimes like having kids.
Your first rule is painful and you swear never to do it again. After a while you have forgotten the incident and think about doing another one :wink:

Is the wife happy with the reminder?

1 Like

:rofl: Yes but with two kids and years of rule building under my belt you would think I would have learned :wink:

My wife just headed out for a few days at her friends cottage, before I got it working, so I'm yet to find it if it's :ok_hand: or :-1::rage:

1 Like

I think there has only ever been one rule the wife has thanked me for and really likes. Its a reminder if I have left the fridge or freezer door open by accident.
Go figure

1 Like

I added that a while back. Don't know why I never did it before, but it's been very useful. I found out that while I sometimes don't get the door closed properly, she does it A LOT. Has not thanked me for it, and talks back to Alexa when reminded :rofl:

Maybe I'll save some money in the long run. That one is very useful. Someone on here (can't remember who it was) mentioned it in a post and I had one of those, slap the head V8 moments. Ours is a top freezer model, so a single contact sensor covers both doors.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.