arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
468 stars 104 forks source link

Garage Door Config #14

Closed vijaydembla1 closed 4 years ago

vijaydembla1 commented 6 years ago

Hi,

Please accept my sincere thanks for the work you have done, it has made me achieve my goal. I'm writing this to discuss the issue I'm experiencing with Garage Door.

The Topic response for the status of the Garage is based no a reed switch, as a stand-alone sensor, it is working fine as the configuration of contact sensor is based on the topic response of "On"or "Off".

What is the way for me to make the script recognize the sensor response of Open and closed based on/off rather than "O ,C , o, c, S"etc.

Interestingly, the relay topic doesn't trigger the relay button, not sure what I'm missing, as the same relay is working with the Toggle function

Thanks for your help.

i3laze commented 6 years ago

vijaydembla1, please post your plugin config and tell the MQTT-device you're using.

+1 for garage setup seems really messy.

For example:

  1. GetState and SetState both use one 'doorvalues' array, but I've got separate MQTT topics for control and state with non-matching status names.

  2. When I set "doorValues" variable in config, MQTT logging shows that only a first char was published, like 'O', instead of 'ON'. Currently I have to modify index.js for publish to work fine.

  3. When State is 'Open' and a door is suddenly closed by RF remote or embedded autoclose timer, contact sensor fires event; MQTT logging says ' State is now: 1', nevertheless HomeKit state changes from 'Open' to 'Opening'. How so? Maybe something like this is required?

UPD: I moved to this GarageDoor plugin - it worked for me out of the box.

arachnetech commented 6 years ago

There was an error in the documentation - default target state values are O for OPEN and C for CLOSED (not 0 and 1). I'll correct this in the next release.

If you customise the values with doorValues, the OPEN and CLOSED target values must currently match the OPEN and CLOSED state values.

I've tested door values with strings longer than the single-character defaults and they seem to work for me. The syntax is:

"doorValues": [ "Open", "Closed", "Opening", "Closing", "Stopped" ]

Logging shows:

[2018-8-12 18:43:11] [Test Garage Door] Received MQTT: test/garage/current = Closed
[2018-8-12 18:43:11] [Test Garage Door] State is now: 1
[2018-8-12 18:43:29] [Test Garage Door] Received MQTT: test/garage/current = Open
[2018-8-12 18:43:29] [Test Garage Door] State is now: 0

MQTT logging of "State is now: 1' is referring to the internal homekit values, not the published MQTT values.

@vijaydembla1 I'm not quite sure what you mean by "the relay topic doesn't trigger the relay button, not sure what I'm missing, as the same relay is working with the Toggle function".

Note that I'm just exposing Homekit behaviour here. The supported behaviour appears to be (only) that Homekit changes the target state to open/closed to indicate whether the door should be open or closed, then the garage door can optionally send Opening/Closing followed by Stopped or Open/Closed to confirm that it has obeyed Homekit's instructions. As far as I can tell, there's no way for a garage door to tell homekit that it has been opened/closed independently of homekit.

hejsiri commented 6 years ago

Can you show your configuration for Garage Door Opener?

arachnetech commented 6 years ago

I was testing with:

    {
      "accessory": "mqttthing",
      "type": "garageDoorOpener",
      "name": "Test Garage Door",
      "url": "http://192.168.10.35:1883",
      "logMqtt": true,
      "topics":
      {
          "getCurrentDoorState":      "test/garage/current",
          "setTargetDoorState":       "test/garage/target",
          "getObstructionDetected":   "test/garage/obstruction",
          "getLockCurrentState":      "test/garagelock/current",
          "setLockTargetState":       "test/garagelock/target"
      },
      "doorValues": [ "Open", "Closed", "Opening", "Closing", "Stopped" ]
    },
vijaydembla1 commented 6 years ago

{ "accessory": "mqttthing", "type": "garageDoorOpener", "name": "TEST_Garage", "url": "mqtt://192.168.1.15", "username": "****", "password": "***", "caption": "<label (optional)>", "topics": { "getCurrentDoorState": "cmnd/Sensor/POWER2", "setTargetDoorState": "cmnd/Garage/POWER1", "getObstructionDetected": "", "getLockCurrentState": "<topic used to get lock current state (optional)>", "setLockTargetState": "<topic used to set lock current state (optional)>" }, "doorValues": "O,o,,,,", "lockValues": "<array of 4 lock values corresponding to unsecured, secured, jammed and unknown respectively (optional)>", "integerValue": "true to use 1|0 instead of true|false for obstruction detected value" },

The above is my config for the garage. Please note: - I have also added 2 accessories, one for the door status and one to control the relay button, their topics are identical to the one above and they seem to work properly, It's just the garage is always open in homekit, when i press it, it says closing, but i don't see any effect on relay (the toggle).

Please let me know if i'm missing something.

Below is the sensor reading when the door switch moves on esp8266 console.

:_

When in the switch is close to each other:-

13:01:19 MQT: cmnd/Sensor/POWER2 = OFF

When they are seperated:-

13:01:32 MQT: cmnd/Sensor/POWER2 = ON

Thanks

arachnetech commented 6 years ago

I would recommend removing the settings with < ... > (getLockCurrentState, setLockTargetState, lockValues, integerValue) as they might confuse things. Those are just intended as comments in the ReadMe.

As far as I can tell, HomeKit's Garage Door (like it's Security System) mandates that HomeKit controls the state that it should be set to, and the door is expected to respond once it's obeyed the command to confirm that HomeKit's state has been reached. It may be possible to set up your switch by setting up and automation in homekit to make the switch change the target state of the garage door. However, you can't just tell homekit that the state has changed, because it will always assume that the door should be moving to homekit's target state.

Kepete commented 6 years ago

@vijaydembla1 As I see you are also trying to use a esp flashed with tasmota for your garage door. Could I ask what setup are you running? I have connected two contact sensors and a relay to the tasmota. Now I would like to have a closed mqtt topic and a separate open mqtt topic. Becaouse tasmota gives me the state of one contact sensor and the state of the other.

hejsiri commented 6 years ago

I also want to do just like you. Two reed sensors + relay on tasmota. Can you help?

arachnetech commented 6 years ago

Could you publish to the same MQTT topic from both contact sensors when they transition as follows:

When closed sensor no contact -> opening When open sensor contact -> open When open sensor no contact -> closing When closed sensor contact -> closed

brefra commented 6 years ago

I would recommend removing the settings with < ... > (getLockCurrentState, setLockTargetState, lockValues, integerValue) as they might confuse things. Those are just intended as comments in the ReadMe.

As far as I can tell, HomeKit's Garage Door (like it's Security System) mandates that HomeKit controls the state that it should be set to, and the door is expected to respond once it's obeyed the command to confirm that HomeKit's state has been reached. It may be possible to set up your switch by setting up and automation in homekit to make the switch change the target state of the garage door. However, you can't just tell homekit that the state has changed, because it will always assume that the door should be moving to homekit's target state.

Pull request #28 contains the fix to keep the GarageDoor device in HomeKit in sync when the door has been controlled from outside of Homebridge.

arachnetech commented 6 years ago

My <comments in settings> have caused a certain amount of confusion, so I've started changing the format.

As discussed in the pull request, your suggestions were very helpful. I was wrong in my belief that target state couldn't be changed outside HomeKit. The Home App doesn't like to show it when it changes, but closing and re-opening it does show a new externally-set target state. Version 1.0.15 now supports external setting of target states for garage door and security system.

transistorgit commented 6 years ago

Hi, I'm using MQTTThing for all my devices, great! Now I'm switching over my MQTT-controlled gateway door (same as a garage door) to use also mqttthing. It works nice so far, but it seems that the "opening"/"closing" states are interchanged in the homekit view, when the door is triggered externally. When triggered by homekit, all states are showing correct order: Door open - touch it - closing - closed. But when its open an I hit the external button, homekit shows "opening" and than "closed" as the final state. The same when it is closed. Hitting the external button - homekit shows "closing", final state is open.

I checked the Mqtt traffic in parallel. It looks completely correct. TargetDoorState shows "Closing", but homekit shows "opening" at the same time (when triggered externally, as said).

Here's my config: { "accessory": "mqttthing", "type": "garageDoorOpener", "name": "Toreinfahrt", "url": "http://192.168.168.112:1883", "topics": { "setTargetDoorState": "Toreinfahrt/Target", "getTargetDoorState": "Toreinfahrt/TargetFeedback", "getCurrentDoorState": "Toreinfahrt/Status", "setLockTargetState": "Toreinfahrt/LockTarget", "getLockTargetState": "Toreinfahrt/unused", "getLockCurrentState": "Toreinfahrt/unused", "getObstructionDetected": "Toreinfahrt/unused" }, "doorValues": [ "Open", "Closed", "Opening", "Closing", "Stopped" ], "lockValues": [ "Unsecured", "Secured", "Jammed", "Unknown" ] }

TargetFeedback will only show the values "Open" and "Closed". Status will show all states "Open", Closed", "Opening", "Closing", "Stopped" exactly written like that.

By the way: homekit doesn't show "stopped", but switches to "Open". Is this Homekit behaviour?

Please tell me what I can do to resolve this, or if I should open a new issue. best regards

arachnetech commented 6 years ago

The Home App doesn’t appear to handle changes in target state correctly. It seems to read the target state when it is opened but then not update it subsequently. If the state then changes to something other than this initial target state, the Home App then shows that the accessory is ‘moving towards’ the initial target state that it read (when really it is moving in the other direction). When I first saw this behaviour, I assumed that target state could only be changed by HomeKit itself. However, if you close then re-open the Home App after changing the target state, it shows the correct state.

transistorgit commented 6 years ago

Ok, that explains why I also saw correct target states sometimes. Hopefully Apple will fix that at some time. Thank you and have a nice sunday!

TLCary commented 6 years ago

"I don't think so Tim." I use MQTTThing for everything but the Garage Door. I would like to use it for everything, but.. I use mqttgaragedoor because it works just fine. It's not Apple or the Home App that isn't responding to changes in the device from external inputs.

arachnetech commented 6 years ago

I need to try this mqttgarage door...

arachnetech commented 5 years ago

Reopening to remind me to look at https://github.com/iomax/homebridge-mqttgaragedoor.

peteroz12 commented 5 years ago

Hi there, I'm trying to get my Garadget (https://community.garadget.com/t/mqtt-support/3226/5) to work, it seems to open but not close or get the correct status. My config is:

{ "bridge": { "name": "Ozone Garage", "username": "XX:XX:XX:XX:XX:XX", "port": XXXXX, "pin": "XXX-XX-XXX" }, "description": "Testing Garage Door", "platforms": [], "accessories": [{ "accessory": "mqttthing", "type": "garageDoorOpener", "name": "Garage Door", "url": "http://XXX.XXX.XXX.XXX:1883", "logMqtt": true, "topics": { "setTargetDoorState": "garadget/Door/command", "getTargetDoorState": "garadget/Door/status", "getCurrentDoorState": "garadget/Door/command", "getObstructionDetected": "garadget/Door/status" }, "doorValues": ["open", "closed", "opening", "closing", "stopped"] }] }

Is there something I'm doing wrong?

TLCary commented 5 years ago

Invalid JSON at Port.

Look for invalid characters. A common problem is using an editor that helps you out by automatically making a “closing parentheses”. That’s a different character than the " that JSON expects.

Jasonlint.com or https://codebeautify.org/jsonvalidator etc

Sent from my iPad

On Dec 14, 2018, at 5:51 AM, peteroz12 notifications@github.com wrote:

Hi there, I'm trying to get my Garadget (https://community.garadget.com/t/mqtt-support/3226/5) to work, it seems to open but not close or get the correct status. My config is:

{ "bridge": { "name": "Ozone Garage", "username": "XX:XX:XX:XX:XX:XX", "port": XXXXX, "pin": "XXX-XX-XXX" }, "description": "Testing Garage Door", "platforms": [], "accessories": [{ "accessory": "mqttthing", "type": "garageDoorOpener", "name": "Garage Door", "url": "http://XXX.XXX.XXX.XXX:1883", "logMqtt": true, "topics": { "setTargetDoorState": "garadget/Door/command", "getTargetDoorState": "garadget/Door/status", "getCurrentDoorState": "garadget/Door/command", "getObstructionDetected": "garadget/Door/status" }, "doorValues": ["open", "closed", "opening", "closing", "stopped"] }] }

Is there something I'm doing wrong?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

pasna commented 5 years ago

Hi, Best wishes for the coming New Year 2019 everyone. Your plugin is great and I just complete configure all my lightings, I have tested, they work great, I really appreciate your hard work. Now I am working on using Sonoff SV flashed Tasmota 6.4.1, I configure the device as follow - GPIO5 -> Switch2 connect to reed switch - one reed switch only.

PulseTime1 10 SwitchMode1 1 SwitchMode2 2 PowerOnState 0 PowerRetain 1 SwitchTopic 0

status read - 20:08:24 MQT: stat/frontgatetest/STATUS = {"Status":{"Module":3,"FriendlyName":["Front_Gate_Test"],"Topic":"frontgatetest","ButtonTopic":"0","Power":0,"PowerOnState":0,"LedState":1,"SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[1,2,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":1}}

