Script throws exception on openHAB startup, sometimes

Your log looks to have rules loading before the Items are ready. I suggest scrapping the clunky old rules DSL and using scripted automation with Jython and the helper libraries, where you will not have this issue. If you want to stay with the rules DSL, then you should setup a way to delay the rules from loading.