OH3 Wow! - Migrate or start over?

I’m using the browser for Rules and VSCode or vim for libraries.

I don’t know much about efficient but this works for me.

  • If I have to figure out how to do something (e.g. call a new Action, call another rule, etc) I’ll create a new Script (right under Rules in the settings in MainUI) and experiment with that until I figure out how to do it. Once I do figure it out, I keep the Script for reference and transfer that to the Rule I’m working on. From there I’ll move the code to a library (see OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules) or just copy and paste it into a new rule when I need to do that again.

  • When building a Rule I’ll do so in the browser. I’ll start building the logic little by little. Most of my rules are pretty short so this doesn’t take long. I have lots of logging and I run the rule manually with the play button frequently. If I can tell what’s going on from Item events, I’ll have the Event Stream open in the Developers Sidebar with filters so I only see the events I care about. In addition, I may have multitail up in a terminal following openhab.log.

  • There are some cases where I may need to trigger the rule with an Item (e.g. I need access to event.oldState). In that case, I’ll pin the Items I care about in the Developer’s Sidebar. If it’s not a read only Item, I will be able to command the Item from there.

image

For other Items, I may go and add a custom default card widget to the Item (that’s what gets displayed in the Developer Sidebar) so I can command it. Or if I just need something quickly and/or I don’t want to change the default widget for this, I’ll open the Scratchpad Script (created and easily accessible from the Developer Sidebar) in another tab and sendCommands or postUpdates from the scratchpad.

  • Sometimes I’ll be writing a rule that has to deal with a certain set of Items. In those cases I’ll pin all those Items to the Developer Sidebar so I can easily look at them to get names, current states, etc.

I think that’s it for my tips and tricks.

Note, if you install the Python add-on, you can use Python in MainUI Scripts. Any language you can write text based rules can be used in MainUI for Script Actions and Script Conditions.

1 Like