Use a Amazon Dash Button as OPEN CLOSE Trigger

I use a openhab2 on a Raspberry PI3, runs great.
I opened a Amazon Dash Button and soldered a reed contact over the switch of the dash button.
When a magnet pass the reed contact the dash button gets triggered and can work as “switch”

That works already, but i like to use it as a Window contact ( OPEN / CLOSE ) every time the magnet pass the reed contact the status toggles.
My question is: How can i translate a switch to a (open / close) contact?
Anybody have an example.

You only need to create another item:

Say your dash button is:

Switch Dash_Button {your binding}

Create another item:

Contact Dash_Contact

Then a rule:

rule "Switch to Contact"
when
    Dash_Switch changed
then
    if (Dash_Switch.state == ON) {
        Dash_Contact.postUpdate(OPEN)
    } else {
        Dash_Contact.postUpdate(CLOSED)
    }
end
1 Like

Sounds easy, i try after work!
Thank you! :slight_smile: