Rule Machine - Get peer assistance here with setting up rules

@mrmrmrmr
If you know how to get the weather data that you want and are able to do something with it outside of Rule Machine, and if the subset of possible weather condition states is reasonably small, you may be able to do something with virtual switches.

e.g. If you know that you have 16 possible weather states (sunny, partly sunny, mostly sunny, cloudy, partly cloudy, mostly cloudy, clear (night), raining, sleeting, snowing, hailing, foggy, windy, t-storms, showers, other?), you could create 16 virtual switches, and name them accordingly for the naming convention in your HA environment.

This grouping of virtual switches will act as an input mechanism for getting weather data inside of Rule Machine. When the state changes, turn the virtual switch for the associated state to ON.

Then, configure rules in Rule Machine to monitor the ON/OFF state of the virtual switches (i.e. Rule Machine doesn’t care that the switch is just a switch. You, the user, know what state each virtual switch represents, and you’re the one making the rules), and do things based on those switch ON/OFF states; like your light bulb color changing scenario.

I know it leads to having bunches of virtual switches in your device list (especially if you use this same technique for other types of automations), but so what?

Pay no attention to the man behind the curtain. :slight_smile:

p.s. I assume the moment I post this, somebody will probably show why my idea sucks :slight_smile: and will give us a real solution, but in the meantime, I think this is at least feasible.

1 Like

I’ve solved my problem directly adding the color change function to weather forecast application.

But I am still interested in virtual switches and going to a solution with rule machine.
How can I create those virtual switches ?

I’d like to expand on this rule.

Turn on a light switch at sunset and keep it on until 10pm. If the TV is drawing power at 10pm leave the light switch on, otherwise turn it off. If the light switch stays on after 10pm because the TV is drawing power, turn off the light switch 10 minutes after the TV stops drawing power.

If the light switch is off after 10pm and a motion sensor deactivates motion turn the light switch on for 10 minutes. If during that 10 minutes the TV starts to draw power then leave the light on until the TV stops drawing power and then turn the light switch off 10 minutes later.

Thanks for looking into this,

This is in a bathroom and I do not have access to my echo in there, or a minimote unfortunately.

I am just using the GE dimmer from clamshell packaging without a neutral. The motion sensor is the Iris centrelite 2, and I believe the timeout is 1 minute. I’ve already gone ahead a created that virtual switch, I’m just unsure what to do with it.

Here is my current rule (I realize I could have written it a little more efficient but it was getting the job done)

Ok, I use several if these dimmers as well and they are very much a pain because of the lack of a neutral. They can sometimes take several minutes, if ever, to report to the hub what the current status is.

But. I know how to work around this and get as close as possible to what you want.

I have some questions:

  1. during the hours of this rule, how long are you normally keeping the light at a different level than the rule?
  2. I noticed in the rule there is not a turn off, do you physically turn off the light when you leave?

@mrmrmrmr
I have to take off for a while, but I think this may be the thread you need for learning how to create a virtual switch…

If you’ve poked around in the IDE at all yet, this will be super-easy.

If not, you’ll need to create an account here…
http://docs.smartthings.com/en/latest/getting-started/up-and-running.html#register

Then go log in here…
https://graph.api.smartthings.com/login/auth

Then follow the instructions in the first link.

Let me know how it goes…

1 Like

I’d say around 20 minutes and yeah we usually just turn them off manually in this time frame.

Ok. I’ll set this up for you. I’ll post detailed directions on how to set it up. It’s going to be a couple of hours, I’m on the interstate traveling right now.

No problem! I appreciate it!

I’m looking at a rule where, when a presence sensor arrives the hall light is switched on, if off. Then it stays on for a given period of time and then switches back off. If the light is already on then it stays on.

I’ve worked out the delayed off for when a light is motion activated, as when motion stops you can delay the ‘off’. However i can’t work out how to do this for when the presence has ‘arrived’

Create a conditional trigger.

Trigger - sensor arrives
Conditions - hall light off
Actions for true - turn on light, pending off
Actions for false - leave blank

1 Like

Thanks, I was unaware you could select 2 parameters in the ‘control switches, capture/restore’ section.

So i select the switch in the ‘turn on these switches’ at the top, then the delay and off is in the section 'Turn on or off these switches after a delay, pending cancellation(default is off). Is my understanding correct?

Yes, you are correct. And you can have multiple triggers, such as several presence sensors. Or, lights on, time of day, day of the week…

The same goes for the actions as well… Both true and false…

A rule can get very complex.

1 Like

Thanks fro your help, its going to take a while to get my head round all this!

1 Like

Ok, I’ve got this written up and tested. It works great.
I tested it using a GE dimmer with no neutral and an Iris centralite motion sensor, both the same as yours.

  • All of this is done in rule machine.
  • I set this up like this due to the nature of the GE dimmer, they are unpredictable on their response times. So, there are a couple of levels of redundancy built in. It can be done simpler, but this way is going to be reliable.

Step one -
Create a custom command in rule machine. The custom command is refresh().
Follow this link for directions on setup:
Oh you have trouble, ask here and we will walk you through it.

Step two: create this rule
Master Bath Dimmer 1
Conditions - private Boolean is false, dimmer level <=1, switch is off, time between 12-5 am.
Rule - private Boolean is false and time between 12-5 am AND (dimmer level <=1 or switch is off) this is a complex rule, choose the slider for complex rule, choose the PB option, choose AND, choose input subrule for right, choose options, choose end subrule)
Actions for true - dim: light to 10%
Actions for false - leave blank

It should look a lot like this -

Step : Create this rule -
Master bath dimmer 2
Conditions - motion sensor active
Rule - motion sensor active
Actions for true - rule Boolean: master bath dimmer 1 - true, command: refresh() on your GE dimmer switch
Actions for false: rule Boolean: master bath dimmer 1 - false, command: refresh() on your GE dimmer switch

It should look like this -

If you have questions or get stuck, let me know.

[quote=“mrmrmrmr, post:657, topic:29577, full:true”]
…weather forecast application…[/quote]

@mrmrmrmr
Which app is that? Is this a SmartApp that you’re talking about?
If so, any chance you could post a link to it?

Wow, I dont think I would ever have figured that one out. Thank you very much. I believe Ive got everything setup, took me awhile until I figured out I needed to update rule machine. I couldn’t figure out the Boolean thing for the life of me until then.

You can test it by removing the time settings in the rule.

Let me know how it works out for you.

I am running into a problem where the lights immediately turn back on to 10% after they are turned off manually with the dimmer. For some reason they seem to stay off if I turn them off from the app. It almost seems as if it’s detecting motion to fast or something. Other than that everything seems to be working really well.
Here it is in case I missed something


Ok, I think I know what’s going on.

Is the light switch in the detection range of the motion sensor?

If yes, that is the problem. You turn the lights off and then the motion sensor is detecting you.
It refreshes the dimmer, sees that it is off, and then sets them to 10%

One thing that can be done is to add a “Turn off these switches after a delay, pending cancellation”

I think the best thing to do is to add in a turn off command to the rule. This will allow you to walk out of the room and the lights will turn themselves off.

In Rule #1 (master bath 1) do this:

Goto "Actions for true --> Control Switches, Capture/Restore --> Turn on or off these switches after a dely, pending cancellation.

Choose the bathroom dimmer, tap done.
Look right below that section and you will see a red line below "Minutes of delay"
I would give it a 2.

Tap done, done, done… or how ever many times.

Then test it.

I’m going to work on this some more, but this workaround should do what you need for now.

Please confirm if the dimmer is the sensors detection zone.

Thanks.