Open marekhalmo opened 5 years ago
update the item value and send ON or OFF to COM1
Updating Item state does not normally do anything to any binding. Certainly not to the serial binding. You'd need to send it a command.
This kind of feature is essentially what the follow profile is about, unfortunately this is restricted to use with bindings with channels and will not be available for serial v1.x
There's not likely to be a serial 2.x now, but maybe find out if there are any proposals for serial 3.x you could request the feature for. Although I still think profile covers it.
In the meantime, not difficult to use a rule.
TOGGLE command
proposal has been considered and rejected before https://github.com/openhab/openhab-core/issues/947
My setup: two serial gateways 1) button input gateway - transforms button input to a serial command using Arduino (e.g. button 1 click sends 'C1\n' on serial link) 2) relay output gateway - transforms serial input to relay on off (e.g. '+1\n' turns on relay 1, '-1\n' turns the relay 1 off)
I want to make simple bindings that bind relay and button clicks, this means that i don't need to write a rule to connect the button to a relay output example Switch Lamp {serial="COM1@9600,ON(+1\n),OFF(-1\n)", serial="COM2@9600,TOGGLE(C1\n)"}
So if the COM2 receives C1 - the binding will receive TOGGLE command - update the item value and send ON or OFF to COM1
What is necessary for the "TOGGLE" command to work is that i need to figure out the current state of the item in binding. There is no state that i can rely on in the serial binding class.
Can anyone suggest how to safely fetch the actual state of the item?