Need help with automation

Hello everyone hopefully i put this post in the correct area. I was unsure where it would fit best.

Im trying to do a simple automation and i really need some help . I had made a virtual contact sensor within hubitat. im trying to use when energy meter as the trigger when engery goes above xx watts put the virtual contact to open when engery falls below xx watts put virtual contact to closed. I tired doing this in rule machine but i failed horribly.

My goal

So i have the virtual contact sensor in amazon alexa when the contact sensor is closed alexa will play an announcement. I have the alexa part done i just need the hubitat automation.

Any help would be great thanks

OK, so this is what I have if will open the sensor but then close it right away


There are a couple of different ways you could set this up. Ultimately, it depends if you want one rule or two. Personally, I would use two rules and it would look something like this:

Rule 1
Required Expression:
Private Boolean is True

Trigger:
Energy is above XX Watt

Actions:
Set Private Boolean of this rule to False
Set Private Boolean of 2nd rule to True
Set Virtual Contact to Open

Rule 2
Required Expression:
Private Boolean is True

Trigger
Energy Watt is below XX

Action
Set Private Boolean of this rule to False
Set Private Boolean of Rule 1 to True
Set Virtual Contact to closed

The Private Boolean is used so that your rule only runs once rather than every time you get a Watt reading above or below your desired amount.

1 Like

That makes sense by looking at your triggers. The contact opens if the power level increases by over 280. The contact closes if the power level is greater than 8. 280 is greater than 8. I think the contact closing should be less than 8?

Yes for some reason when i start the dryer it goes to open then it immediately goes to closed . However there is no way the watts could be less then 8 . So im confused

I would try using just your 1st rule and add a wait for event. After that add open contact when dryer reports less than 1.

1 Like

Sorry im so new at rule machine , no idea what alot of this means .

That's not what your trigger says. The trigger is saying the Watt value is > than 8. You need to switch it around so that the trigger is Watt value is < 8.

1 Like

OMG i feel so stupid :sob: :laughing:

That worked .. now its working fine thank you !!!

1 Like

We have all been there! @Johnnyvaneddie has a good idea as well.
Required Expression
Private Boolean is True

Trigger
Power Level is greater than 8

Action
Set Private Boolean to False
Set Virtual Contact to Open
Wait for Event: Power Level is less than 8
Set Virtual Contact to Close
Set Private Boolean to True

A Private Boolean is just a simple variable (true/false) that is unique to each rule. A lot of folks will utilize it as a way of making sure a rule only runs once until complete. Basically, every time you get an energy reading, your rule will be evaluated. If you want it to only run once, a Private Boolean is a way of limiting it.

1 Like

Hey Jb thanks for helping . I did figure it out, i stayed with my original rules and flipped the > to a < which fixed it .

Thanks everyone i got it working now . And a special thanks to @JB10

1 Like

Thanks @JB10 The reason I gave my idea was I don't understand booleans either

2 Likes

So in RM for all the comparison what exactly do they all mean

more then

< less then

=

= with line

<=

=

In

changed

increased

decreased

increased by over

If you are new to RM, maybe check out Webcore as well, since you are not yet deep into RM.

It would be a simple rule in Webcore, as there are options for this scenario where you do not have to keep track of anything:

You probably just need rises above and drops below with two simple rules. You would put both rules in a "piston" and name the piston.



1 Like

Thank you ill try it out

@JB10 so im trying to do the same thing with the washer , however the washer will sit for 45 seconds or so at 1 watt . So i need to have a rule that says if washer drops to under 3 watts and stays there for 2 minutes then close virtual contacts . Would you mind explaining how to write that rule in RM

Sure. You could use a Wait as the first action before checking the value again. So, something like:

Action
Wait for Event - Elapsed Time of 2 minutes
Simple Conditional - If Watt is below X value, set Virtual Contact to closed

Basically, the Wait will just count the time. The Simple Conditional will check to see if it is true, and if it is, set the contact as you want.

Looking at what you are trying to do, I would make a recommendation:

Unless you are just trying to learn how rule machine works, install Hubitat Package Manager: [BETA] Hubitat Package Manager

Then use that to install "Better Laundry Monitor"


(The thread for that app is here: Better Laundry Monitor Port & Update - #2 by csteele)

It already has most, if not all of the options you are trying to create in rules

The other added bonus from installing package manager will be the ability to find and install other usefull apps.

Not to disuade you from playing with Rule Machine, especially if you are just trying to feel it out and learn it. But, if you want the switches on, etc, with a lot of the logic already figured out, the app has already debugged most of the isses.

1 Like

Hey thanks for the suggestion.However i'm already using better laundry .

Im using RM for a virtual contact sensor that i have in alexa routines then the sensor closes alexa makes an announcement on all my amazon echos throughout the house . Unfortunately better laundry couldnt do these automations