ZeliardM / homebridge-kasa-python

Plugin that uses Python-Kasa API to communicate with Kasa Devices.
MIT License
5 stars 2 forks source link

Support for two networks? They are pingable and reachable #3

Open smithmarcw opened 2 weeks ago

smithmarcw commented 2 weeks ago

Describe Your Problem:

I have two wireless networks, my homebridge on network-1. I'm able to detect devices on network-1, however, I cannot find devices on network-2 (my IOT network). Is this supported? I can ping the device on network-2 from the homebridge container (on network-1), however it's not discovering.

Am I missing a setting?

Logs:

NOTICE TO USERS AND PLUGIN DEVELOPERS
> Homebridge 2.0 is on the way and brings some breaking changes to existing plugins.
> Please visit the following link to learn more about the changes and how to prepare:
> https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[11/10/2024, 11:17:55 PM] [Kasa Python] (31381) wsgi starting up on http://127.0.0.1:33041
[11/10/2024, 11:17:55 PM] [Kasa Python] (31381) accepted ('127.0.0.1', 53720)
[11/10/2024, 11:18:00 PM] [Kasa Python] Restarting child bridge...
[11/10/2024, 11:18:00 PM] Got SIGTERM, shutting down child bridge process...
[11/10/2024, 11:18:00 PM] [Kasa Python] An error occurred during device discovery: socket hang up
[11/10/2024, 11:18:05 PM] [Kasa Python] Child bridge process ended
[11/10/2024, 11:18:05 PM] [Kasa Python] Process Ended. Code: 143, Signal: null
[11/10/2024, 11:18:12 PM] [Kasa Python] Restarting Process...
[11/10/2024, 11:18:12 PM] [Kasa Python] Launched child bridge with PID 31414
[11/10/2024, 11:18:12 PM] Registering platform 'homebridge-kasa-python.KasaPython'
[11/10/2024, 11:18:13 PM] [Kasa Python] Loaded homebridge-kasa-python v2.3.1 child bridge successfully
[11/10/2024, 11:18:13 PM] Loaded 3 cached accessories from cachedAccessories.0EC22C5FE329.
[11/10/2024, 11:18:13 PM] [Kasa Python] Configuring cached accessory: [Garage - Kasa Plug 0E94] UUID: fd23e1f5-e1e6-4f7e-9aa0-df4c62da5acc deviceId:
[11/10/2024, 11:18:13 PM] [Kasa Python] Configuring cached accessory: [Entry Kasa] UUID: fe7c3c49-a82c-4d8f-97a2-9ecb28112009 deviceId:
[11/10/2024, 11:18:13 PM] [Kasa Python] Configuring cached accessory: [TP-LINK_Smart Plug_F61D] UUID: 6e25ca08-5921-473e-ac7f-5b3d1a4891f5 deviceId:
[11/10/2024, 11:18:13 PM] [Kasa Python] homebridge-kasa-python v2.3.1, node v20.18.0, homebridge v1.8.5, api v2.7 Initializing...
[11/10/2024, 11:18:13 PM] Homebridge v1.8.5 (HAP v0.12.3) (Kasa Python) is running on port 40106.
[11/10/2024, 11:18:13 PM] 

NOTICE TO USERS AND PLUGIN DEVELOPERS
> Homebridge 2.0 is on the way and brings some breaking changes to existing plugins.
> Please visit the following link to learn more about the changes and how to prepare:
> https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[11/10/2024, 11:18:13 PM] [Kasa Python] Version file updated to version 2.3.1
[11/10/2024, 11:18:13 PM] [Kasa Python] Plugin version changed, virtual python environment will be recreated.
[11/10/2024, 11:18:32 PM] [Kasa Python] Discovering devices...
[11/10/2024, 11:18:37 PM] [Kasa Python] Devices discovered: 3
[11/10/2024, 11:18:37 PM] [Kasa Python] Adding: [Entry Kasa] IOT.SMARTPLUGSWITCH []
[11/10/2024, 11:18:37 PM] [Kasa Python] Adding: [Garage - Kasa Plug 0E94] IOT.SMARTPLUGSWITCH []
[11/10/2024, 11:18:37 PM] [Kasa Python] Adding: [TP-LINK_Smart Plug_F61D] IOT.SMARTPLUGSWITCH []

