eschava / broadlink-mqtt

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

No json response #69

Closed cgorms closed 4 years ago

cgorms commented 4 years ago

I run mqtt.py it discovers devices but I don't get any json response relating to the state of socket etc

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/#

cgorms commented 4 years ago

Edited mqtt.conf and changed 'broadlink_bg1_state_json = True' and received this when running mqtt.py

DEBUG Sending BG1 state 'null' to topic 'broadlink/BG1_00_00_00/state'

cgorms commented 4 years ago

PIP Package Versions...
 python 2.7
 cryptography 2.6.1
 paho-mqtt 1.5.0
 pycrc 0.9.2
 broadlink 0.12.0

Additionally I've installed git+https://github.com/barnybug/python-broadlink@add_bgelectrical_sockets

Can someone shed some light on my issue?

eschava commented 4 years ago

It's clear that bg1.get_state() returns None And it seems we already discussed such issue, didn't we?

cgorms commented 4 years ago

Hi I must apologies, if we have spoke about this previously... I have forgotten what the reason was. Please below my install process, can you tell me where I’ve possibly gone wrong??

Install MQTT sudo apt-get install -y gcc g++ make python git wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key cd /etc/apt/sources.list.d/ sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list sudo apt-get update sudo apt-get install mosquitto

Installing pip for Python 2 sudo apt-get install python-pip

Install Broadlink-mqtt cd /opt sudo git clone https://github.com/eschava/broadlink-mqtt.git cd broadlink-mqtt sudo pip install -r requirements.txt sudo pip install git+https://github.com/barnybug/python-broadlink@add_bgelectrical_sockets

sudo nano /opt/broadlink-mqtt/mqtt.conf Amend the file with 'multiple_lookup'

sudo /opt/broadlink-mqtt/mqtt.py

cgorms commented 4 years ago

ERROR Error Traceback (most recent call last): File "mqtt.py", line 548, in broadlink_bg1_state_timer state = device.get_state() File "/usr/local/lib/python3.8/site-packages/broadlink/init.py", line 367, in get_state response = self.send_packet(0x6a, packet) File "/usr/local/lib/python3.8/site-packages/broadlink/init.py", line 283, in send_packet response = self.cs.recvfrom(2048) socket.timeout: timed 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.

eschava commented 4 years ago

Thanks a lot for sharing your experience!