eschava / broadlink-mqtt

MQTT client to control BroadLink devices
MIT License
221 stars 60 forks source link

ERROR No Broadlink device found #76

Closed utech-git closed 4 years ago

utech-git commented 4 years ago

Hello,

I am trying to use it with "lookup" device type (because I can't set a fixed IP for my broadlink on my router) but I am getting the error: ERROR No Broadlink device found

Here's my custom.conf

# Type of device. Valid options are 'lookup', 'multiple_lookup', 'rm', 'rm4', 'sp1', 'sp2', 'a1', 'mp1', 'dooya', 'bg1'
device_type = 'lookup' # use lookup

# lookup parameters
lookup_timeout = 20
local_address = '127.0.0.1'

# parameters for direct connection
#device_host = ''
#device_mac  = ''

# MQTT connection parameters
mqtt_broker = 'localhost'       # default: 'localhost'
mqtt_port = 1883                # default: 1883
mqtt_clientid = 'broadlink'
mqtt_username = 'XXXXXXX'
mqtt_password = 'YYYYYYY'
mqtt_topic_prefix = 'broadlink/'
mqtt_multiple_subprefix_format = '{type}_{mac_nic}/' # use only with 'multiple_lookup' device type (allowed parameters are {type}, {host}, {mac}, {mac_nic})
#mqtt_birth_topic = 'clients/broadlink'
#mqtt_birth_payload = 'Hello!'
mqtt_will_topic = 'clients/broadlink'
mqtt_will_payload = 'Adios!'

When I log into my routers config page, get the IP address, set it on "device_host" along with "device_mac" everything works OK. But I can't rely on that because every now and then my router changes the broadlink's IP.

It is possible to use broadlink-mqtt without static IP, right? What am I doing wrong??

Thanks.

utech-git commented 4 years ago

Ok, I found out. Actually my raspberry pi was connected to a VPN I forgot about. When trying to "lookup" for the broadlink it was probably using the network interface from the VPN instead of the "regular" interface on the same network as the broadlink.

After disabling the VPN interface it was working again.

Now I need to make it work with the VPN interface enabled. Any ideas? Maybe I could set an IPtables rule that when connecting on specific port it has to use the "regular" interface (instead of the VPN)... Anyone knows what port broadlink-mqtt uses to both "lookup" and to connect to broadlink devices?

Thanks.

utech-git commented 4 years ago

If someone stumble upon this on the future: I figured out that my clients VPN connection config file was explicitly forcing any traffic out from the VPN interface (AllowedIPs = 0.0.0.0/0). After changing that to the IP of the VPN (111.222.0.1/24 or whatever IP you set to your VPN), everything seems to be working now.

eschava commented 4 years ago

There is local_address parameter in the config Please set there IP of the computer (not Broadlink device) provided by the router