Representing a gate status + opening/closing

  • Platform information:
    • Hardware: RaspberryPi 3+_
    • OS: OpenHabian
    • OpenHAB version: 2.3.2

I have an electric gate which is monitored and controlled by an ESP board (relay to trigger opening/closing and 2 reed switch inputs to determine “Open” or “Closed”) which is running Tasmota 6.2.1.

The challenge I’m having is trying to represent the seemingly disconnected “status” of the gate (Open, Closed, In motion) neatly alongside the open/close triggering of the relay.

Here’s what my Items file looks like:

Switch GSonoff0101 "Gate" <switch> (LR,gLight) ["Lighting"] { mqtt=">[mosquitto:cmnd/GSONOFF01/POWER1:command:*:MAP(], <[mosquitto:stat/GSONOFF01/POWER1:state:MAP(]"}
Switch GSonoff0105 "Latch" <switch> (LR,gLight) ["Lighting"] { mqtt=">[mosquitto:cmnd/GSONOFF01/POWER7:command:*:MAP(], <[mosquitto:stat/GSONOFF01/POWER7:state:MAP(]"}
Switch GateS "Gate State" <light> (LR,gLight) ["Lighting"] { mqtt=">[mosquitto:cmnd/GSONOFF01/POWER6:command:*:default], <[mosquitto:stat/GSONOFF01/POWER6:state:default], <[mosquitto:tele/GSONOFF01/STATE:state:JSONPATH($.POWER6)]"}

Some notes

  1. GSonoff0101 is the trigger to either open or close the gate. Relay1 on Tasmota is configured to pulse on for about 500ms.
  2. The entries are because the logic for the relay board is upside down OFF=ON
  3. The GSonoff0105 points to Relay7 which is virtual and triggers the relay1 twice with a 60 second delay (latches the gate open. Just ignore this please.
  4. GateS is reading the gate state POWER6 comes on when the gate is fully open and this shows my gate state. Sort of.
  5. POWER5 (not currently monitored) comes on when the gate is fully closed.

Here’s the sitemap file segment:
Frame label=“Entrances” {
Switch item=GateS icon=“gate”
Switch item=GSonoff0101 icon=“door”
Switch item=GSonoff0105 icon=“door”

As you can see - 3 rows in the interface for what should really be one.

Use another Item (String type will suffice) and set the status of this item through a rule.

1 Like