Rule machine is too confusing

It's been 34 years since I programmed in BASIC on a TRS-80 Model III so my if-then syntax might be a little rusty. I'm trying to make a rule that plays one of three MP3 files stored locally, whenever the front or back door is opened, depending on which mode the hub is currently in. The documentation for rule machine, and pretty much everything else, leaves a lot to be desired. I'm beginning to wish I never bought a Hubitat, because trying to figure it out is giving me a migraine.

2 Likes

Trigger: Front door open OR Back door open

Run: IF (Mode = 1) THEN
Play file_1.mp3
ELSE-IF (Mode = 2) THEN
Play file_2.mp3
ELSE-IF (Mode = 3) THEN
Play file_3.mp3
END-IF

This isn't verbatim to enter, but it's the general skeleton of the rule

2 Likes

I agree, Rule Machine can be very. stinking. frustrating. You come here, you get help, you master it, and wouldn't you know, something else gets frustrating. Rinse and repeat. You made the right choice by coming to Hubitat. The community here is amazing and friendly. But, we can't read your mind. Don't wait until you become frustrated, Do a quick search for your topic, because you're not alone, and if you don't find anything or still need help, then post it out here. We've all been there. We've all started somewhere. You're not expected to know it all out of the gate, but don't leave it all on yourself to learn alone.
Welcome to the community.

10 Likes

Stick with it. you will get past the migraine stage then truly love it. then start banging your head against the wall because you try and do a overly complex rule that is just for the F of doing so. But then we will all be here to help.

3 Likes

Enough of the warm and fuzzy. Can you post what you have or at least what your use case is and how you have it in your head and someone will put it in order for you.

2 Likes

no scripting environment is perfect. everyone is frustrated in the beginning you just have to be patient & avoid the tendency to yell and scream.

When you find yourself at a point where you want to give up; go take a walk around the block then come back and post a question on here and I bet you'll end up figuring it out without losing it. :slight_smile:

I have caught myself in the middle of typing up a question on here several times only to realize as i'm explaining it that I've actually worked through it in my head and end up deleting the post before responding.

Like April said, at some point it will click and you'll be fine. This is all new to me as well and at first I was ready to pull my hair out but you'll get there. We're here to help (well people smarter than me are anyway).

Great community! The community alone is hubitat's killer feature.

3 Likes

That's pretty much what I have and it doesn't work.

