Weird behaviour of a very simple rule

So, I made a simple rule to turn on a led when the boiler turns on

rule "led caldaia"
when Item Relaiscaldaia changed
then
    ledrelaycaldaia.sendCommand(Relaiscaldaia.state)
end

It worked.

I restarted openhab and the rule wasn’t working anymore giving me this error

2023-11-26 06:14:07.692 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'heating-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null in heating

Now, I solved with a follow profile (which I should have used from the very beginning) and I’m not going to change this, but I’m struggling to understand what was wrong with the rule and why it was working in the beginning and why it stopped working.

Any clue?
Thanks for your time on such a stupid question.

I think at restart the item Relaiscaldaia is initiated with ‘null’. → changed to null.
the rule want to send null to your second item… That doesn’t work.
if the item Relaiscaldaia changes to a ‘real’ value the rule is working again.
Greets

That’s not the case as I manually operated Relaiscaldaia from on to off several times, so it wasn’t null

Thanks for your answer thou.

Read the error message:

The instance that the method should be invoked on is
ledrelaycaldaia. Is it correctly spelled? Any issue with upper/lower case?

Why it worked before restart I don’t know. Perhaps you changed something on the item before the restart?

What time of Items are these?

Add some logging so you know what state both items are in when it fails.