eschava / broadlink-mqtt

MQTT client to control BroadLink devices
MIT License
224 stars 61 forks source link

Issue with subscribing to broker mqtt.py #68

Closed cgorms closed 4 years ago

cgorms commented 4 years ago

When I run mqtt.py all I get is the following...

DEBUG Connected to 'BG1' Broadlink device at '192.168.0.1' (MAC 00:00:00:00:00:00) and started listening for commands at MQTT topic having prefix 'broadlink/BG1_00_00_00/' DEBUG Connected to MQTT broker, subscribing to topic broadlink/#

I then check the /var/log/mosquitto/mosquitto.log

mosquitto version 1.6.8 starting Config loaded from /etc/mosquitto/mosquitto.conf. Opening ipv4 listen socket on port 1883. Opening ipv6 listen socket on port 1883. New connection from ::1 on port 1883. New client connected from ::1 as broadlink (p2, c0, k60). Socket error on client broadlink, disconnecting.

eschava commented 4 years ago

It isn't a broadlink-mqtt issue. It's something related to mosquitto Have you tried to google about this issue? I did and found that it could be related to incorrect credentials used for connection

E.g. https://github.com/eclipse/mosquitto/issues/523#issuecomment-384449673 https://stackoverflow.com/questions/35704632/mqtt-socket-error-on-client-unknown

cgorms commented 4 years ago

The issue I think I'm having is I'm not seeing any mqtt subscribe messages...

When I run mqtt.py this happens

DEBUG Connected to 'BG1' Broadlink device at '192.168.0.1' (MAC 00:00:00:00:00:00) and started listening for commands at MQTT topic having prefix 'broadlink/BG1_00_00_00/' DEBUG Connected to MQTT broker, subscribing to topic broadlink/#

But there is no additional debug information with the regards the subscribing i.e. power state, brightness etc...

I can publish a command but the BG1 doesn't respond... DEBUG Received MQTT message broadlink/BG1_00_00_00/power/2 on DEBUG Setting power state of socket 2 to True

cgorms commented 4 years ago

Run mosquitto -v and this was the output

New connection from ::1 on port 1883. New client connected from ::1 as broadlink (p2, c0, k60, u'mqtt'). Will message specified (6 bytes) (r0, q0). clients/broadlink Sending CONNACK to broadlink (0, 0) Received SUBSCRIBE from broadlink broadlink/# (QoS 0) broadlink 0 broadlink/# Sending SUBACK to broadlink

But nothing else with regards broadlink following that, BG1 device don't appear to be publishing to mqtt... from what I can work out.

cgorms commented 4 years ago

RESOLVED

BG1 devices connected to broadlink cloud via BG App worked for serval days and then stopped broadcasting their device state via LAN.

Resetting the sockets with the following sequences:

Pressing the left power button and connecting via ‘Smart Config’ or ‘AP Config’ within the app made no difference to the sockets broadcasting their state etc.

I finally resolved the issue by putting the socket into AP Config mode and pulled down python-broadlink on to a laptop. Connected the laptop to the AP SSID of the socket and run ‘broadlink_cli --joinwifi ’ command to connect the socket to my Wi-fi but not the broadlink cloud.

Sockets started broadcasting on LAN and broadlink-mqtt worked as expected again.