running OH4.2.2-releas on openHABian.
I’d like to check if the change to an item is “ON” or not with this code:
configuration: {}
triggers:
- id: "1"
configuration:
groupName: PL12Homeserver
type: core.GroupStateChangeTrigger
- id: "3"
configuration:
cronExpression: 0 0 0/6 * * ? *
type: timer.GenericCronTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
script: >
if(event.itemName != undefined) {
// Trigger was itemChange
console.info("DEBUG: Docker item " + event.itemName + " hat Status " + event.itemState + " und alten Status " + event.oldItemState);
if (event.itemState == "ON") {
console.info("State is ON");
} else {
console.info("State is not ON");
}
}
type: script.ScriptAction
But regardless the state, it’s always in the else
part?
2024-11-14 11:29:38.434 [INFO ] [utomation.script.ui.MonitoringDocker] - DEBUG: Docker item HSRV_GrafanaOnline hat Status ON und alten Status OFF
2024-11-14 11:29:38.435 [WARN ] [utomation.script.ui.MonitoringDocker] - State is not ON