Hi
so as topic says i want to publish two different commands to arduino but on the same channel.
Let say i want one off my relays to send pulse (ON pause OFF) signal and i want to have another on1 off1 buttons to send another (ON pause OFF pause ON pause OFF) on the same relay.
So far i made another command listener on arduino and awaits ON1 and OFF1 commands, but i cant send them from Openhab, If its possible to make this pulses through Openhab only, some examples are welcomed .
You can combine the bindings configs onto one Switch which will cause it to send “ON” and “ON1” whenever you press the switch it will send both ON and ON1 at the same time.
But if you are looking to have one Switch send an ON sometimes and an ON1 other times, how is it supposed to know which one you want? A Switch is just a toggle, a boolean, it can only be ON or OFF. You would need something else (a second switch perhaps) to tell it which one you want.
However, if you make it a Number Item you can put it on your sitemap as a Switch with a Mappings which will put four buttons on the sitemap. Then your binding would be something like
However, not knowing what exactly it is you are doing, I would have thought it would make the most sense to have two separate Switches to control each behavior separately.
Thanks for the answer,
the point is that i control my AC through remote and on that remote i installed relay on the ON button, so when i press ON in openHAB it sends (ON pause 1sec than OFF) and it acts like i pressed the button on that remote.
But when the power outage happens, my AC unit is off and the remote for the AC is still on, so to send another ON command to the AC unit, first i need to turn off that remote with (ON pause 1sec OFF) and than turn back on with (ON pause 1sec OFF). With little modifications and with your help now its working .
Can you please help me with one more thing ,
i also installed AC status relay to tell me if its on or off, and i made rules for the same switch again with your help in another topic , here is the code for the rules
rule "Reset AC on startup"
when
System started
then
if (Relay11.state == ON && Switch5.state == OFF ) {
Relay1.sendCommand(ON)
Relay1.sendCommand(OFF)
// send email notification
}
end
but when i tested and when the openHAB reboots in the middle of that process i turned on the AC, but the openHAB thought that is OFF because off RRD4J persistence and tried to turn ON again but actually it turned OFF. So the question is…
Is it possible to initialize the current state of my switch, or to call for that state before the rules apply?
It depend on whether your device support it. Personally I solve this problem by having OH publish a “send update” message to my devices which causes the devices to publish their current state. This update request message is sent in the System started rule.
Then you can sleep for a bit to give the devices a chance to report their current status and then do the rest of your logic.
Without some way for OH to request the current state, there is no way for OH to know what state the device may be in when it comes up. All if has to go on is the value in rrd4j.