Closed mjcumming closed 6 months ago
I cannot reproduce this on the latest snapshot #3723
and with the openhab-js version that comes with it.
I have tested this with a file-based rule:
rules.when().item('test_switch').changed().then((e) => {
console.log(e);
}).build();
The log output is as expected:
{
"oldState": "NULL",
"newState": "ON",
"itemName": "KNX_Aktor_Licht",
"eventType": "change",
"triggerType": "ItemStateChangeTrigger",
"eventClass": "org.openhab.core.items.events.ItemStateChangedEvent",
"payload": {
"type": "OnOff",
"value": "ON",
"oldType": "UnDef",
"oldValue": "NULL"
},
"module": "90f9a354-1746-4878-9593-261196c5d34e"
}
Can you please provide information about your system (the issue templates exist for a reason, please follow them) and re-test?
Hi, sorry for the delay - I hope to get an example code block. The error is happening with the GenericEventTrigger - does something need to change in the code the builds the Event object?
Not sure what you expect when using GenericEventTrigger
, but for this special trigger the available properties heavily depend on which events it triggers.
You cannot expect to find itemName
on the event object of GenericEventTrigger if GenericEventTrigger only triggers on non-Item related events.
I will update the docs accordingly to make that clear.
Reviewing this part of rules.js
The expected properties, as per the documentation, are missing such as newState, receivedCommand, etc.
https://www.openhab.org/addons/automation/jsscripting/#event-object
It seems that _addFromHashMap is not working correctly as none of these properties are being set.