# Can Rule Machine do this

I am very new to this (hub arrived today so only hours into it).
My plan is to get my custom blinds that use a servo motor and an esp8266 (currently working using Blynk) uploaded with Hubuino so I can change them in Hubitat.

Now I am only up to the stage of playing around with the hubitat itself and been looking through Rule Machine which doesn't appear as flexible as I hoped... but its early days so hopefully I am wrong.. I have looked at Webcore and that seems more capable but understand that it isn't advised by the Hubitat people to use it...

So, if I wanted to change the angle of my servo motor relative to sunrise would this be possible in Rule Machine?

Assume all time is in hours for simplicity.

If (currenttime > sunrise) AND (currenttime < sunrise + 5h)
Angle of Servo = (currenttime - sunrise) * 15 +90
Else
Angle of Servo = 90
end if

So when currenttime = surnise the angle is 90, after 5 hours it is 165 degrees (almost vertical) as the sun passes over, then fully opens again to let maximum light in. This allows maximum light through depending on where the sun is. I have this working in arduino ide but I want to move all control of the esp8266 into hubitat (using hubduino coding)

Rule Machine is incredibly capable these days. It just requires a different mindset versus webCoRE which is really an interpreted programming language on top of another interpreted programming language. Thus webCoRE is a bit of a beast!

I believe Rule Machine can handle your requirement, with a simple Trigger at Sunrise. Then have an Action that sets the Servo angle = 90 (may need to store this value in a variable). Then add a repeating action every 15 minutes that increases the angle by 15 degrees (add 15 to the variable and set the servo angle = to the variable.) End the repeat after 20 iterations.

I am not at home so no way to mock this up. I am betting @bravenel or one of the many skilled RM community members can whip up an example fairly quickly.

Hopefully the HubDuino side of your project is making sense. Please let me know if you have any questions.

1 Like

Great. Thanks for helping. Looks like I might be floating ideas around this forum prior to coding for a while to train my head into rule machine.

Yes that is a different mindset than I was thinking and believe that will work well.. Still some learning to be done to execute that but the theory sounds clear.

I just got myself into Hubitat also. I came from Openhab and Home assistent. But what really helps me is to make a virtual device for everything I plan on using in the future and then make rules for those devices and play around with that and see what happens in the logs. The easy thing about it is that it's all on your screen and you can very easily get every possible outcome of every way you create your rule. Good luck and welcome!

1 Like

I've also only got a dashboard of virtual switches. I plan on one of them triggering the servo for my Venetian blinds (plus add the follow sun angles) and also trigger ifttt to open /close my pulse automate commercial roller blinds (only supports ifttt but I have this working).

One thing I am toying with is to have a slider to trigger instead. At 0 to 10% all blinds will be shut, from 10 to 90% the privacy blinds and the angles of Venetian will be partly open at a set angle, then at 90 to 100% blinds will be open as much as possible with the Venetians following the sun angle as per this thread plus the Blockout roller blinds up.

I sort of wish there were multi step sliders or multi position switchescto have 3 steps. Seems switches are boolean and sliders are fixed to 100 steps... But maybe I am wrong here.

Seems all this is achievable which I hope to get running today if the family gives me a few hours to get my head around it.

Isn't it easier to use 0% / 1-99% / 100%?
Because swiping all the way to the left or the right is never hard to do. Then you can use the values in between to calculate to a value that suits the Venetian blinds.

1 Like

I really only want 3 selected angles though but I see your point. That way anywhere mid range of the slider opens them to the predefined angle that is somewhat private for the whole day. Rather than having to fine tune the slider to the right angle for privacy it just goes there.

That way I have fully closed, partly open but still somewhat private, and fully open (at 90 degrees unless between sunrise and 11am where it chases the sun until it goes over the awning)..

Now that I think of it you could also use a virtual button in which you can choose how many buttons it has. But on a dashboard that would just result in three separate buttons. So that would be up to you.

There is a preset open (on) and off (closed) in the device. So, there are two presets right there.

So I have created in rule machine that triggers at sunrise and sets a global variable to 1 that allows the attached code to enter the first step of the conditional loop. Otherwise every 15 minutes the code below will enter and just leave due to the sunrisetrigger value.

I think it should work... but time will tell.

WHAT THE.....???? Dude, why are you going through all that trouble? I showed you exactly what command you had to use to fade over time. You can fade of 5 hours if you want. Did you even look at it?

I guess I got carried away. I read about the transition but as my mind set was already on rule machine I missed the easy option.. I did read it, and even user it for when I initially open the blinds to make them quieter = Woops. Oh well was a good learning experience I guess.

We call that the Rube Goldberg method of engineering.

Turns out I think I got lucky..

As I don't always have the blinds open at sunrise, having the angle for full sunlight (chasesunangle) calculating even when the blinds are still shut works well.

If I went with the transition time then it would only start changing the angle when I chose to open the blinds fully... I think.

However.... At the time of me not thinking, the transition time would have made sense.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.