Local API feature request: "wait for relay_state change, with timeout" command

Local API feature request: "wait for relay_state change, with timeout" command
Local API feature request: "wait for relay_state change, with timeout" command
2021-01-10 19:02:34 - last edited 2021-01-10 19:03:37
Model: HS200
Hardware Version:
Firmware Version:

(reposting this in the correct forum)

 

Hi,

 

I've installed a couple of HS200 and HS210 and have found them quite programmable given the open source software available. There is one major shortcoming to the local API, i'm wondering if TP-Link would consider addressing it:

 

It would be infinitely more useful if each smart switch/plug/etc would support a "wait for relay_state change, with timeout" command. Here is how this command could work:

 

Case #1: when nobody presses the physical switch

 

Local Client                                    HS200

{"wait_for_state_change": {"timeout": 5}} ----->

 

               ... HS200 waits for 5 seconds ...

 

               <----  {"error": 0, status: "timeout"}

 

Case #2: when someone presses the physical switch
 

Local Client                                    HS200

{"wait_for_state_change": {"timeout": 5}} ----->

 

               ... 3 seconds elapse ...

 

      Physical switch pressed, HS200 e.g. turns lights on

                            -or-

               HS210 detects 3-way line change

 

               <----  {"error": 0, status: "changed", relay_state: 1}

 

Ideally, timeout could be something from e.g. 1 second to hours, but it's understandable that it may need to be short to allow the switch to do routine tasks. In my typical use case, I imagine I would prefer to set timeout to 30 seconds.

 

Is this possible with HS200 series switches, or something TP-Link is interested in adding? It would make them infinitely more useful with home hubs such as Home Assistant, because it would mean hubs like Home Assistant could discover within milliseconds that a switch had physically been turned on without much increase on the local network traffic.

 

Thanks!

1
1
#1
Options
2 Replies
Re:Local API feature request: "wait for relay_state change, with timeout" command
2021-01-12 06:16:05

@cmdrd4t4 

Thank you very much for your kind feedback.

We would be glad to forward your feedback to the senior engineers for further evaluation.

And If you have more better ideas, please feel free to update it here.

Thanks a lot and wish you a happy new year.

0
0
#2
Options
Re:Local API feature request: "wait for relay_state change, with timeout" command
2021-01-14 17:34:27 - last edited 2021-01-14 17:35:45

@TP-Link thanks so much for looking at this. I realize I made a slight error in my proposal, there is one additional case the API would need to cover. I'm including the corrected API. The change is the addition of the "from_state" field in the request, which allows the client to specify its understanding of the current relay_state.

 

 

Case #1: when nobody presses the physical switch, and it was off when the API request was made

 

Local Client                                    HS200

{"wait_for_state_change": {"timeout": 5, "from_state": 0}} ----->

 

               ... HS200 relay_state was 0 when request received; it waits for 5 seconds ...

 

               <----  {"error": 0, status: "timeout"}

 

 

Case #2: when nobody presses the physical switch, and it was on when the API request was made

 

Local Client                                    HS200

{"wait_for_state_change": {"timeout": 5, "from_state": 0}} ----->

 

               ... HS200 relay_state was 1 when request received; no delay ...

 

               <----  {"error": 0, status: "condition_not_met", "relay_state": 1}

 

Case #3: when someone presses the physical switch

 

Local Client                                    HS200

{"wait_for_state_change": {"timeout": 5, "from_state": 0}} ----->

               ... 3 seconds elapse ...

 

      Physical switch pressed, HS200 e.g. turns lights on

                            -or-

               HS210 detects 3-way line change

 

               <----  {"error": 0, status: "changed", "relay_state": 1}

 

 

 

0
0
#3
Options
Related Articles