Domotest – A Lua rock to aid testing Domoticz event scripts

Home Automation with Domoticz + Test Driven Development of event scripts? Sure, why not…

I’ve recently been exploring home automation, which deserves it’s own post (note to self: must write that), using Domoticz as the central controller.

Custom events can be created in Domoticz, in the form of either Blockly or Lua scripts. These events can range from something simple like “turn on the outdoor security light at nighttime” to something a lot more complex like controlling ventilation based on humidity.

As a software developer I enjoy the feeling of security when I have a good set of unit tests. This got me thinking that it would be useful to be able to test the Lua scripts that I create for my home automation system. That way I could test the scripts quickly, and without the actual hardware, and rest easy knowing that any changes I might make will be covered by the tests, rather than waiting to find that the lights don’t turn on when they should!

That’s where Domotest comes in, it’s a very small library (at less than 35 lines I don’t even think it counts as a library) that hides a lot of the boilerplate required to get standard Domoticz-compatible Lua scripts loaded into a test environment such as Busted.

That sounds great! How do I use it?

It’s fairly straightforward, firstly install it with Luarocks:

Then require it in to your test file(s) and run the domotest function.

Check out the repository on GitHub for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *