mvalla / openhab-addons

Add-ons for openHAB
Eclipse Public License 2.0
24 stars 16 forks source link

Door locks detected as a light switches #21

Closed WhatWapp closed 5 years ago

WhatWapp commented 5 years ago

Hi, first of all thanks for the awesome job you are doing with this binding! 👏

I have a couple of locks, one for the entry door and one for the main gate. Both of them are detected as a light switch and I can open them by turning the switch ON or close them by turning it OFF.

The problem is that once I change the state of the switch it doesn't automatically revert to the original state. Example:

  1. Door is Closed
  2. Turn ON the Door Switch
  3. The door opens and stays that way

After that, if I close the door, it won't close itself and I need to turn the switch off to make it close again.

Sorry for the poor explanation but I am very new to this world 😄

mvalla commented 5 years ago

Hi, devices are detected as switches because they are switches: I cannot imagine a way to understand automatically they are connected to a door instead of a light.

What you want to achieve can be probably obtained by proper configuration of items in openHAB i.e. obtain a pushbutton behavior. See the openHAB forum and search for threads like this: https://community.openhab.org/t/push-button-instead-of-switch/30937

Since this does not appear to be an issue related to the binding, I will close this issue after some time. M

alessandro-lac commented 5 years ago

Here's a way to manage this situation:

Step 1: Create a Push Button: .sitemap:

Switch item=FF_LivingRoom_Door label="Entry Door" mappings=[ON="Open"] visibility=[FF_LivingRoom_Door_State == OFF]
            Switch item=FF_LivingRoom_Door label="Entry Door" mappings=[ON="Close"] visibility=[FF_LivingRoom_Door_State == ON]

.items:

Switch   FF_LivingRoom_Door          "Entry Door"               <frontdoor>          (FF_LivingRoom)                 ["Lighting"]   {channel="", autoupdate="false"}
Switch   FF_LivingRoom_Door_State    "Entry Door"               <frontdoor>          (FF_LivingRoom)                 ["Lighting"]   {channel=""}

Remember to link both Items to the door in the PaperUI Things section.

Step 2: Create a rule to close the door after you press the open button (otherwise the door lock will stay open)

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

// Global Variables

rule "Chiusura Porta"
when
    Item FF_LivingRoom_Door changed
then
  if ((FF_LivingRoom_Door.state == ON)) {
    sendCommand(FF_LivingRoom_Door, OFF)
  }
end

Hope this helps.