Rule Machine

Is there a book, anything that can help to understand how to create rules. I don't even know what a private boolean, true and false I really don't get when to use it.

I would start here:
http://docs.hubitat.com/index.php?title=Rule_Machine

There's also a page specific to RM 4.0.

https://docs.hubitat.com/index.php?title=Rule-4.0

Other than that, I would read as much as you can here on the forum.

In addition to the above, I would also see if what you want to do is already possible with a built-in app. Rule Machine is powerful, but the stock apps have a lot of options, too, and they're a lot easier to set up. (This is especially true if you're new to the platform and haven't seen how "normal" apps work yet, which I'm not saying applies to you, but it's worth knowing for anyone.)

tried to create this rule but it's not working

First of all, you can't have a condition of a specific time. It is only exactly 5am fror 1 ms and rule machine is not that fast. So, the first thing you have to do is start putting times as ranges.

Second You have the second if nested under the first. it cannot, by definition, ever be 1am and 5am at the same time. So, the second If will never, ever be true.

But ultimately, what are you actually trying to do? Turn a plug on at a specific time and off at a specific time? If so, I would use Simple Lighting. It's going to be a lot easier than Rule Machine for you.

Yes that's the intention for it to be off and turn on at specific time, but I lose electricity so often where I live and the switch on the plug doesn't come on auto. I want to use it to turn my refrigerator off at nights and on in the morning and also turn it back on when I lose power.

First of all, you can't have a condition of a specific time. It is only exactly 5am fror 1 ms and rule machine is not that fast. So, the first thing you have to do is start putting times as ranges.

IF (Time is 5:00 AM EST)

RM4 treats a specific time condition as a 59 second time range. This condition is true from 5:00:00 AM until 5:00:59 AM.

Why would you want to do this? Don't you want to keep your food cold at night? Refrigerators have built in thermostats which keep them at a specific temperature. If they don't need to cool, they don't run. Turning off your refrigerator on a frequent basis is usually not recommended by the manufacturer. I would be very wary of doing this.

1 Like

As noted above, I suspect this is a bad idea: most fridges don't like frequent "hard" cuts of power like this. But automating a smart plug based on time is much easier in Simple Lighting than in Rule Machine (and the former, despite its name, can be used for any type of switch/outlet/dimmer, not just lights). You can create multiple instances of this app as needed to handle multiple on/off times.

So, I'd suggest Simple Lighting for basic time-based automations like this. (It's certainly possible in RM but much more difficult and not really necessary.) But first I'd make sure the device is designed to handle it.

Thanks advice appreciated