python-kasa icon indicating copy to clipboard operation
python-kasa copied to clipboard

HS110 not discovered by Discover.discover()

Open Wallum opened this issue 4 years ago • 5 comments

I have 2 devices; HS110 plug and LB130 bulb - Running: import asyncio from kasa import Discover

devices = asyncio.run(Discover.discover()) for addr, dev in devices.items(): asyncio.run(dev.update()) print(f"{addr} >> {dev}") only discovers the LB130 and not the plug.

Wallum avatar Mar 27 '22 22:03 Wallum

Are both devices in the same network? And is the HS110 otherwise working if you access it using its IP address? If you are in the UK, there are HS110 devices that use different protocol (see #115).

Otherwise, you could try to use Discover.discover_single(host) to see if it is responding to the discovery query.

Btw, you can use triple-ticks to fence code blocks on github.

rytilahti avatar Mar 29 '22 22:03 rytilahti

I ran into similar issues today. When I run the original code snippet posted by @Wallum, not a single device is discovered (there should be three HS100 plugs). When I use their respective IP addresses and Discover.discover_single(<ip>) however, the plugs are immediately found.

I also increased the discovery delay (up to 100 seconds) but that didn't change anything.

What could be causing this?

steps0x29a avatar Jun 24 '22 10:06 steps0x29a

Do you have multiple network adapters in your system? If yes, you need to specify on which network the discovery should be performed (i.e., which broadcast address is used for requests), take a look at the second example at https://python-kasa.readthedocs.io/en/latest/discover.html#kasa.Discover

rytilahti avatar Jun 26 '22 21:06 rytilahti

I have same issue, also with HS100 and HS110 (hardware V2 for both). My phone with Kasa app works fine. Laptop and phone on same wifi network.

I tried a couple of times, with no success:

❯ ./venv/bin/kasa discover
Discovering devices on 255.255.255.255 for 3 seconds
❯ ./venv/bin/kasa discover
Discovering devices on 255.255.255.255 for 3 seconds
❯ ./venv/bin/kasa
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 3 seconds
❯ ./venv/bin/kasa
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 3 seconds

Then ran "kasa wifi" and got a OS popup (mac) asking for permission for python to listen on a local interface, which I granted. It then detected the switches fine.

❯ ./venv/bin/kasa wifi
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 3 seconds
== Switch2 - HS100(AU) ==
...
== Switch1 - HS110(AU) ==
	Host: 192.168.30.92

After which, the original command worked fine

❯ ./venv/bin/kasa
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 3 seconds
== Switch2 - HS100(AU) ==
...
== Switch1 - HS110(AU) ==

lyricnz avatar Aug 21 '22 20:08 lyricnz

I'm running into the same issue with a HS110(UK) too.

If I target the exact device:

asyncio.run(Discover.discover(target="192.168.2.188"))

Then I get a result, but a generic discover() yields no results. I AM on a different network to it (192.168.0.x vs 192.168.2.x), so I've tried the following:

asyncio.run(Discover.discover(target="192.168.2.255"))

But that yields no results either. I've even tried increasing the timeout and packets:

asyncio.run(Discover.discover(target="192.168.2.255",timeout=15,discovery_packets=9))

But still no beans.

My current plan is to iterate over all 255 IP addresses in the range to find it, but it would be great if I could make discovery() work instead. Any ideas?

littlecharva avatar Jan 04 '23 10:01 littlecharva