ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
149 stars 13 forks source link

[Support] Garagedoor state_cmd want pass Set commands #132

Closed arkadicolson closed 1 year ago

arkadicolson commented 1 year ago

Hi

I'm trying to get garagedoor working with this config

                {
                    "type": "GarageDoorOpener",
                    "displayName": "Garagepoort_2",
                    "currentDoorState": "OPEN",
                    "targetDoorState": "OPEN",
                    "obstructionDetected": "FALSE",
                    "lockCurrentState": "UNSECURED",
                    "lockTargetState": "UNSECURED",
                    "name": "Garagepoort_2",
                    "manufacturer": "Somebody",
                    "model": "Anything",
                    "serialNumber": "1232321321345",
                    "stateChangeResponseTime": 10,
                    "state_cmd": "/opt/garagepoort_2.sh",
                    "polling": [
                        {
                            "characteristic": "currentDoorState",
                            "interval": 540,
                            "timeout": 8000
                        },
                        {
                            "characteristic": "obstructionDetected",
                            "interval": 540,
                            "timeout": 8000
                        },
                        {
                            "characteristic": "lockCurrentState",
                            "interval": 540,
                            "timeout": 8000
                        }
                    ]
                },

I just started with this simple test script:

#!/bin/sh
echo ">> $1 $2 $3 $4" >> /tmp/homebridge_scripts.log
if [ "$1" = "Get" ]; then
        if [ "$3" = "ObstructionDetected" ]; then
                echo FALSE
        elif [ "$3" = "CurrentDoorState" ]; then
                echo CLOSED
        elif [ "$3" = "LockCurrentState" ]; then
                echo SECURED
        fi
else
        echo "SET"
fi

Get commands are displayed in /tmp/homebridge_scripts.log but I do not see any Set commands when pushing the garagedoor in the home app

==> /tmp/homebridge_scripts.log <==
>> Get Garagepoort_2 CurrentDoorState 
>> Get Garagepoort_2 ObstructionDetected 
>> Get Garagepoort_2 LockCurrentState 

I do see this in the homebridge log:

[10/14/2022, 2:55:42 PM] [Cmd4] Setting (Cached) Garagepoort_2 TargetDoorState 0
[10/14/2022, 2:55:42 PM] [Cmd4] Also Setting (Cached) Garagepoort_2 CurrentDoorState 0

but I cannot catch it in my state_cmd script. Any idea why? Something cache related?

ztalbot2000 commented 1 year ago

Hi,

On your IOS device, you would have to trigger the GarageDoor to be opened for a "Set" command to occur. I just noticed you did this, so let's continue. A GarageDoor does not request to change the "CurrentDoorState". instead it sends a "TargetDoorState" of OPEN or CLOSED I think you got this too. The problem I see is the debug log of "Setting ( Cached ) Garagepoort_2 TargetDoorState 0" The key issue being "Cached" which is not executing your script.

I think you need to poll for "lockTargetState" which I believe resolve the issue.

You should see CMD4 displaying a debug log that it is executing your script.

You should also to remember to always exit the script properly. exit 0

Ttyl, John

On Fri, Oct 14, 2022 at 9:08 AM arkadicolson @.***> wrote:

Assigned #132 https://github.com/ztalbot2000/homebridge-cmd4/issues/132 to @ztalbot2000 https://github.com/ztalbot2000.

— Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/132#event-7590249694, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX5C26Z6KSLCJQRUF7DWDFLM7ANCNFSM6AAAAAARFHHOYY . You are receiving this because you were assigned.Message ID: @.***>

ztalbot2000 commented 1 year ago

Hello again.

Did you have any success?

In the homebridge-cmd4 distribution in the sub path of Extras/Cmd4Scripts there is a javascript file called State.js. Every possible "Get/Set" option is listed there and it could be used as a state_cmd. What is also important is that it handles persistence of TargetDoorState and Setting currentDoorState afterwards, so the door does not get stuck openning. I might have misspoke with polling for "lockTargetState" it might have been "targetDoorState". The state.js file has the proper documentation, as does the Homebridge-Cmd4 github documentation. If your still stuc, just ask and I'll create a proper config.json and send it to you.

Ttyl, John

On Fri, Oct 14, 2022 at 9:30 AM John Talbot @.***> wrote:

Hi,

