Add option for individual outlet control on HS300 and HS303 power strips #79
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_ids
Child 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: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}}}