rule1 read - on switch2#state=1 do publish test/garage/current %value% endon on switch2#state=0 do publish test/garage/current o endon

config file - { "accessory": "mqttthing", "type": "garageDoorOpener", "name": "Front Gate Test", "url": "http://192.168.0.55:1883", "username": "my_name", "password": "my_password", "logMQtt": true, "caption": "Front Gate Test", "topics": { "setTargetDoorState": "cmnd/frontgatetest/POWER", "getTargetDoorState": "test/garage/current", "getCurrentDoorState": "test/garage/current" }, "doorValues": [ "1", "1", "o", "c", "S" ], "lockValues": [] } with is setting, I am able to get the device trigger 1 second pulse and control my sliding gate to open and close without any problem regardless of how Home App display status. However I felt that this plugin is fascinating and I love to use fewer plugins. At current status these cases were what I had faced. pt 1) I cannot use other doorValues than what shows above otherwise sonoff will not trigger, I found that "1" will command sonoff to trigger, "o" , "c", "S" did not push Home App to reflect status correctly. The app will spin forever and showing either opening or closing.

pt 2) I have to configure GPIO5 -> Switch2 and put reed switch into the play, reed switch does not control any relay. With reed switch and rule1 I can put the app to come to "Closed" position ( On Home App ). I attach this reed switch to the gate and I got notification pop-up on iPhone when gate is opened or closed and it is perfect. However when I manually, without push on the App Icon, opening the gate and the reed switch move apart, Home App showing closing instead of opening ! I wish it shows "Open" instead.

pt 3) When I restart Homebridge, the plugin fail to retain LWT and the Icon show "Open" but does not trigger relay. This only affect the garage door icon not the lightings.

Have a great holiday.

vijaydembla1 commented 5 years ago

Hi All,

I managed to get it to work, all i need is the pulse time to be included. Below is my current config:-

{ "accessory": "mqttthing", "type": "garageDoorOpener", "name": "garage-test", "url": "mqtt://192.168.1.15", "username": "pi", "password": "WWWWWWWW", "caption": "test-garage", "topics": { "setTargetDoorState": "cmnd/Garage/power3", "getTargetDoorState": "cmnd/2/POWER2", "getCurrentDoorState": "cmnd/2/POWER2" }, "doorValues": ["OFF", "ON" ,"o" ,"c" ,"S" ] }

I have 4 relays and 1 reed switch connected. I need help in adding pulse time to relay 3 only (garage/power3.

I have been able to add all of them and with added pluse time, i'll be able to set up my garage. Sorry i have been away and it took ages for me to recall what i orginially did.

Thanks again

NorthernMan54 commented 5 years ago

If your config is good, could you add it to the Wiki of Test Configurations so others can make use of it?

https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations

On Jan 31, 2019, at 6:20 AM, vijaydembla1 notifications@github.com wrote:

Hi All,

I managed to get it to work, all i need is the pulse time to be included. Below is my current config:-

{ "accessory": "mqttthing", "type": "garageDoorOpener", "name": "garage-test", "url": "mqtt://192.168.1.15", "username": "pi", "password": "WWWWWWWW", "caption": "test-garage", "topics": { "setTargetDoorState": "cmnd/Garage/power3", "getTargetDoorState": "cmnd/2/POWER2", "getCurrentDoorState": "cmnd/2/POWER2" }, "doorValues": ["OFF", "ON" ,"o" ,"c" ,"S" ] }

I have 4 relays and 1 reed switch connected. I need help in adding pulse time to relay 3 only (garage/power3.

I have been able to add all of them and with added pluse time, i'll be able to set up my garage. Sorry i have been away and it took ages for me to recall what i orginially did.

Thanks again

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arachnetech/homebridge-mqttthing/issues/14#issuecomment-459308958, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5CmA7Fp2GkDR3n8vyC-h09QnWPW6ebks5vItGDgaJpZM4Vx647.

vijaydembla1 commented 5 years ago

The config needs 2 improvements:- a) The relay should be timed for a second or so b) after rebooting either: RaspberryPi, Homebridge. ESP8266 The garage status shows open. You need to physically seperate the reed switch and bring them together to see the correct status in homekit.

Once the above 2 issues have been addressed, then i can upload it to the above link and with various others

Developer of this code might need to help on this :-)

Once again, thanks to all

tobekas commented 5 years ago

please try Version 1.0.42

arachnetech commented 4 years ago

Closing old issue.