Thing Item
Living room lamp1 LivingRoomLamp1
Living room lamp2 LivingRoomLamp2
Remote 1 Button 1 Remote1Button1
Remote 1 Button 2 Remote1Button2
and the following rules file:
rule "Remote1Button1On"
when
Item Remote1Button1 received command ON
then
LivingRoomLamp1.sendCommand(ON)
end
rule "Remote1Button1Off"
when
Item Remote1Button1 received command OFF
then
LivingRoomLamp1.sendCommand(OFF)
end
rule "Remote1Button2On"
when
Item Remote1Button2 received command ON
then
LivingRoomLamp2.sendCommand(ON)
end
rule "Remote1Button2Off"
when
Item Remote1Button2 received command OFF
then
LivingRoomLamp2.sendCommand(OFF)
end
When i look in the basic GUI the buttons for the remote change state when i press buttons on the physical remote but the lamps don’t change state, what am i missing?
Perhaps the button Items receive updates, that would be more usual for “incoming” traffic. Commands are usually generated by rules or UI and acted on bindings for “outward” effects.
Does the lamp change its state, when you use PaperUI?
You get the state of an item by simply compare to yourItem.state, e.g.
Remote1Button1.state
like in:
rule “Remote1Button1”
when
Item Remote1Button1 received command
then
if(Remote1Button1.state.equals(ON)
{
LivingRoomLamp1.sendCommand(ON)
}
else if(Remote1Button1.state.equals(OFF)
{
LivingRoomLamp1.sendCommand(OFF)
}
end
The state is what the Item has now.
Depending how the item is configured and what bindings it may have, an external device may send updates to this state.
A Command is something you (or a rule) sends to an Item.
Depending how the item is configured and what bindings it may have, sending it a Command may or may not change the state, and may or may not result in something being sent to an external device.
If you really want to send Commands to your remote, there is a “magic variable” called receivedCommand available inside a rule. (which is different from state, as discussed above)
rule "Remote1Button1"
when
Item Remote1Button1 received command
then
if (receivedCommand == ON) {
- - -
You should investigate looking into the logs that Openhab makes, you can see what updates and commands actually happen in response to your rules, UI, and external devices.
I don’t know why you expect to see commands. I would expect an Item linked to a remote handset to receive updates from it. Sending a command from Openhab to a remote handset makes little sense. No need to guess though, you can find out what it does by looking in the logs.