IF (Back door, Front door any open AND Mode is Day) THEN playTrack(http://redacted/local/robin.mp3) on Upstairs, Downstairs
ELSE-IF (Back door, Front door any open AND Mode in Evening, Night) THEN playTrack(http://redacted/local/crickets.mp3) on Upstairs, Downstairs
ELSE-IF (Back door, Front door any open AND Mode in Away, Bed) THEN playTrack(http://redacted/local/dog.mp3) on Upstairs, Downstairs
END-IF

My biggest issue is that whoever writes the documentation assumes that the reader has programming experience. My programming experience is obsolete by almost 40 years. I have forgotten most of what I knew about BASIC from high school, and I'm barely functionally literate in HTML. I need one of those yellow paperbacks titled Hubitat for Dummies.

3 Likes

so you need to set up your triggers first.
Triggers are what start the rule evaluation.
your triggers woudl be back door front door any open

Then move on to your rule
if mode is day
and
any door is open
then play track
else if mode is ...
and ...
then ...
else if
mode is...
and
any door ...
then
end if

also, you may be able to play a track according to mode instead of separating the rule to mode. You would have to look if it's possible for playback. It is a possibility for lighting.

Also, Might I suggest you use the notifications app? It's much easier and I am pretty sure it will do everything you need without getting so complicated. It's native, but you'd have to load it.

I'm not at home to provide screenshots, so I'm doing this from memory.

My trigger event is:

Back door, Front door any changed

EDIT: there are supposed to be asterisks on either side of the word changed. Apparently they're being interpreted as some kind of code for italics. :roll_eyes:

1 Like

i would not use any changed. Your trigger should be opened because the rule will evaluate every time there is an open or close event. Only use what you need to trigger the rule. Since all of your rule is about the doors opening, you do not need changed.

1 Like

I change the trigger event to open and the only change I got was that my Google home devices made a weird bleep sound but still didn't play the mp3s. I'm not sure if I should consider this progress or not.

Can you post a screenshot of your rule at this point please?

2 Likes

If you haven't already done this, I suggest starting with a rule that plays an MP3 whenever a door opens, not dependent on mode. Then, you know that your commands for playing the MP3 work correctly and can focus on the if-then-else issues.

6 Likes

I'm not using a PC at the moment so a screenshot of this rule from my phone would actually take two screenshots to show it in its entirety. Another thing I don't like about hobitat is that it's very difficult to navigate the controls with a smartphone. We've had these things for over a decade now so why do I have to fire up my PC to do anything with hubitat? When I tap on a menu it should drop down and show me the options regardless of which device I'm using.

I just had to give a like to the post and a shout out to ya for the sake of "the ole days" :rofl:

Besides learning "what's where" and "what to use for what", I think what's frustrating is the impetus one has to jump in and make things work only to learn the flexibility of the system is daunting and finding the best "how to" examples requires some searching. These combine to raise the fear factor of building something that is going to bite you in the rear later.... (because you didn't know better or didn't find the best example)... and then you'll be forced to do it all over again some day.

But as some of the folks in here constantly suggest....Keep It Simple and with time your knowledge base will catch up with your build objectives.

Still on that learning curve and letting my trust build with each and every new device and application use.

1 Like

Besides the above advice, I'd consider looking at whether this command actually works on your devices. Go to the device page in the admin UI ("Devices" from the left-side menu, then click/tap into the upstairs or downstairs speaker page, it appears), then try the exact URL from your rule in the "Play Track" command button on the device--paste it into the "Track URI" parameter field, then hit the "Play Track" button to run the command with that parameter. This is a way to test this command directly on your device, leaving Rule Machine out of the picture.

I suggest these because if it doesn't work here, it won't work in RM, either. Alternatively, you could try a different action in RM, like notification to your phone or a "Log" action, so you can test the flow of the rule while using a more reliable action and without (for now) worrying about the speech/music device.

Finally, I should mention that Rule Machine is tempting for a lot of automations but not necessary for many. Hubitat has lots of built-in apps designed for specific purposes, which you can use without the effort of creating a Rule (which indeed does require some learning, example-seeing, and documentation-reading .... you'll get the hang of it!). In this case, the built-in Notifications app looks like it could handle your automation if you set one up something like this:

(This setup can be a bit confusing--the URL is what it wants for "Track Name" when you choose your Music Player device.) But again, if your device doesn't work with this command, no app--RM or otherwise--will, either, so that's worth checking out first regardless.

3 Likes

How are you supposed to RTFM when there is almost nothing to read? If you ask me hubitat is flying by the seat of their pants and assuming too much. When I placed my order I expected a manual to come with the hub. Instead I'm expected to search for my answers on a poorly-written website written by somebody who assumes they are writing for an audience that has a college degree in computer science. Somebody needs to write something that the average Joe can understand. I'm seriously considering demanding a refund.

What documentation? Have you seen the documentation for rule machine? You have to be a software engineer to understand it. It glosses over things that are important to people who don't have programming experience. Hubitat needs to hire a teacher to write their documentation like a textbook instead of the unintelligible garbage that it is.

What documentation are you looking at? FWIW, I find this forum post more helpful than the formal Rule 4.0 docs, even though they are the same thing. (Another confusing thing is that you might be tempted to look for the "Rule Machine" docs, but that is for the parent app and not of much interest if you are using it as most people do to create "child" Rule instances, besides the fact that the parent documentation explains platform concepts like "events" that you'll need to understand at some level.) The inline screenshots--and further comments from other users--make it more helpful, in my opinion:

There are also several example rules on the forum, including this thread:

Finally, asking for help--exactly as you did--is always a good thing. :slight_smile: Hubitat can indeed take some getting used to (apps vs. devices, "what are events?", and so on) and Rules are hard to write until you do. The collection of built-in apps would be my first recommendation--it's tempting to write a Rule for a lot of things, but you don't often need to. The Community is full of people willing to help regardless.

3 Likes