Plugin Config:

{
    "name": "Kasa Python",
    "enableCredentials": true,
    "username": "",
    "password": "",
    "powerStrip": false,
    "_bridge": {
        "username": "",
        "port": 40106
    },
    "platform": "KasaPython"
}

Screenshots:

Environment:

ZeliardM commented 2 weeks ago

The discovery is done based on the connected network and the default broadcast address of 255.255.255.255. I can see about adding an option for additional discovery networks to be added. They would need to be applied in the format of: 192.168.1.0. Give me some time to work through this and add it in.

smithmarcw commented 2 weeks ago

Thank you so much - Look forward to testing

ZeliardM commented 2 weeks ago

Ok, excellent. I'll update this again once I have something for you to test. Now, as you stated, you can ping the devices from the Homebridge instance, direct network communication will be required for this plugin and library to work. It will not communicate over the Kasa Cloud to devices.

plasticfist commented 2 weeks ago

Marc,  I could use this as well.  However it looks like the homebridge and iPhone have to still be on the same network, did you find a way around that issue? On Nov 11, 2024, at 12:07 AM, Marc Smith @.***> wrote: Thank you so much - Look forward to testing

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

smithmarcw commented 2 weeks ago

Marc,  I could use this as well.  However it looks like the homebridge and iPhone have to still be on the same network, did you find a way around that issue? On Nov 11, 2024, at 12:07 AM, Marc Smith @.> wrote: Thank you so much - Look forward to testing —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.>

I have not found a work around for this. Of course the other option is put homebridge all in the same network as my devices. I will do this unless ZeliardM feature to add discovery networks option doesn't pane out.

ZeliardM commented 2 weeks ago

I have updated to v2.4.0. There is a new area under discovery options to add the other networks, formatted 192.168.1.0, add your other network and let's see if the other devices can be discovered. Let me know.

smithmarcw commented 2 weeks ago

Hello - Thanks for the work on this. However, It hasn't found the devices on that network. I'm going to keep poking around and test.

{
    "name": "Kasa Python",
    "enableCredentials": true,
    "username": "",
    "password": "",
    "powerStrip": false,
    "additionalNetworks": [
        "172.16.2.0"
    ],
    "_bridge": {
        "username": "",
        "port": 40106
    },
    "platform": "KasaPython"
}

Logs from plugin

NOTICE TO USERS AND PLUGIN DEVELOPERS Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. Please visit the following link to learn more about the changes and how to prepare: https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[11/11/2024, 5:03:48 PM] [Kasa Python] Discovering devices... [11/11/2024, 5:03:53 PM] [Kasa Python] Devices discovered: 3 [11/11/2024, 5:03:53 PM] [Kasa Python] Adding: [Entry Kasa] IOT.SMARTPLUGSWITCH [] [11/11/2024, 5:03:53 PM] [Kasa Python] Adding: [Garage - Kasa Plug 0E94] IOT.SMARTPLUGSWITCH [] [11/11/2024, 5:03:53 PM] [Kasa Python] Adding: [TP-LINK_Smart Plug_F61D] IOT.SMARTPLUGSWITCH []

The three devices found are on the same network on homebridge my 172.16.1.0 network.

Here is a ping from homebridge in console

homebridge -V

1.8.5

ping 172.16.2.52

