I want to develop my rules on a local instance of openhab (currently just running it out of the IDE with my productive config that is synced via a git repo). That works nice in general, the only problem I currently have are Items that are linked to channels.
As the code should be the same as on my productive system, I would need to use the correct Items. If those are linked to a channel it may happen that I’m accidentially switching things.
Is there a possibility to use different items files, where I can have my “Mock Items” in one and the real ones in another file without having to rename or copy them around manually?
Any ideas how this could be solved?
I am (occasionally) doing something similar. The key is to have separate machines (could be virtual machines) running your production system and your test system.
With this setup in place, it is simply a matter of not installing bindings on the test system to avoid disturbing your production system.
On your test system you can then use the REST API to stimulate and monitor your code. In this way you can actually build complete test scenarios to test your rule logic.
Thanks for the hint … sounds like a plan … I thought the processing of the input would break if an item is linked to binding that is not present … soll i’ll go down that road then.
Sounds like an awesome approach to setting up a test harness to fully exercise your system in an automated fashion. You can make a REST call to change an Item, wait a second or so, then check that the right Items were changed after wards to the expected values.
Exactly! That’s why I spent some time on this concept a while ago. To make things simpler (and because I am quite a fan of the Python language) I wrote a simple Python wrapper for sending commands, checking states, etc. around the REST API. With this in place I could use the Pyhton ‘unittest’ module to write test cases.
With a few ‘waits’ thrown in here and there, to allow openHAB to process commands, this actually worked fairly well. Sadly, my focus has been elsewhere lately so my test bed and set of test cases have not been maintained…
Have you played with the JSR223 Rules at all? It would let you write your rules in Jython in the first place.