nitaybz / homebridge-switcher-platform

Homebridge plugin for Switcher Smart Accessories
MIT License
35 stars 9 forks source link

Plugin not adding devices even when explicitly given IP Address #38

Closed Knilo closed 1 year ago

Knilo commented 1 year ago

Hi,

Until recentley I had this plugin working well on Raspberry Pi. Upon installing OpenVPN on the Pi, the plugin no longer identifies switcher devices on the network. All other plugins work (both when a VPN is on and when not). I changed the iptables slightly to enable the Pi to be a gateway device.

Both the Pi and the device are on the same subnet. The Pi can ping the ip address of the switch.

There are no other logs (when in debug) besides: [23/01/2023, 21:40:28] [Switcher Platform] Scanning for switcher devices...

This is the result of iptables -S -P INPUT DROP -P FORWARD DROP -P OUTPUT ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -i eth0 -p icmp -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i eth0 -o tun0 -j ACCEPT -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

and the output of iptables -L -v:

Chain INPUT (policy DROP 357K packets, 100M bytes) pkts bytes target prot opt in out source destination 78021 10M ACCEPT all -- lo any anywhere anywhere 23 2508 ACCEPT icmp -- eth0 any anywhere anywhere 0 0 ACCEPT tcp -- eth0 any anywhere anywhere tcp dpt:ssh 124K 108M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 ACCEPT all -- eth0 tun0 anywhere anywhere 0 0 ACCEPT all -- tun0 eth0 anywhere anywhere state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT 291K packets, 49M bytes) pkts bytes target prot opt in out source destination

Here is the config. I added the ip address to try force the device to be added but that didn't work: { "name": "Switcher Platform", "debug": true, "secondsToRemove": 0, "devices": [ { "identifier": "10.0.0.5", "accessoryType": "valve" } ], "customTimers": [ { "identifier": "eddf64", "shutdownMinutes": 30 } ], "platform": "SwitcherPlatform"

Any idea how to debug this? Or what might be stopping the plugin from identifying the device?

nitaybz commented 1 year ago

Specifying the ip is only good for specific device configurations, not for detecting devices.

In order to detect the device the plugin is listening on specific port for broadcast messages from the device.

I guess it's not really listening on the same network after all

Knilo commented 1 year ago

Hi Nitay, what is the port? I was looking through switcher-js2 ans saw these definitions:

const SWITCHER_UDP_PORT = 20002; const SWITCHER_UDP_PORT2 = 20003;

const SWITCHER_TCP_PORT = 9957; const SWITCHER_TCP_PORT2 = 10000;

nitaybz commented 1 year ago

The first 2 is for listening and the 3rd and 4th are for connecting to the device

Knilo commented 1 year ago

@nitaybz FYI, I solved the issue by adding a rule to my iptables to accept incoming UDP connections. Thanks for you help!