DSL Anyone? #296
Unanswered
qui3xote
asked this question in
Show and tell
DSL Anyone?
#296
Replies: 1 comment 3 replies
-
Wow - that's impressive. Thanks for sharing! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After moving a few automations over to pyscript, I got inspired to try and simplify the process of writing automations even further. YAML (IMO) stinks for the job and while I love PyScript, it seems like overkill for most home automation jobs. So I got inspired to write a domain specific language (which I call OttoScript) on top of PyScript. OttoScript abstracts away nearly all of the technical details of working with HomeAssistant in favor of a simple, declarative language with minimal syntax rules (though lots of grammatical constraints). I've just published v0.1 and I've moved several of my simpler automations over to it and have been running for several days - so far, I'm quite pleased with it, and now that it's up and running, adding new features is proving to be pretty easy.
Here's a simple (albeit silly) example script that demonstrates many of the working features:
The capitalization of keywords, line breaks and indentation are all purely optional (like SQL).
While the set of supported commands is small right now, OttoScript is quite extensible and it should very easy to add more. I also intend to add more conditionals (like a CASE statement and ELSE support) and the ability to nest them, which will require a bit more work, but doesn't seem too bad at all. I would love feedback and contributions from this community if anyone is interested!
Installation requires cloning two repositories - the OttoScript parser and the Pyscript App. The limitations of PyScript would've made writing it as a fully native app very cumbersome, so I chose to build most of it as a separate python library, and then a thin 'interpreter' that is passed to the library for callback functions.
EDIT: typo
Beta Was this translation helpful? Give feedback.
All reactions