Help, I'm ready to give up

There are ways to deal with this sort of thing:

  1. Use Designer to catch syntax errors for you
  2. Use persistence with restoreOnStartup to avoid the NULLs
  3. Make use of the ? operator for a quick test for null
if(timers.get("foo") != null) timers.get("foo").cancel

can be replaced with

timers.get("foo")?.cancel
  1. Make use of Groups
  2. be aware that OH 2 is a lot better at handling casts for your so you rarely need to do something like if(MyItem.state as DecimalType > 20) any longer.

With the above I find I have no more tests than I do in any other not strongly typed language such as Python or JavaScript.

2 Likes