arachnetech / homebridge-mqttthing

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

Gargedoor State not matching #532

Closed coolas21 closed 9 months ago

coolas21 commented 2 years ago

HI,

I have a garage door set up with Tasmota and two reed sensors. Everything seems to work fine except the opening and closing in HomeKit are backwards. IE if I open the door from HomeKit or the actual garage my Mqtt publishes Opening, and HomeBridge accessory says Opening, but HomeKit says Closing. Any ides?

coolas21 commented 2 years ago

I'm not sure if this will help but when Homebridge receives OPENING HomeKit says closing, when it receives CLOSING HomeKit says Opening, and when it receives STOP HomeKit says OPEN. When OPEN and CLOSE are received HomeKit displays Opened and Closed correctly. Also in accessories in Homebridge the state matches what I am publishing and is happening. Just doesn't match in HomeKit

Here is my log from HomeBridge:

[1/25/2022, 10:13:54 AM] [Garage Door] Received CLOSE - targetDoorState state is now 1 [1/25/2022, 10:13:54 AM] [Garage Door] Received CLOSE - currentDoorState state is now 1 [1/25/2022, 10:14:09 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = OPENING [1/25/2022, 10:14:09 AM] [Garage Door] Warning: targetDoorState received [OPENING] which is not in configured values {"OPEN":0,"CLOSE":1} [1/25/2022, 10:14:09 AM] [Garage Door] Received OPENING - currentDoorState state is now 2 [1/25/2022, 10:14:16 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = OPEN [1/25/2022, 10:14:16 AM] [Garage Door] Received OPEN - targetDoorState state is now 0 [1/25/2022, 10:14:16 AM] [Garage Door] Received OPEN - currentDoorState state is now 0 [1/25/2022, 10:16:18 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = CLOSING [1/25/2022, 10:16:18 AM] [Garage Door] Warning: targetDoorState received [CLOSING] which is not in configured values {"OPEN":0,"CLOSE":1} [1/25/2022, 10:16:18 AM] [Garage Door] Received CLOSING - currentDoorState state is now 3 [1/25/2022, 10:16:19 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = OPEN [1/25/2022, 10:16:19 AM] [Garage Door] Received OPEN - currentDoorState state is now 0 [1/25/2022, 10:16:21 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = CLOSING [1/25/2022, 10:16:21 AM] [Garage Door] Warning: targetDoorState received [CLOSING] which is not in configured values {"OPEN":0,"CLOSE":1} [1/25/2022, 10:16:21 AM] [Garage Door] Received CLOSING - currentDoorState state is now 3 [1/25/2022, 10:16:37 AM] [Garage Door] Received MQTT: stat/GarageDoor/STATE = STOP [1/25/2022, 10:16:37 AM] [Garage Door] Warning: targetDoorState received [STOP] which is not in configured values {"OPEN":0,"CLOSE":1} [1/25/2022, 10:16:37 AM] [Garage Door] Received STOP - currentDoorState state is now 4

gensth commented 9 months ago

Dear coolas21,

I just found your question when searching for the solution of an own problem.

Probably the solution I found for my problem might help you: When searching for the error message ("which is not in configured values") in the code, I found that I might add additional values for the key "doorValues" to my homebridge configuration. I try blindely to adjust it to your problem:

            ...
            "topics": {
                "getCurrentDoorState": "stat/GarageDoor/STATE"
            },
            "doorValues": [ "OPEN", "CLOSED", "OPENING", "CLOSING", "STOP" ],
            ...

Depending on your error description (reversed OPENING and CLOSING state) it might also be (which might be strange)

            "doorValues": [ "OPEN", "CLOSED", "CLOSING", "OPENING", "STOP" ],

Best, Max

coolas21 commented 9 months ago

Max, thanks for the reply. I actually got it fixed after you sent me that message. What I found out was that I should match everything case and order with the directions. Target state is also very important.

MQTT thing: "doorCurrentValues": [ "Open", "Closed", "Opening", "Closing", "Stopped" ], // I use S for current state "doorTargetValues": ["open", "close"], // I use T for target state

and my MQTT door open code: (I have an open and closed reed contacts on sensor 1 and 2. And a lot of the code is for when the door opener restarts it will send the correct state to Homebridge. And my cat lives in the garage so at sunrise I have the event cat sent to the door and it opens it enough for the cat to get out.)

Rule1 ON Switch1#Boot DO var1=%value% ENDON
ON Switch2#Boot DO var2=%value% ENDON ON Mqtt#connected DO IF (var1==1) publish stat/%topic%/T open; DELAY 30; event Opened ENDIF ENDON ON Mqtt#connected DO IF (var2==1) publish stat/%topic%/T close; DELAY 30; event Closed ENDIF ENDON ON Mqtt#connected DO IF ((var1==0) and (var2==0)) delay 30; event Opening ENDIF ENDON ON EVENT#OPEN do power1 %var2% ENDON
ON EVENT#CLOSE do power1 %var1% ENDON
ON EVENT#STOP do backlog delay 8; power1 1 ENDON

Rule2 ON event#Opened do backlog var1 1; var2 0; ruletimer1 0; publish stat/%topic%/S Open ENDON
ON event#Closed do backlog var1 0; var2 1; ruletimer1 0; publish stat/%topic%/S Closed ENDON
ON event#Opening do backlog publish stat/%topic%/T open; var1 0; var2 0; ruletimer1 15; publish stat/%topic%/S Opening ENDON
ON event#Closing do backlog publish stat/%topic%/T close; var1 0; var2 0; ruletimer1 15; publish stat/%topic%/S Closing ENDON ON event#Stopped do backlog var1 1; var2 0; ruletimer1 0; publish stat/%topic%/S Stopped ENDON ON EVENT#CAT DO IF (var2==1) event open; power1 0; event stop ENDIF ENDON

Rule3 ON Switch1#State=1 do event Opened ENDON ON Switch2#State=1 do event Closed ENDON ON Switch1#State=0 do event Closing ENDON ON Switch2#State=0 do event Opening ENDON ON rules#timer=1 DO event Stopped ENDON

coolas21 commented 9 months ago

.