Help with a rule to indicate if the cat has been fed at 1 of 3 feeding times during the day

Hi All! I'm struggling to create this rule and am hoping your bright minds can help!

We have a cat that gets fed 3 times per day. Once between about 6am and 10am, once between 4pm and 8pm and again between 10pm and 12pm. We are constantly asking each other 3 times a day, if the cat has been fed.

I would like to use a door sensor on the cabinet where the cat food is stored and then perhaps a virtual switch on our tablet, mounted in the kitchen running sharptools, to indicate if the cat has been fed recently. I'm struggling to figure out how to build this in Rule Machine. Basically if the cat food cabinet door is open between 6am-10am, or 4pm-8pm or 10pm-12pm turn virtual switch on so that that switch lights up on sharptools to indicate the cat has been fed recently, but how would I actually program this into Rule Machine? Or is there a better way to do this than what I'm outlining here? Thanks!!

Something like this? You can change the timeout to turn the switch off again to whatever your definition of "recently" is. :slight_smile: Using this logic, after 30 minutes, the "cat" switch automatically turns off (or resets) for the next feeding.

1 Like

If you want the switch timer to "reset" back to a new 30 minutes if the cabinet is opened, I would add "Cancel Delayed Actions" somewhere, probably at the beginning of the rule before any of the conditionals (your trigger is only "open" and presumably you'd want it reset any of those times). Of course, it all depends on what you want. If you only open it once or only care about the first time, this won't matter much, though the "cancelable" flag doesn't do anything in that case. I'd also probably move the "Off" action before the END-IF, otherwise it will schedule an "off" for this switch even if the cabinet was opened outside those times (and this the virtual switch was never turned on, but say it was later...which would be remedied with a cancel, so if that was changed too I guess this would also matter less).

Either way, this otherwise looks good to me! I assume your cat's automatic meow-er has a very short timer that cannot be adjusted and is hard to read. :laughing:

2 Likes

LOL, this isn't my rule. I was just suggesting an idea. I guess I'm so used to ticking "cancel" on all my delayed timers that I forget NOT to do it when not needed. :wink:

Sorry, I was mixing "you"s for different second-persons. Ha.

As for "Cancel," I think I'd still do it. There may be something I haven't thought through 100%, but it's definitely the case that multiple openings would cause multiple scheduled "off"s if you don't, which is likely to cause surprises at some point (especially if the "off" is scheduled all the time and not just during the feeding times as it currently is).

1 Like

True! Good catch!

Thanks for this @corerootedxb!

I'm thinking, if the contact sensor was opened at 6am, would it reset at 6:30am then? If so, I suppose I could extend the timeout to 4 hours to catch the whole 6am-10am morning feeding window but then I imagine this would result in a feeding at 6pm looking like the cat had been fed it's before bed meal at 8pm when it actually was just fed a later supper. I'm trying to rack my brain if I could modify this a bit to just turn the switch off at 10am, 8pm and 12 am; that way once the cat was fed, it wouldn't matter how much time passed before the switch turned off, it would just turn off at the end of the normal feeding window.

EDIT: Wow you guys are fast. I was typing a reply to the first responses to my question and there are like 4 more messages by the time I actually posted this!

2 Likes

That would work too. Think of the rule I posted as an idea and expand upon it. :smiley: (and absolutely take @bertabcd1234's input as well... He always nails logic problems).

Keep this rule, eliminate the "off" action in the rule, and use three Hubitat Simple Lighting child apps to turn off the virtual swith at 10, 8, and 12 (or shortly before, if you want) is what I would do then. :slight_smile: But you could also make one rule with three time-based triggers that turns off the switch, too. I think adding that to this one would make the rule hard to deal with--simple is often better (especially if your actions have little to do with each other, which they would here).

I really wish these apparent abilities included me when I'm creating my own rules and not just looking at others' when they already did most of the work. :laughing:

1 Like

^^^ SEE?! He always nails the logic problems (which is a fantastic thing) +1 sir!

Three simple lighting rules would, as you say, be easiest, but how would I do this all in one rule with time based triggers? It's one thing I really disliked about my Wink Hub days was how many different robots would have to be created to accomplish one task. It was also difficult to keep straight which robots worked with which other robots to accomplish that one task. I love how, for the most part, with Hubitat, one rule machine logic can accomplish everything that needs to happen and I can even write notes in there to explain how it works or what I was thinking or problems I'm experiencing that need to be worked out.

1 Like

Something like this should work for that:

Triggers:

Time is 10 AM OR
Time is 8 PM OR
Time is 12 AM

Actions:

Turn off Virtual Switch XYZ

I guess Simple Lighting would almost be more difficult in this case since you'd have to click just as much to create three child apps, but either should work.

That's straight forward! Could this be included in the some Rule Machine child app that triggers the virtual switch to turn on if the door is opened at certain times? Or is the only way to have this as a separate rule machine child app?

Technically, you could do it in the same rule, but I would do it as a separate rule. That way, the triggers are separated. So, the first rule triggers on the door opening. The second one resets the switch at the times you want and is triggered at 10:00, 20:00, and 22:00.

1 Like

I would definitely make it a separate Rule. (Just do "Create New Rule 4.0" as you did for the first, if you haven't created multiple rules before.) Jamming a bunch of triggers onto the same rule to run actions that have nothing to do with actions you want to run for other triggers seems like a recipe for disaster, trying to sort out what you want to happen when in your actions. (I know it sounds cleaner, and people who've previously used webCoRE are used to this, but...as people used to say here back when it was harder to make complicated rules: "Rules are free." :slight_smile: )

1 Like

Awesome, thanks guys!! I'll let you know how it goes!

2 Likes

Hi guys, just wanted to let you know that this is working great! This was one automation that my wife was actually quite happy with and just works like it should! Thanks for your help!

1 Like