Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

[serial] add TOGGLE option to switch items #5872

Open
marekhalmo opened this issue Jun 27, 2019 · 1 comment
Open

[serial] add TOGGLE option to switch items #5872

marekhalmo opened this issue Jun 27, 2019 · 1 comment

Comments

@marekhalmo
Copy link
Contributor

marekhalmo commented Jun 27, 2019

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?

@Rossko57
Copy link

Rossko57 commented May 8, 2020

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
openhab/openhab-core#947

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants