Skip to content

Automation Rules

inhies edited this page Dec 21, 2016 · 2 revisions

Overall Design

I would LOVE to be able to write automation rules in Go, but I'm not sure that will be practical or possible. Plugins will be great once they get here but they have a huge memory footprint. Perhaps if all the automation rules were placed in a single plugin it would be doable though... In the meantime, maybe a javascript interpreter will suffice?

Custom language for rules?

Given that everything in Casa is backed by MQTT, perhaps it would make sense to have a custom language for writing automation rule scripts in because it wouldn't have to do too much. For simple rules it just needs to read from an MQTT topic and do something when it happens, which would be accomplished by publishing to another MQTT topic.

Triggers

github.com/oleksandr/conditions has rules like this which look like they'd work well for automation triggers:

($0 > 0.45) AND ($1 == `ON` OR $2 == \"ACTIVE\") AND $3 == false

I'd like to expand that to work with MQTT topics natively:

(`Hue/Light1/Color Name` == "Red") && (`Hue/Light1/State` == "On")

Until a proper lexer and parser is written to handle the above rules, I've implemented similar functionality in the rules package. It allows the rule to receive messages for specific topics, and then it can evaluate the rules and publish a MQTT message if it needs to. Note that this package, in its current form, is most likely temporary and will see heavy changes when plugin support for Go is released for all platforms.

Rules

UI Thoughts

  • Maybe we could do like the vera does where it just gives you a screen with every device in the system on it, and you just set the ones you want the rule to affect to the desired state. For example you would turn on a light, or tell the front door to lock, etc.

Clone this wiki locally