I’m looking at this code and can’t help but think it’s an XY Problem.
Why are you storing the Item and the String representation of it’s state to an ArrayList? Especially when you already have a list of those Items in a Group?
Why are you using an ArrayList instead of a HashMap using the Item name as the key?
Some additional problems you may encounter is that the Item Object you get for a given Item on one run of the Rule may not be the same Object that you get for the same Object later. As a result, the Item you’ve stored in your ArrayList may become disconnected from the event bus so your sendCommand or postUpdate calls may not work. It’s better to store the Item’s name in this case instead of the Item itself. When using a Map, it’s critical to not use the Item itself as the key.
Why are you storing the Item and the String representation of it’s state to an ArrayList? Especially when you already have a list of those Items in a Group?
because i need the state at the time the rule was performed
Why are you using an ArrayList instead of a HashMap using the Item name as the key?
i tried also hashmaps but got the same problem
Why are you not using storeStates and restoreStates which are Actions created for this purpose? Actions | openHAB
Why not use persistence and previousState to store the value and get it back later? Persistence | openHAB
i didn’t know this funktions
but overall i fixed my funktion with the info from the first comment:
var data = newArrayList()
data = oldstateheater.get(i)
logInfo("heater.rules", data.get(0))
but for now i will change my code to use the new functions