FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Leverage data from UDP discovery to initialize device structure by dlee1j1 · Pull Request #132 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 1 addition & 2 deletions kasa/cli.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ async def dump_discover(ctx, scrub):
async def discover(ctx, timeout, discover_only, dump_raw):
"""Discover devices in the network."""
target = ctx.parent.params["target"]
click.echo(f"Discovering devices for {timeout} seconds")
click.echo(f"Discovering devices on {target} for {timeout} seconds")
found_devs = await Discover.discover(
target=target, timeout=timeout, return_raw=dump_raw
)
if not discover_only:
for ip, dev in found_devs.items():
await dev.update()
if dump_raw:
click.echo(dev)
continue
Expand Down
2 changes: 1 addition & 1 deletion kasa/discover.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def datagram_received(self, data, addr) -> None:

device_class = Discover._get_device_class(info)
device = device_class(ip)
asyncio.ensure_future(device.update())
device.update_from_discover_info(info)

self.discovered_devices[ip] = device
self.discovered_devices_raw[ip] = info
Expand Down
5 changes: 5 additions & 0 deletions kasa/smartdevice.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ async def update(self):
# TODO: keep accessible for tests
self._sys_info = self._last_update["system"]["get_sysinfo"]

def update_from_discover_info(self, info):
"""Update state from info from the discover call."""
self._last_update = info
self._sys_info = info["system"]["get_sysinfo"]

@property # type: ignore
@requires_update
def sys_info(self) -> Dict[str, Any]:
Expand Down

Back | FazBrowse Home | New Git URL