Add option for individual outlet control on HS300 and HS303 power strips#79
Open
AMDHome wants to merge 4 commits intosoftScheck:masterfrom
Open
Add option for individual outlet control on HS300 and HS303 power strips#79AMDHome wants to merge 4 commits intosoftScheck:masterfrom
AMDHome wants to merge 4 commits intosoftScheck:masterfrom
Conversation
|
@AMDHome, Have you been able to set multiple child_ids at the same time or does it just change the state of the first child_id in the list? |
Contributor
Author
|
I haven't used it in a while since the project I used this for ended, but if you craft the json by hand using the -j option you can add as many outlets as the strip has to the "child_id" array. If you are just using the -o flag that I implemented here as proof of concept, then no. You can only change one outlet at a time with the -o flag. You could change the code to allow for multiple -o flags and put them all in the "child_id" array in the json, but I was lazy when writing it and didn't do that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull requests adds some documentation and basic code to modify the commands and show how to control individual outlets on a TP-Link Kasa power strip.
Overview
As it is, this script can control power strips as a single entity. All switches on/off, timer/schedule set for all outlets, etc.
By adding a specially formatted piece of data you can control outlets individually.
Existing commands:
{"system":{"set_relay_state":{"state":1}}}{"system":{"set_relay_state":{"state":0}}}New commands for HS300/303
{"context":{"child_ids":["8006...E101"]}, "system":{"set_relay_state":{"state":1}}}{"context":{"child_ids":["8006...E101"]}, "system":{"set_relay_state":{"state":0}}}child_idsChild IDs are 42 character long Hexadecemal strings. You can get these values by running the info command on the power strip.
For instance, I have the HS303 power strip and when I run
{"system":{"get_sysinfo":{}}}it will return the following JSON:{ "system": { "get_sysinfo": { "sw_ver": "1.0.9 Build 191031 Rel.095941", "hw_ver": "1.0", "model": "KP303(US)", "deviceId": "8006243B...AAE1", . . . "led_off": 0, "children": [ { "id": "8006243B...AAE100", "state": 1, "alias": "Do not turn off!!!", "on_time": -3372260, "next_action": { "type": -1 } }, { "id": "8006243B...AAE101", "state": 0, "alias": "Plug 2", "on_time": 545, "next_action": { "type": -1 } }, { "id": "8006243B...AAE102", "state": 1, "alias": "Heat Pad", "on_time": 36062, "next_action": { "type": -1 } } ], "child_num": 3, "ntc_state": 0, "err_code": 0 } } }Some lines have been omitted to shorten the length
If you look under
"system">"get_sysinfo">"children"you can see the ID and alias for each of the outlets on your power strip.These child IDs should be just the
deviceId+ a 2 digit number representing the position of the outlet on your device (00 - 06 or 00 - 02 depending on which one you have)Multiple Control
You can actually control multiple outlets at once by specifying multiple IDs in the command JSON array.
Only outlet 1:
{"context":{"child_ids":["8006...E101"]}, "system":{"set_relay_state":{"state":0}}}Only outlet 1 and 2:
{"context":{"child_ids":["8006...E101","8006...E102"]}, "system":{"set_relay_state":{"state":0}}}