Closed wawa79 closed 3 years ago
If this was a bug, which I do not believe it to be, it should not be reported in the Jython helper libraries but openhab-core. The forum would be the best place to discuss this, where it's been discussed before.
event.itemState is reporting the state that the Item was updated to, which can be PercentType, UpDiownType, or UnDefTyoe. When reading the state of the Item, you will need to specify the format that you'd like it in or accept the type that you get. To specify PercentType, then you need to ask for it with...
event.itemState.as(PercentType)
You can also request UpDownType...
event.itemState.as(UpDownType)
... but be careful, since you will get None if the value is not 0 or 100. Read through this... https://www.openhab.org/docs/concepts/items.html#a-note-on-items-which-accept-multiple-state-data-types.
Describe the bug Within a rule triggered by an update of a Rollershutter item, event.ItemState does not report the state of the item (0-100 number) but the command sent to the item (UP DOWN).
To Reproduce
Define a Rollershutter item named MyRollershutter
Rollershutter MyRollershutter "Test rollershutter"
Create the following Jython script
@rule("bug_itemState", description=u"Bug for itemState with Rollershutter item", tags=[]) @when("Item MyRollershutter received update") def bug_itemState(event): bug_itemState.log.debug("Item state: {}={} {}".format(event.itemName, event.itemState.toString(), ir.getItem(event.itemName).state.toString()))