Info: if you link that Item to a modbus data Thing with read capability … the next read poll will overwrite your “initialized” Item state anyway.
A first poll will most likely have already run before your rule, and your rule will overwrite the polled data.
At the next poll after your rule has run, the polled data will overwrite your rule data again.
It is possible to make write-only modbus data Things, if that is what you have in mind.
A tweak to your rule that only “initializes” if no polled data is available yet
rule "Startup"
when
System started
then
if ( Temp_correct.state == NULL) {
Temp_correct.postUpdate(0)
}
end
I want to initialize a String item with the following rule:
rule "Startup"
when
System started
then
remoteCommand.postUpdate("init")
end
but i get the following error message
Error during the execution of startup rule ‘Startup’: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null
I was expecting “weird” from somewhere, but not that
Okay, the problem is about the rule not that Item.
Really sure there is only one rule “startup”?
Confident your editor is saving the file to the folder?
You should see “xxx.rules loaded” message in your openhab.log at each save. No parser complaints following that?
I’d look at the preceding or following rules in the file, make sure they are structured properly and all brackets are paired.
Nothing found, try your test rule in a new file of its own. Type it in, don’t copy-paste to avoid copying invisible control characters. Remember, only one rule of name “startup” at a time,give it a new name.
Well, it’s not pixies, there is a syntax fault in your big file somewhere. Non-obvious faults can be down to invisible characters outside of regular rules, maybe your editor has an option to show them.