eschava / broadlink-mqtt

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

Device recognised as unknown #45

Closed vzorglub closed 4 years ago

vzorglub commented 4 years ago

Hi, I have purchased this device: https://www.bgelectrical.uk/smart-sockets

After a bit of digging, I found out that they use a broadlink chip:

https://community.home-assistant.io/t/uk-wifi-smart-socket-screwfix-testing/119995/5

So I though I would try using your broadlink-mqtt

Kind of works:

pi@piup:~/broadlink-mqtt $ pi@piup:~/broadlink-mqtt $ python mqtt.py
[2019-10-09 10:27:40,822] DEBUG Connected to 'Unknown' Broadlink device at '192.168.0.99' (MAC c8:f7:42:fc:e5:45) and started listening for commands at MQTT topic having prefix 'broadlink/'
[2019-10-09 10:27:40,834] DEBUG Connected to MQTT broker, subscribing to topic broadlink/#

So, it connects to the device but it is unknown It has two sockets so I tried to force the config as an MP1 device. No dice It tried as a single socket SP1 and then SP2. No dice

It connects, so there must be a way. I have a spare device that I can send by post I can also send debug logs or whatever is needed

Thanks

eschava commented 4 years ago

I think it's better to ask this question at the issue tracker of the parent project https://github.com/mjg59/python-broadlink

If they will add support for this device then it shouldn't be a problem support it at broadlink-mqtt

eschava commented 4 years ago

Also could you please execute next command and post output here? python import broadlink print hex(broadlink.discover(timeout=10)[0].devtype)

vzorglub commented 4 years ago

0x51e3

vzorglub commented 4 years ago

I have raised an issue on the broadlink repo: https://github.com/mjg59/python-broadlink/issues/289

eschava commented 4 years ago

Thanks

vzorglub commented 4 years ago

There is a pull request on the base project for the device here: https://github.com/mjg59/python-broadlink/pull/290 I have a working version of your code working on my machine with the device added including a command for the LED brightness and I kept the same topic structure as the MP1 device What do I do now?

eschava commented 4 years ago

Could you please create a pull request for your changes? Also, it isn't clear what get_state method returns. Do you have an example of output? I need it to correctly implement sending current device state periodically

eschava commented 4 years ago

Committed reading of state parameters from BG1 device, please test

vzorglub commented 4 years ago

@eschava Could you please create a pull request for your changes?

How do I do that?

vzorglub commented 4 years ago

I don't know exactly what you added in the file so I can't add your state code in mine I'll wait for a full version from you to test

eschava commented 4 years ago

Merged, please update

vzorglub commented 4 years ago

All working Tested with json False and True Both working

Thanks a lot

eschava commented 4 years ago

Welcome!