Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP + broadcast support #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

wowczarek
Copy link

@wowczarek wowczarek commented Jul 9, 2018

  • Support for broadcast (discovering all devices and mass commands)
  • Support for UDP communication (works just as well as TCP, minus UDP being UDP)
  • Configurable UDP timeout, and source address (for both TCP and UDP)
  • Only json output sent to stdout, rest to stderr, to get clean json for scripting etc.

- Support for broadcast (discovering all devices and mass commands)
- Support for UDP communication
- Configurable UDP timeout and source address (for both TCP and UDP)
- Only json output sent to stdout, rest to stderr,
  to get clean json output
@wowczarek
Copy link
Author

  • Readme.md updated accordingly, added my name to Python source, hope you don't mind

The TP-Link Kasa app uses broadcast UDP probes to discover devices (the "info" JSON cmd, also on port 9999, all-ones IP address). They reply to the sender via unicast UDP. It turned out that all commands work via UDP unicast (and broadcast), the only difference in terms of the protocol is the lack of the 4-byte padding. The broadcast operation is quite useful - you can for example send "off" to all devices, etc.

Recently (on Android at least) either the Kasa app got "smarter" deliberately to force people to use their cloud solution, or introduced a bug and stopped sending discovery unless you are on wi-fi - which breaks the operation over VPNs and such. So I decided to ditch it as my devices never have nor will they ever be allowed to reach the cloud while on my network.

I am planning some more work e.g. to dump the discovered data into a file where IDs can be mapped to MACs, so you can refer to those rather than IPs - and you can keep the configured device names intact. Or to reconfigure the devices en masse.

@tonsmets
Copy link

I used your broadcast functionality and it is a great addition! Since the latest firmware upgrade I was scared I could not use this script anymore but by using UDP/broadcast I can query information from my device!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants