is it possible to use a hashmap to link items to eachother?
My use case – I want to reference my wall switch item with the relays it should control. So two use cases:
- single item mapped to another item
- single item mapped to multiple items
Any help on syntax would be great.
nevermind, it worked with my code snippet below:
val nodesKillSwitch = newHashMap(
"NODE_HB_JakesBedroom" -> NODE_DMS_JakesBedroom,
"NODE_HB_NataliesBedroom" -> NODE_DMS_NataliesBedroom
)
rule "NodeReset"
when
Time cron "0 0 9 * * ?"
then
gNodeHB.members.forEach [ Node|
// check if HB is reporting over 20 hours, if so, send reboot command
if (Node.state > 20) {
logWarn("ashburn.Nodes", "#### node reset hashmap lookup: "+Node.name+" = " + nodesKillSwitch.get(Node.name))
sendCommand(nodesKillSwitch.get(Node.name), ON)
Thread::sleep(3000)
sendCommand(nodesKillSwitch.get(Node.name), OFF)
}
]
end