SwitchBotAPI icon indicating copy to clipboard operation
SwitchBotAPI copied to clipboard

The new webhook documentation for the contact sensor is incorrect

Open AdyRock opened this issue 2 years ago • 37 comments

Describe The Bug: The new documentation for the webhook call-back for the contact sensor is wrong.

To Reproduce: Read the document and look at the webhook response.

Expected behavior: The detection state shows the contact status NOT the motion status. But, It would be very nice to ALSO have the motion status available.

Screenshots:

detectionState String the motion state of the device, "DETECTED" stands for motion is detected; "NOT_DETECTED" stands for motion has not been detected for some time

Device Model:

SwitchBotAPI

  • Use Case:

Detecting the contact state.

AdyRock avatar Apr 16 '22 17:04 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 26 '22 18:04 github-actions[bot]

Will the document be corrected?

AdyRock avatar Apr 26 '22 18:04 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 06 '22 19:05 github-actions[bot]

Any news if this will be corrected?

AdyRock avatar May 06 '22 20:05 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 16 '22 21:05 github-actions[bot]

Any news if this will be corrected?

AdyRock avatar May 16 '22 21:05 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 26 '22 22:05 github-actions[bot]

Will this be updated?

AdyRock avatar May 27 '22 06:05 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 06 '22 08:06 github-actions[bot]

Any updates?

AdyRock avatar Jun 06 '22 08:06 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 16 '22 09:06 github-actions[bot]

Any updates?

AdyRock avatar Jun 16 '22 09:06 AdyRock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 26 '22 11:06 github-actions[bot]

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.

github-actions[bot] avatar Jun 27 '22 11:06 github-actions[bot]

I would like to see this bug fixed as well. There is currently no way to do a webhook with the contact sensor for the detection of motion. The detectionState shows the contact status NOT the motion status, and should probably be labelled differently.

JGKarlin avatar Aug 07 '22 14:08 JGKarlin

I got annoyed trying to keep this open, so probably nothing will be done.

AdyRock avatar Aug 07 '22 15:08 AdyRock

I agree. The documentation is not clear and the motion detection is missing. It would be great if this feature was added and if answers could be given…

LittleJ avatar Aug 18 '22 20:08 LittleJ

When we query device info we get:

{
    "statusCode": 100,
    "body": {
        "deviceId": "",
        "deviceType": "Contact Sensor",
        "hubDeviceId": "",
        "moveDetected": false,
        "brightness": "bright",
        "openState": "close"
    },
    "message": "success"
}

detectionState matches none of those attributes. Could we reopen this issue ?

LittleJ avatar Aug 23 '22 06:08 LittleJ

I don't think there is anyone from Switchbot that looks at the issues, so I doubt it will be reopened or fixed.

AdyRock avatar Aug 23 '22 07:08 AdyRock

I think you are right, that's a shame... But thank YOU for answering. I was feeling alone here :-D

LittleJ avatar Aug 23 '22 07:08 LittleJ

FYI: I emailed the support to say that customers were not getting any answer on Github, here was the answer:

Hi there,
 
Thank you for reaching out.
We apologize for the trouble caused.
We will forward your need to the related department, and they will handle it accordingly.
 
Thank you for your patience.
 
If you have any other questions, please let us know, and we'll try to accommodate your request as soon as possible.
Have a nice day!
 
Best Regards!
SwitchBot Support -Ellen
Customer Service Agent
SwitchBot Customer Happiness

LittleJ avatar Aug 23 '22 07:08 LittleJ

I don't think there is anyone from Switchbot that looks at the issues, so I doubt it will be reopened or fixed.

Hi,AdyRock,sorry for our answer,I will check and fix it in next few days. Thank you for your feedback

chenliuyun avatar Aug 23 '22 12:08 chenliuyun

When we query device info we get:

{
    "statusCode": 100,
    "body": {
        "deviceId": "",
        "deviceType": "Contact Sensor",
        "hubDeviceId": "",
        "moveDetected": false,
        "brightness": "bright",
        "openState": "close"
    },
    "message": "success"
}
detectionState matches none of those attributes. Could we reopen this issue ?

Hi, could you check if the cloudservice is enabled in the device setting page?We will try to reproduce and fixed this bug,thanks

chenliuyun avatar Aug 23 '22 12:08 chenliuyun

Hello @chenliuyun. All is enabled. What we need is this: https://github.com/OpenWonderLabs/SwitchBotAPI/issues/125

LittleJ avatar Aug 23 '22 14:08 LittleJ

Hello @chenliuyun. All is enabled. What we need is this: #125

Hi, I have update code already, please check it ,

chenliuyun avatar Aug 24 '22 10:08 chenliuyun

I don't think there is anyone from Switchbot that looks at the issues, so I doubt it will be reopened or fixed.

Hi, I have fixed the bug, please check it.

chenliuyun avatar Aug 24 '22 10:08 chenliuyun

Hi @chenliuyun, thank you for participating in here, it is much appreciated.

I am however confused! What have you fixed?

AdyRock avatar Aug 24 '22 11:08 AdyRock

@chenliuyun Almost good ! 2 issues:

1/ Webhook must be triggered when "detectionState" AND "openState" change. For now it does NOT work if move is detected, only when it is open. There is no POST from webhook. Please verify detectionState and openState.

Contact sensor OPENED -> Webhook trigger (changeReport) -> openState: "open"
Motion DECTECTED by contact sensor -> Webhook trigger (changeReport) -> detectionState: "DETECTED"

2/ README not up to date. Here is my pull request: https://github.com/OpenWonderLabs/SwitchBotAPI/pull/126

LittleJ avatar Aug 24 '22 20:08 LittleJ

I can confirm the detectionState and openState now work as described. Thank you for that update.

Will the detectionState be updated independently of the contact soon, so the benefit of the motion sensor can be used, especially the NOT_DETECTED state?

Also would it be possible to include the left open and button press as separate webbook messages?

My goal is to stop polling for all the changes and just rely on the webhook, so that will reduce the load on your server and on my device.

AdyRock avatar Aug 24 '22 21:08 AdyRock

@AdyRock My changes have been pulled to the main repo. Documentation is now up to date. But the webhook is not triggered when movement is detected, and I suspect that when you open the contact sensor it still relies on the "detectionState" attribute.

I requested access to the source code here: https://github.com/OpenWonderLabs/SwitchBotAPI/issues/127 I am very interested in seeing what is happening in there. Users could certainly help accelerating the development/improvement of (new) features.

LittleJ avatar Aug 24 '22 21:08 LittleJ