It you extended Routines to support a sequence of nested if-then-else groups, each with nested and-or condition, plus a sleep action, you’d pretty much have the current functionality of the Rules API. Actually you’d have more because Routines have access to as yet undocumented Rules.
No loops, no variables, no functions and none of the TCP/TSP/TEP cleverness.
WebCoRE pistons are effectively event handling scripts. Indeed I think webCoRE functionality would best be reproduced by writing SmartApps in a general purpose programming language, though you wouldn’t get the local execution (but you don’t have it now).
To me Rules feel more like a mesh of binary operations that are constantly being updated with the result bubbling up to the top and a ‘trigger’ just meaning that the conditional actions are activated at that point. Something like Smart Lighting on steroids. If you have ever watched the live logs for that you can see the restrictions are constantly being updated even though there haven’t been any trigger events.
That’s just how it feels to me. It is likely drivel.
So I think that I ll wait to see because I like ST but I I think that I wont be able to do nothing after the lost of groovy and the chance are that I leave to hubitat… Pretty frustrating that something that works flawlessly is being updated with something that offer no flexibility… I was thinking of a both local and cloud system where all functionallity would be there and you try to transfer all of that local through time to be able to stop the cloud… kind of desapointing!
I think that is ok and please do it. What would be more helpful is a dedicated page that says, “You used to use WebCore, this is how you use the Rules API”. This page would have all the basics to get going. A short tutorial on setting up the environment (e.g. community (very weird) CLI and VS Code and etc) and how to get your code to work in a similar manner. For example, 1_ This is how to turn on a light when a switch is turned on. 2_ This is how to make something happen when it is 22 minutes before sunset. ← maybe these would be links to examples that exist.
I have code that goes out to a URL and parses the return to then call VoiceMonkey (another external site). If you could do a sample like that; bonus.
I do not see many people that haven’t used WebCore now deciding they are going to ramp up on Lua. Maybe later.
The thing I was missing in a big way was how do I get the code into the hub but I am sure I will find other obstacles that have already been figured out but are all over the place.
There’s also a repository where there are several Rule examples just for you to copy, replace the corresponding IDs and save them.
Where there’s another tutorial using Postman (which avoids the usage of a text editor), the CLI is a tool that helps you interact with the ST API from the console, but, you can send direct commands to the API, this means you can create them from other integrations that you develop, you would only need to make the corresponding HTTP requests.
Creating an app to consume the ST API directly would help you solve your issue with the requests to the URL because currently, the Rules API doesn’t support requests to URLs.
Or, as WebCore already lets you make calls to external URLs, depending on your automation, you could send the corresponding commands to your ST devices, but, that integration would be hosted in the Cloud. For this you would only need:
Lua (Edge drivers) is for device integrations, not automations. If you create a device using the driver, you can set up certain schedules, actions that help you automate its behavior but it won’t allow you to modify the one of external devices.
I think it would benefit non developers to have a more straight forward step by step tutorial with more basic instructions than having to click link after link and getting confused. I’m sure the documentation is easy enough for people who know what all the terminology means but for those who want more powerful rules but are not developers it is just overwhelming confusing!
I’ve always preferred to use automated APIs because they are simpler and more understandable. Maybe it is not really professional, but that makes my work easier and helps me solve the tasks I was assigned faster.
Does anybody have a quick solution for doing a rules api condition of between two times? For example, I want to have the IF use BETWEEN for 5am to 30 minutes after Sunrise. I know that BETWEEN uses “VALUE”, “START” and “END” but i’m not sure how to put the TIME object in that sequence. Normally you would specify the value you want in the END and then just use a string or integer in the other two, but i’m not sure how that would work when dealing with time objects. Thoughts?
A between is testing if value is between start and end. In this case we are dealing with times and in Rules times are defined in terms of a reference and an offset. As we are interested in comparing the current time at the moment the Rule is executed the appropriate reference is Now. As an aside you could apply an offset so you could effectively say ‘ten minutes ago it was between …’ or ‘in thirty seconds time it will be between …’. It probably doesn’t gain you anything but it is fun.
You might like to keep an eye on the sunrise time if your rule runs in the cloud. For the last year I’ve had a bug with sunrise and sunset not updating daily in cloud based rules.