Rich and I have always been on the path to try to make it as fail safe as possible during design and implementation but there is some limit to do so.
Instead of complaining I would rather ask ourselves, how we can improve it? What would one expect the blocks to behave like?
So would a block help with which it is possible to check if key has already been set at all?
I have implemented the following block for you which would be available from 3.3 M1
The result in this case is “firstValue”.
Note the following
- The values are persisted as a part of the instance of the rule
- Modifying the rule during development creates a new instance which means the value is reset.
- Restarting openHAB creates a new rule instance which also means the value is reset
- In most cases both situations are negligible for many rules.
Does that help?
I have also written the section about that in the Blockly Reference. Do you mind checking that section if it is clear and comprehensive enough?