Use an string item state as a name and state for another item

You need to get the item from your string value.

To achieve this, you need to put the sensor items in a group (gSensors) and filter the group by name. It’s close to the associated items pattern.

...
val mysensor = gSensors.members.filter[ i | i.name == ALARM2_SENSOR.state.toString ].head
if (mysensor.state.toString == ALARM2_SENSOR_STATUS.state.toString)
...

But i second @vzorglub, this complicates everything. What are you really trying to achieve?