Setting item from null to any number doesn't work

So, I have an item of type Number and it is unitialized. I want to set it to some number, but it’s just not sticking. At this point, I have tried everything I can think of and the item’s state insists on staying uninitialized.

Basically, the following inside a rule does nothing:

var Number counter
counter = 5
testiCount.postUpdate(counter)
testiCount.sendCommand(counter)
testiCount.postUpdate(5)
testiCount.sendCommand(5)
testiCount.postUpdate("5")
testiCount.sendCommand("5")
counter = testiCount.state

I know the rule itself is triggering, I have a line to log it in there. There are no errors in the log or anything, it’s just that nothing happens!

There’s only four things that can happen with that line.

It’s not executed, because your rule does not run, is not loaded,or fails with an error before it gets to that line.
See your openhab.log to eliminate some of those possibilities.

The Item does not exist. See your openhab.log for a report of that.

The command is unsuitable for that Item. See your events.log for a report of that.

It works - should be in events.log
“works” for a command does not guarantee a state change, but let’s go one step at a time.

As stated, none of those things report any error in the log. Also, as stated, the rule does run. The item also does exist, as can be verified by e.g. adding it to my sitemap – something that I did. Also, in the event-log it does state the item received a command.

With all the above in mind, nothing changes; item’s state remains uninitialized.

That’s an important clue, thankyou for revealing it.

So … what is the Item’s state?
You can log it out in your rule.
logInfo("test", "State " + testiCount.state.toString)

I should have pointed out before that you don’t get events.log entries for successful updates to the same state.