On your IOS device, you would have to trigger the GarageDoor to be opened for a "Set" command to occur. I just noticed you did this, so let's continue. A GarageDoor does not request to change the "CurrentDoorState". instead it sends a "TargetDoorState" of OPEN or CLOSED I think you got this too. The problem I see is the debug log of "Setting ( Cached ) Garagepoort_2 TargetDoorState 0" The key issue being "Cached" which is not executing your script.

I think you need to poll for "lockTargetState" which I believe resolve the issue.

You should see CMD4 displaying a debug log that it is executing your script.

You should also to remember to always exit the script properly. exit 0

Ttyl, John

On Fri, Oct 14, 2022 at 9:08 AM arkadicolson @.***> wrote:

Assigned #132 https://github.com/ztalbot2000/homebridge-cmd4/issues/132 to @ztalbot2000 https://github.com/ztalbot2000.

— Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/132#event-7590249694, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX5C26Z6KSLCJQRUF7DWDFLM7ANCNFSM6AAAAAARFHHOYY . You are receiving this because you were assigned.Message ID: @.***>

ztalbot2000 commented 1 year ago

Here is a config.json for a working GarageDoorOpener { "type": "GarageDoorOpener", "name": "My_GarageDoorOpener", "displayName": "My_GarageDoorOpener", "manufacturer": "GarageDoorMan", "currentDoorState": "OPEN", "targetDoorState": "OPEN", "obstructionDetected": "FALSE", "lockCurrentState": "UNSECURED", "lockTargetState": "UNSECURED", "polling": [ { "characteristic": "currentDoorState" }, { "characteristic": "targetDoorState" }, { "characteristic": "obstructionDetected" }, { "characteristic": "lockCurrentState" } ], "stateChangeResponseTime": 10, "state_cmd_prefix": "node", "state_cmd": ".homebridge/Cmd4Scripts/State.js" },

The State.js file as I previously mentioned is distributed with Cmd4. If you still have problems, just reopen the issue.

Take care, John

arkadicolson commented 1 year ago

Hi

Sorry for the late answer but it works again. Polling lockTargetState did the trick. Thanks for your help!

Arkadi

On 15/10/2022 12:18, John Talbot wrote:

WAARSCHUWING: Deze mail is afkomstig van buiten Smartbit. Klik niet op links en open geen bijlagen, tenzij je deze mail verwacht en hij afkomstig is van een betrouwbare bron.

Hello again.

Did you have any success?

In the homebridge-cmd4 distribution in the sub path of Extras/Cmd4Scripts there is a javascript file called State.js. Every possible "Get/Set" option is listed there and it could be used as a state_cmd. What is also important is that it handles persistence of TargetDoorState and Setting currentDoorState afterwards, so the door does not get stuck openning. I might have misspoke with polling for "lockTargetState" it might have been "targetDoorState". The state.js file has the proper documentation, as does the Homebridge-Cmd4 github documentation. If your still stuc, just ask and I'll create a proper config.json and send it to you.

Ttyl, John

On Fri, Oct 14, 2022 at 9:30 AM John Talbot @.***> wrote:

Hi,

On your IOS device, you would have to trigger the GarageDoor to be opened for a "Set" command to occur. I just noticed you did this, so let's continue. A GarageDoor does not request to change the "CurrentDoorState". instead it sends a "TargetDoorState" of OPEN or CLOSED I think you got this too. The problem I see is the debug log of "Setting ( Cached ) Garagepoort_2 TargetDoorState 0" The key issue being "Cached" which is not executing your script.

I think you need to poll for "lockTargetState" which I believe resolve the issue.

You should see CMD4 displaying a debug log that it is executing your script.

You should also to remember to always exit the script properly. exit 0

Ttyl, John

On Fri, Oct 14, 2022 at 9:08 AM arkadicolson @.***> wrote:

Assigned #132 https://github.com/ztalbot2000/homebridge-cmd4/issues/132 to @ztalbot2000 https://github.com/ztalbot2000.

— Reply to this email directly, view it on GitHub

https://github.com/ztalbot2000/homebridge-cmd4/issues/132#event-7590249694, or unsubscribe

https://github.com/notifications/unsubscribe-auth/ABSBCX5C26Z6KSLCJQRUF7DWDFLM7ANCNFSM6AAAAAARFHHOYY . You are receiving this because you were assigned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/132#issuecomment-1279713460, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT22SE6EBKJISMHN7COYITWDKAIDANCNFSM6AAAAAARFHHOYY. You are receiving this because you authored the thread.Message ID: @.***>