Not completely sure what your question is, but check
itemState(itemname, [ignoreTransform]): retrieves the state of an item by its name; ignoreTransform (optional, false by default) will return the raw state (e.g. ‘CLOSED’) instead of the transformed state (‘zu’);