homebridge-ewelink
homebridge-ewelink copied to clipboard
IP update behavior can incorrectly assign a forwarder IP instead of the actual device IP
What issue do you have? Please be as thorough and explicit as possible.
Line 94 of lan.js tests if the packet address matches the device info. If it doesn't, line 95 assigns the packet IP to the device info. However, in complex networks (especially those with multiple subnets) this packet address may not actually be the device address! In my network, packet.address
is the router address. This means that when the device info IP is updated, it is replaced with my router IP address, which causes the plugin to then send update requests to my router instead of my ewelink devices. In the logs, I am presented with a device unreachable error with my router's IP address.
Tested workaround:
As a workaround, I simply commented out line 95. This stopped the IP from being reassigned to my router IP, and restores correct LAN control behavior on my network.
Proposed fix:
Note that I am using DHCP reservations for all of my ewelink devices, and I am using static IP configuration within the plugin. The above workaround could negatively impact people with simple DHCP setups and no static plugin configuration. Instead, I would propose either of two more appropriate fixes:
- Parse the packet for the true origin IP instead of using the packet IP (assuming dns-sd packets include this information.)
- Check if static IP plugin configuration is being used for that device, and if so, do not attempt to update the IP at all.
I would submit a PR for one of these fixes, but I'm not yet familiar enough with the plugin structure and dns-sd to implement them properly myself.
Details of your setup.
-
Do you use (1) Homebridge UI-X (2) Homebridge CLI or (3) HOOBS? Homebridge UI-X
-
Which version of Homebridge/HOOBS do you have? v1.6.1
-
Which platform do you run Homebridge/HOOBS on (e.g. Raspberry Pi/Windows/HOOBS Box)? Please also mention your version of Node.js/NPM if known. Run in a ProxMox container, with Node.js v20.5.1
-
Which version of this plugin (homebridge-ewelink) do you have? Has the issue started since upgrading from a previous version? v12.0.0
-
Which eWeLink devices do you have that are causing issues? Please include product models if applicable. Sonoff iFan-04
Hi @trevorirwin thanks for the issue here
I made some changes here: https://github.com/bwp91/homebridge-ewelink/commit/70f8c1eb0c04f471b60074e5e221e8f5e9317ca2
and posted a new beta version of the plugin, could you try this?
Hi @bwp91,
I've installed and tested the beta. It is working, with no errors in the logs. However, there is unexpected output in the logs just after initialization:
[10/25/2023, 5:30:50 PM] [eWeLink] [Living Room Fan] changed IP address to [MY_ROUTER_IP].
and periodically:
[10/25/2023, 5:33:06 PM] [eWeLink] [Living Room Fan] receiving update {"light":"on","fan":"off","speed":1,"ip":"MY_ROUTER_IP","online":true,"updateSource":"LAN"}.
(I've replaced the actual router IP in both messages with MY_ROUTER_IP
)