Hi,
im searching the documentation and the community for a hint how to specify a condition like a trigger in JavaScript/ECMAScript 262 Edition 11.
How would be the syntax to use the numericState of the Item (victron_output_potential) as condition for the rule?
In more complex examples i would like to spare some if clauses.
Thanks for help
rules.JSRule({
name: "BatterieUndervoltage",
description: "Batterie Undervoltage",
id: "BatterieUndervoltage",
tags: ["Solar"],
triggers: [triggers.ItemStateChangeTrigger("victron_output_potential")],
//conditions: [conditions.ItemStateCondition()],
execute: (event) => {
var systemvoltage =items.getItem("victron_output_potential").numericState;
if (systemvoltage <= 39.0 & items.getItem("dpm_setOutput").state=="ON")
{
items.getItem("dpm_setOutput").sendCommand("OFF");
}
}
});
- Platform information:
- Hardware: Intel i-3-9350KF / x64 /64GB DDR4 ECC/990Evo ZFS Mirror
- OS: Proxmox 8.3.5
- Virtual Hardware: 4Cores / x64 / 8GB / 64GB scsi
- Virtual OS: Debian 12.8
- Java Runtime Environment: Zulu17.56+15-CA
- openHAB version: 4.3.3 Release Build