PING 172.16.2.52 (172.16.2.52) 56(84) bytes of data. 64 bytes from 172.16.2.52: icmp_seq=1 ttl=254 time=27.3 ms 64 bytes from 172.16.2.52: icmp_seq=2 ttl=254 time=51.7 ms ^C --- 172.16.2.52 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 27.263/39.485/51.707/12.222 ms

ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.16.1.192 netmask 255.255.255.0 broadcast 172.16.1.255 ether 02:42:ac:10:01:c0 txqueuelen 0 (Ethernet) RX packets 269114 bytes 139683419 (139.6 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 220628 bytes 32546646 (32.5 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 152189 bytes 71473574 (71.4 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 152189 bytes 71473574 (71.4 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ZeliardM commented 2 weeks ago

Ok, I'll check and see if there's anything else I need to do on my end as well. I also made another update to hopefully resolve the issues with the alias. Try v2.4.1

smithmarcw commented 2 weeks ago

Same result with v2.4.1

ZeliardM commented 2 weeks ago

Yea, sorry, 2.4.1 was only to handle the issues with the alias not working correctly sometimes. I'll have to look into the issue with the network a little further. Would you be willing to do some troubleshooting of the library from the Homebridge Web UI Terminal?

smithmarcw commented 2 weeks ago

Given instructions, I'll do my best to help, yes.

ZeliardM commented 2 weeks ago

In the Web UI, open the terminal: It should start in /var/lib/homebridge/ Type cd kasa-python and then enter, then the following: source .venv/bin/activate kasa --version kasa --target 172.16.2.255 discover

smithmarcw commented 2 weeks ago

Here you go

Note: This is a restricted shell, sudo cannot be used here.

Homebridge Terminal

Node.js Version: v20.18.0 Node.js Path: /opt/homebridge/bin/node Plugin Path: /var/lib/homebridge/node_modules

Update Node.js: hb-service update-node

Install Plugin: hb-service add homebridge-plugin-name Remove Plugin: hb-service remove homebridge-plugin-name

root@7a57c1e717ba:/var/lib/homebridge $ cd kasa-python root@7a57c1e717ba:/var/lib/homebridge/kasa-python $ source .venv/bin/activate (.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $ kasa --version kasa, version 0.7.7 (.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $ kasa --target 172.16.2.255 discover Discovering devices on 172.16.2.255 for 10 seconds Found 0 devices (.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $

ZeliardM commented 2 weeks ago

Ok, so I guessed that 172.16.2.255 is the broadcast address for the other network. I suppose a little more information about the other devices might be needed. Is the other network segmented and closed off? Like can the devices talk to each other, do they talk to the internet, is mDNS enabled in the network for broadcast discovery? If not, I can see about doing a manual input for specific IP's and we can see if that works.

smithmarcw commented 2 weeks ago

mDNS is enabled, network can talk to internet. it's a /26 so my broadcast is 172.1.6.2.63. You might need to allow users to specify CIDR, if allowed.

For now, I switched to a /24 so my broadcast is 172.16.2.255. That being said, I'm still not discovering the devices, even using the cmd prompt mentioned above. I restarted bridge and plugin after changes were made.

smithmarcw commented 2 weeks ago

So I used your commands directly to the ip address of the device I wanted added and that worked. See below. This isn't ideal, as the IP could change, so would like to figure out auto-discover.

(.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $ kasa --target 172.16.2.52 discover Discovering devices on 172.16.2.52 for 10 seconds == Back porch - KL130(US) == Host: 172.16.2.52 Port: 9999 Device state: True Time: 2024-11-11 23:54:52-05:00 Hardware: 3.0 Software: 1.0.15 Build 240429 Rel.154143 MAC (rssi): 14:eb:b6:33:f3:31 (-60)

== Primary features == State (state): True Current consumption (current_consumption): 1.2 W Brightness (brightness): 4 (range: 0-100) Color temperature (color_temperature): 3945 (range: 2500-9000)

== Information == Today's consumption (consumption_today): 0.028 kWh This month's consumption (consumption_this_month): 0.374 kWh Total consumption since reboot (consumption_total): 0.036 kWh Cloud connection (cloud_connection): True

== Configuration == HSV (hsv): HSV(hue=0, saturation=0, value=4) Light preset (light_preset): Not set Light preset 1 Light preset 2 Light preset 3 Light preset 4

== Debug == RSSI (rssi): -60 dBm Reboot (reboot):

Found 1 devices (.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $

ZeliardM commented 2 weeks ago

Ok, I'll make the modifications for specifying the exact broadcast. I'll also make modifications for specifying devices and let you know when those changes are done.

ZeliardM commented 2 weeks ago

As of right now, bulbs and lights are not supported by the plugin, so they may be discoverable by the library but the plugin will not find them.

smithmarcw commented 2 weeks ago

I have an EP40 on that network as well that isn't being discovered. At this point, I'm somewhat convinced that it's a network issue. One thing I failed to mention is I have VLANs enabled. Upon my research it appears mDNS isn't supported across VLANs without a repeater. My network hardware/software does support it, but I can't seem to get it to work.

From your kasa commands you sent me, manually adding seems to work and might be a workaround. However, I think my best route would be to put everything on the same network.

I really appreciate your responsiveness and help on this. I'll continue to help if you need someone to test.

ZeliardM commented 2 weeks ago

I'm going to add manually adding devices, just in case people want to only manually add them and not use the broadcasting. Give me a bit and I will get something together.

ZeliardM commented 2 weeks ago

Check v2.4.2 and see if you can manually add the devices you have on the other network, you don't need to manually add the devices on the network that are connected to the homebridge instance. If they get added, check and make sure that you can control them correctly from Homebridge and HomeKit.

smithmarcw commented 2 weeks ago

It doesn't work on my setup. I still think it's mDNS across vlan issue. I can get state information using homepage terminal

(.venv) root@7a57c1e717ba:/var/lib/homebridge/kasa-python $ kasa --host 172.16.2.50 device state Discovering device 172.16.2.50 for 10 seconds == TP-LINK_Smart Plug_20A8 - EP40(US) == Host: 172.16.2.50 Port: 9999 Device state: False Time: 2024-11-12 15:27:47-05:00 Hardware: 1.0 Software: 1.0.4 Build 240305 Rel.111944 MAC (rssi): 28:87:BA:95:20:A8 (-64)

== Primary features == State (state): False

== Information == On since (on_since): None Cloud connection (cloud_connection): True

== Configuration == LED (led): False

== Debug == RSSI (rssi): -64 dBm Reboot (reboot):

== Children ==

== Animated Light (Socket for EP40(US)) ==

== Primary features == State (state): False

== Information == On since (on_since): None

== Configuration ==

== Debug ==

== Kasa_Smart Plug_20A8_1 (Socket for EP40(US)) ==

== Primary features == State (state): False

== Information == On since (on_since): None

== Configuration ==

== Debug ==

ZeliardM commented 2 weeks ago

If the discover works through the library on the Homebridge Web UI Terminal, it should work through the plugin. Could be something else with the plugin. Let me add some additional logging. Do you know how to turn on Debug Mode in Homebridge? Now, this may print some sensitive information, so I would suggest scrubbing it before you post any logs, but let me update the logging and get v2.4.3 out there and have you try it.

smithmarcw commented 2 weeks ago

I don't see much in debug, in fact, I don't even see it trying to discover my manual device.

Here is my config

{
    "name": "Kasa Python",
    "enableCredentials": false,
    "powerStrip": false,
    "manualDevices": [
        {
            "host": "172.16.2.50"
        }
    ],
    "_bridge": {
        "username": "0E:C2:2C:5F:E3:29",
        "port": 40106
    },
    "platform": "KasaPython"
}

homebridge-kasa-python.log

ZeliardM commented 2 weeks ago

Ok, now try v2.4.3, sorry, this has the additional logging in it

ZeliardM commented 2 weeks ago

Ok, sorry, try v2.4.4, I forgot to turn on the logging

smithmarcw commented 2 weeks ago

here you go

homebridge-kasa-python.log(2).txt

ZeliardM commented 2 weeks ago

Ok, looks like it didn't pull in the manual device. Let me look into it.

ZeliardM commented 2 weeks ago

Ok, let's try v2.5.0. I got everything to parse and pass correctly now. remove the manual devices, put your broadcast back at the correct one and let's try the discovery on the additionalBroadcast and see what happens. You should be able to disable the debug logging as well. Please let me know.

ZeliardM commented 2 weeks ago

v2.5.1 should resolve the errors with the device name in getSysInfo

smithmarcw commented 2 weeks ago

Hello -

It appears to scan for them, but again, I don't think mDNS works across multiple VLAN IDs, therefore, nothing is discovered on my added broadcast network (at least in my network).

[11/13/2024, 2:15:15 PM] [KasaPython] Child bridge process ended [11/13/2024, 2:15:15 PM] [KasaPython] Process Ended. Code: 143, Signal: null [11/13/2024, 2:15:22 PM] [KasaPython] Restarting Process... [11/13/2024, 2:15:22 PM] [KasaPython] Launched child bridge with PID 2621 [11/13/2024, 2:15:23 PM] [KasaPython] Loaded homebridge-kasa-python v2.5.1 child bridge successfully [11/13/2024, 2:15:23 PM] [KasaPython] Configuring cached accessory: [Smart Plug 20A8] UUID: 02fa4449-7986-49cc-9526-2fe675759917 deviceId: 80068CA5E49793D1E684A461C4BA79B71FEF709A [11/13/2024, 2:15:23 PM] [KasaPython] homebridge-kasa-python v2.5.1, node v20.18.0, homebridge v1.8.5, api v2.7 Initializing... [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Starting python environment check... [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Running command: python3 --version [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command PID: 2632 [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/python3 /homebridge/node_modules/homebridge-kasa-python/dist/python/pythonHome.py [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command PID: 2633 [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Running command: python3 /homebridge/node_modules/homebridge-kasa-python/dist/python/pythonHome.py [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command PID: 2634 [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 --version [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command PID: 2635 [11/13/2024, 2:15:23 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:24 PM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 freeze [11/13/2024, 2:15:24 PM] [KasaPython] [Python Check] Command PID: 2636 [11/13/2024, 2:15:24 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:24 PM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 install -r /homebridge/node_modules/homebridge-kasa-python/requirements.txt [11/13/2024, 2:15:24 PM] [KasaPython] [Python Check] Command PID: 2637 [11/13/2024, 2:15:25 PM] [KasaPython] [Python Check] Command finished. [11/13/2024, 2:15:25 PM] [KasaPython] [Python Check] Finished python environment check. [11/13/2024, 2:15:25 PM] [KasaPython] Running command: /var/lib/homebridge/kasa-python/.venv/bin/python3 /var/lib/homebridge/node_modules/homebridge-kasa-python/dist/python/kasaApi.py 42521 [11/13/2024, 2:15:25 PM] [KasaPython] Command PID: 2640 [11/13/2024, 2:15:25 PM] [KasaPython] Command started. [11/13/2024, 2:15:25 PM] [KasaPython] Discovering devices... [11/13/2024, 2:15:25 PM] [KasaPython] Sending discovery request with additionalBroadcasts: ["172.16.1.255"], and manualDevices: [] [11/13/2024, 2:15:35 PM] [KasaPython] Devices discovered: 1 [11/13/2024, 2:15:35 PM] [KasaPython] Adding: [Smart Plug 20A8] IOT.SMARTPLUGSWITCH [80068CA5E49793D1E684A461C4BA79B71FEF709A] [11/13/2024, 2:15:35 PM] [KasaPython] [Smart Plug 20A8] Existing Accessory found [80068CA5E49793D1E684A461C4BA79B71FEF709A] [02fa4449-7986-49cc-9526-2fe675759917] category: OUTLET [11/13/2024, 2:15:40 PM] [KasaPython] [Smart Plug 20A8] executing deferred getSysInfo count: 1

smithmarcw commented 2 weeks ago

I'm moving towards putting everything on the same network. Appreciate your additions and these new features. Should help other users!

ZeliardM commented 2 weeks ago

It looks like it did find it though, 20A8 is the plug that was on the separate network. Did it add the other devices back as well or just the new one? I understand, I appreciate your help with this. I don't employ a complex network myself so troubleshooting this with you has been extremely helpful. If while you have time to test a few more things, I'd like to see if I could get it fully working this way.

smithmarcw commented 2 weeks ago

It was, but I moved homebridge to network-2, so everything is reversed. Homebridge is now on network-2 and I'm scanning network-1 (172.1.6.1.255). There are still items to discover on network-1 as I haven't moved them over yet. Sorry for confusion, here is my config.

I can keep testing for you, if needed.

{
    "name": "KasaPython",
    "enableCredentials": false,
    "powerStrip": false,
    "additionalBroadcasts": [
        "172.16.1.255"
    ],
    "platform": "KasaPython",
    "_bridge": {
        "username": "0E:8E:7A:DD:A5:97",
        "port": 43811
    }
}
ZeliardM commented 2 weeks ago

What if you remove the broadcast and add the IP Addresses of those devices on network 1 to the list of manual devices? Discovery will not work with VLAN's because of UDP discovery not transversing the VLAN, you are correct.

ZeliardM commented 2 weeks ago

I've updated to v2.5.2 with a lot of additional logging for the device discovery. If you can enable debug logging on the server and run it and post a copy of the log here after scrubbing any personal information, it should help narrow down some things. Thanks.

smithmarcw commented 2 weeks ago

I've updated to v2.5.2 with a lot of additional logging for the device discovery. If you can enable debug logging on the server and run it and post a copy of the log here after scrubbing any personal information, it should help narrow down some things. Thanks.

I will look at it and do that today. Been busy with work.

ZeliardM commented 2 weeks ago

no problem, just keeping the issue up to date. Thanks for your help, this will make things a lot more versatile for others as well with more complex set ups.

ZeliardM commented 2 weeks ago

Check v2.5.4 and let me know. I made some changes to the device type handling.

smithmarcw commented 2 weeks ago

Here are the logs attached using the added broadcast address. Remember, I moved my networks around and the broadcast address is 172.16.1.255. The default is 172.16.2.255.

{
    "name": "KasaPython",
    "enableCredentials": false,
    "powerStrip": false,
    "additionalBroadcasts": [
        "172.16.1.255"
    ],
    "_bridge": {
        "username": "0E:8E:7A:DD:A5:97",
        "port": 43811
    },
    "platform": "KasaPython"
}

homebridge-kasa-python.log.txt

smithmarcw commented 2 weeks ago

Here are logs for address discovery. It looks like it finds the device, but can't be added. Device being added is 172.16.1.139

{
    "name": "KasaPython",
    "enableCredentials": false,
    "powerStrip": false,
    "manualDevices": [
        "172.16.1.139"
    ],
    "_bridge": {
        "username": "0E:8E:7A:DD:A5:97",
        "port": 43811
    },
    "platform": "KasaPython"
}

NOTICE TO USERS AND PLUGIN DEVELOPERS

Homebridge 2.0 is on the way and brings some breaking changes to existing plugins. Please visit the following link to learn more about the changes and how to prepare: https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Starting python environment check... [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Running command: python3 --version [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command PID: 65516 [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/python3 /homebridge/node_modules/homebridge-kasa-python/dist/python/pythonHome.py [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command PID: 65517 [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Running command: python3 /homebridge/node_modules/homebridge-kasa-python/dist/python/pythonHome.py [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command PID: 65518 [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 --version [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command PID: 65519 [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 freeze [11/15/2024, 9:29:04 AM] [KasaPython] [Python Check] Command PID: 65520 [11/15/2024, 9:29:05 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:05 AM] [KasaPython] [Python Check] Running command: /var/lib/homebridge/kasa-python/.venv/bin/pip3 install -r /homebridge/node_modules/homebridge-kasa-python/requirements.txt [11/15/2024, 9:29:05 AM] [KasaPython] [Python Check] Command PID: 65521 [11/15/2024, 9:29:05 AM] [KasaPython] [Python Check] Command finished. [11/15/2024, 9:29:05 AM] [KasaPython] [Python Check] Finished python environment check. [11/15/2024, 9:29:05 AM] [KasaPython] Logging server started on port 33077 [11/15/2024, 9:29:05 AM] [KasaPython] Running command: /var/lib/homebridge/kasa-python/.venv/bin/python3 /var/lib/homebridge/node_modules/homebridge-kasa-python/dist/python/kasaApi.py 33873 [11/15/2024, 9:29:05 AM] [KasaPython] Command PID: 65524 [11/15/2024, 9:29:05 AM] [KasaPython] Command started. [11/15/2024, 9:29:06 AM] [KasaPython] 2024-11-15 09:29:06.455 | INFO | main::192 - Starting server on port 33873 [11/15/2024, 9:29:11 AM] [KasaPython] Discovering devices... [11/15/2024, 9:29:11 AM] [KasaPython] Sending discovery request with additionalBroadcasts: [], and manualDevices: ["172.16.1.139"] [11/15/2024, 9:29:11 AM] [KasaPython] 2024-11-15 09:29:11.459 | DEBUG | main:discover:167 - Starting device discovery with additionalBroadcasts: [] and manualDevices: ['172.16.1.139'] [11/15/2024, 9:29:11 AM] [KasaPython] 2024-11-15 09:29:11.462 | DEBUG | main:discover_devices:54 - Starting device discovery [11/15/2024, 9:29:11 AM] [KasaPython] 2024-11-15 09:29:11.464 | DEBUG | main:discover_devices:60 - Discovering devices on broadcast: 255.255.255.255 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.542 | DEBUG | main:discover_devices:64 - Discovered 2 devices on broadcast 255.255.255.255 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.545 | DEBUG | main:discover_devices:71 - Discovering manual device: 172.16.1.139 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.555 | DEBUG | main:discover_devices:75 - Discovered manual device: 172.16.1.139 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.558 | DEBUG | main:update_device_info:105 - Updating device info for 172.16.2.50 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.560 | DEBUG | main:update_device_info:105 - Updating device info for 172.16.1.139 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.597 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Plug at 172.16.1.139 - Entry Kasa (EP25(US))> [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.600 | DEBUG | main:update_device_info:114 - Updated device info for 172.16.1.139 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.613 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Strip at 172.16.2.50 - TP-LINK_Smart Plug_20A8 (EP40(US))> [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.616 | DEBUG | main:update_device_info:114 - Updated device info for 172.16.2.50 [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.618 | DEBUG | main:discover_devices:101 - Device discovery completed with 2 devices found [11/15/2024, 9:29:16 AM] [KasaPython] 2024-11-15 09:29:16.620 | DEBUG | main:discover:169 - Device discovery completed with 2 devices found [11/15/2024, 9:29:16 AM] [KasaPython] Devices discovered: 2 [11/15/2024, 9:29:16 AM] [KasaPython] Adding: [Entry Kasa] IOT.SMARTPLUGSWITCH [80066260040F711445AEEA79F35EFE8521A74FE2] [11/15/2024, 9:29:16 AM] [KasaPython] [Entry Kasa] Existing Accessory found [80066260040F711445AEEA79F35EFE8521A74FE2] [fe7c3c49-a82c-4d8f-97a2-9ecb28112009] category: OUTLET [11/15/2024, 9:29:16 AM] [KasaPython] Adding: [Smart Plug 20A8] IOT.SMARTPLUGSWITCH [80068CA5E49793D1E684A461C4BA79B71FEF709A] [11/15/2024, 9:29:16 AM] [KasaPython] [Smart Plug 20A8] Existing Accessory found [80068CA5E49793D1E684A461C4BA79B71FEF709A] [02fa4449-7986-49cc-9526-2fe675759917] category: OUTLET [11/15/2024, 9:29:21 AM] [KasaPython] [Entry Kasa] executing deferred getSysInfo count: 1 [11/15/2024, 9:29:21 AM] [KasaPython] [Smart Plug 20A8] executing deferred getSysInfo count: 1 [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.730 | DEBUG | main:get_sys_info_route:176 - Getting system info for device config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.1.139', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.734 | DEBUG | main:get_device_info:121 - Getting device info for config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.1.139', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.810 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Plug at 172.16.1.139 - Entry Kasa (EP25(US))> [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.814 | DEBUG | main:get_sys_info_route:176 - Getting system info for device config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.2.50', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.817 | DEBUG | main:get_device_info:121 - Getting device info for config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.2.50', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:21 AM] [KasaPython] 2024-11-15 09:29:21.990 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Strip at 172.16.2.50 - TP-LINK_Smart Plug_20A8 (EP40(US))> [11/15/2024, 9:29:26 AM] [KasaPython] [Entry Kasa] executing deferred getSysInfo count: 1 [11/15/2024, 9:29:26 AM] [KasaPython] [Smart Plug 20A8] executing deferred getSysInfo count: 1 [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.732 | DEBUG | main:get_sys_info_route:176 - Getting system info for device config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.1.139', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.734 | DEBUG | main:get_device_info:121 - Getting device info for config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.1.139', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.814 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Plug at 172.16.1.139 - Entry Kasa (EP25(US))> [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.818 | DEBUG | main:get_sys_info_route:176 - Getting system info for device config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.2.50', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.821 | DEBUG | main:get_device_info:121 - Getting device info for config: {'connection_type': {'device_family': 'IOT.SMARTPLUGSWITCH', 'encryption_type': 'XOR', 'https': False}, 'host': '172.16.2.50', 'timeout': 5, 'uses_http': False} [11/15/2024, 9:29:26 AM] [KasaPython] 2024-11-15 09:29:26.997 | DEBUG | main:custom_device_serializer:37 - Serializing device: <DeviceType.Strip at 172.16.2.50 - TP-LINK_Smart Plug_20A8 (EP40(US))> [11/15/2024, 9:29:31 AM] [KasaPython] [Entry Kasa] executing deferred getSysInfo count: 1

ZeliardM commented 2 weeks ago

Ok, so it does not find the devices using the additional broadcast, but we figured that with the VLAN's. It finds 2 devices on the default broadcast and the 1 manual device but only adds one of the devices from the default broadcast and the manual device. I believe you had three devices on the network originally that were being discovered, what is the makeup of devices between the two networks now? can you run a manual discovery for each device: /var/lib/homebridge/ cd kasa-python source .venv/bin/activate kasa --version kasa --target (Each Device IP) discover

Trying to find out the differences in the device information and why it's discovering it, but not adding it. Will add some more logging as well.

ZeliardM commented 2 weeks ago

v2.5.5 with some additional logging for device type filtering

ZeliardM commented 2 weeks ago

v2.5.6 with additional fixes for the different classifications for device types

ZeliardM commented 1 week ago

@smithmarcw Any luck with 2.5.6?

smithmarcw commented 1 week ago

So some good news and bad..

The good news is I can discover and control devices using manual devices here is the log homebridge-kasa-python.log(4).txt

The bad news is, additional broadcast addresses still doesn't work. homebridge-kasa-python (2).log

Nice work!

ZeliardM commented 1 week ago

And the additional broadcast for you is across VLAN's is that correct? If so, then manual entry will be the only way to handle that device unless the firewall configuration can be updated to allow udp and mdns traffic across the vlans. I don't implement something like this myself so it would be difficult to test successfully and would be a local configuration outside of the scope of the plugin itself. I'm glad that we were able to get the manual discovery working and that functionality is working now. If you're satisfied with the state of things, I will close this issue on my end. I will keep updating the plugin for additional device support and thank you for your help in troubleshooting the issues.

smithmarcw commented 1 week ago

Yes, it's across VLANs. Thanks so much for your work.

ZeliardM commented 1 week ago

No problem, if you need anything else, open another issue and we can work through it.

ZeliardM commented 3 days ago

@smithmarcw let me know if the latest versions of the plugin still work for your manual devices, please and thank you!