I have the following problem. I am using openhab2 with the knx2 binding and I have some items to define states to control my house (e.g. summer on or off/night on or off/windows open or closed). I want to send these states periodically to the knx bus. My first thought was to define a group to put all knx items who should be send periodically to the bus together. But I have no idea how to request the actual state of the group members and send them again to the bus inside a rule.
Can anybody help me and give me a hint?
Thank you for your help!
From a Rule:
GroupName.members.forEach[ i | i.sendCommand(i.state) ]
Where GroupName is the name of your Group.
Here’s more info on Design Pattern: Working with Groups in Rules
Thank you Rick, works, but i have one new problem I don’t understand.
The states seem to be send in the log, but I don’t recieve these commands on my knx bus.
Under normal operation my knx system is working with openhab. From my understanding sendCommand should do the job like I thought.
Time cron “0 4/1 * * * ? *”
gKNX_zyk.members.forEach[ i | i.sendCommand(i.state) ]
Someone who uses this binding will have to answer. Sending a command to an Item goes to the binding and should be published to the device.
Some items are contact items, is it possible that a contact item can not receive commands?
Indeed, you cannot send a command to a Contact. Contacts are only sensor values and cannot be commanded.
I need your help again. Since a few weeks (sorry I don’t know exactly the date or the change I made) I get the following error in my karaf log:
Rule 'test': Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null
First I thought hat one of the group members has the state " null", but this was not the matter.
I did not change any thing on the rule.
Thank you for your help!
best regards! Johannes
Assuming the Rule is unchanged from the above, add some logging statements to the forEach to log out i.name and i.state before sending the command. This will hopefully tell us which Item is causing the problem and why.
Indeed, if the item’s state is NULL or UNDEF I would expect to see that error. You can filter those out by changing the loop to:
gKNX_zyk.members.filter[ i | i != NULL && i != UNDEF].forEach[ i | i.sendCommand(i.state) ]
Note, that not all item states are currently sensible commands for the same Item, it depends on type.
In fact looking more closely at the error, you have run into
Your circumvention is
Thank you, it seems to run.