eschava / broadlink-mqtt

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

[Errno 10061] #30

Closed pabloreadi closed 6 years ago

pabloreadi commented 6 years ago

Hello, I run mqtt.py with python and I receive this error. Can you help me?

[2018-06-25 17:14:31,868] DEBUG Connected to RM2 Broadlink device at '192.168.1.108' (MAC 78:0f:77:00:b6:34)

Traceback (most recent call last): File "C:\Python27\broadlink-mqtt-master\mqtt.py", line 385, in mqttc.connect(cf.get('mqtt_broker', 'localhost'), int(cf.get('mqtt_port', '1883')), 60) File "C:\Python27\lib\site-packages\paho\mqtt\client.py", line 768, in connect return self.reconnect() File "C:\Python27\lib\site-packages\paho\mqtt\client.py", line 895, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "C:\Python27\lib\socket.py", line 575, in create_connection raise err error: [Errno 10061] No se puede establecer una conexión ya que el equipo de destino denegó expresamente dicha conexión

eschava commented 6 years ago

Could you please show your configuration? Did you get it once or every time?

pabloreadi commented 6 years ago

OK, this is my configuration. I try to use direct connection but have the same error. I get it once.

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

## lookup parameters
lookup_timeout = 20
#local_address = '127.0.0.1'

## parameters for direct connection
#device_host = '192.168.1.108'
#device_mac  = '78:0f:77:00:b6:34'

## MQTT connection parameters
mqtt_broker = 'localhost'       # default: 'localhost'
mqtt_port = 1883                # default: 1883
mqtt_clientid = 'broadlink'
mqtt_username = ''
mqtt_password = ''
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 TLS parameters
# Required with TLS: a string path to the Certificate Authority certificate files that are to be treated as trusted by this client.
# ca_certs = '/path/to/ca_certsfile'
# Optional Clients Cert/Key
# certfile = '/path/to/certfile'
# keyfile  = '/path/to/keyfile'
# Required TLS version. Valid values: 'sslv3', 'tlsv1', 'tlsv1.2'
# tls_version = 'tlsv1.2'

## extra parameters
broadlink_rm_temperature_interval = 120 # publish temperature from RM device to broadlink/temperature topic every two minutes
broadlink_sp_energy_interval = 30 # publish energy from SP device to broadlink/energy topic every 30 seconds
broadlink_a1_sensors_interval = 30 # publish all sensors data from A1 device to broadlink/sensors/[temperature/humidity/light/air_quality/noise] topics every 30 seconds
broadlink_a1_sensors_text_values = False # use True to send text representation of light/air quality/noise values
broadlink_a1_sensors_json = False # False to send every sensor parameter in separate topic, True - to send all together as JSON object
eschava commented 6 years ago

Thanks Did you try using Broadlink application on the mobile phone?

pabloreadi commented 6 years ago

Yes, it is ok

eschava commented 6 years ago

Oh, sorry There is an error with connection MQTT broker, not Broadlink device

Do you have MQTT broker run on local or any other computer in your network?

pabloreadi commented 6 years ago

Yes, I have mqtt broker running in other computer in my network. I did a ping to 192.168.1.108 and it's ok

Haciendo ping a 192.168.1.108 con 32 bytes de datos: Respuesta desde 192.168.1.108: bytes=32 tiempo=2ms TTL=255 Respuesta desde 192.168.1.108: bytes=32 tiempo=2ms TTL=255 Respuesta desde 192.168.1.108: bytes=32 tiempo=2ms TTL=255 Respuesta desde 192.168.1.108: bytes=32 tiempo=2ms TTL=255

Estadísticas de ping para 192.168.1.108: Paquetes: enviados = 4, recibidos = 4, perdidos = 0 (0% perdidos), Tiempos aproximados de ida y vuelta en milisegundos: Mínimo = 2ms, Máximo = 2ms, Media = 2ms

eschava commented 6 years ago

Then you need to specify correct connection parameters in the config

mqtt_broker = 'localhost'       # default: 'localhost'
mqtt_port = 1883                # default: 1883
mqtt_clientid = 'broadlink'
pabloreadi commented 6 years ago

I need to open the 1883 port in firewall? I opened it in tcp protocol

eschava commented 6 years ago

Sorry, you said you have mqtt broker at another computer You have to specify the address of that computer in the mqtt_broker config parameter By default it has "localhost"

pabloreadi commented 6 years ago

I put the same ip of the computer, but i have the same error...

mqtt_broker = '192.168.1.106' # default: 'localhost' mqtt_port = 1883 # default: 1883 mqtt_clientid = 'broadlink'

pabloreadi commented 6 years ago

Sorry, I put the ip and the port correctly (150). Now I have another error (debug oooops! broadlink disconnects), then I'm going to close this issue and open another if I don't find in another issues.

eschava commented 6 years ago

PLease check issue #7 , it could be related