eschava / broadlink-mqtt

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

BG1 issues #47

Closed cgorms closed 4 years ago

cgorms commented 4 years ago

Noob question how do I add broadlink-mqtt to MQTT and control the BG1 devices...

Many thanks in advance

eschava commented 4 years ago

For the device having two outlets commands are: Payload "on" to topic "broadlink/power/1" to switch on the first outlet, "off" -> "broadlink/power/1" switch off first, "on" -> "broadlink/power/2" switch on second, "off" -> "broadlink/power/2" switch off second.

cgorms commented 4 years ago

I have amended the MQTT.conf file to multiple_lookup as I have 2 BG1 devices.

When I run mqtt.py it discovers both devices and provides me with the PREFIX's for them, but how do I call each one within MQTT?

I also get the following error... DEBUG Connected! to MQTT broker, subscribing to topic broadlink/# DEBUG OOOPS! Broadlink disconnects DEBUG Connected! to MQTT broker, subscribing to topic broadlink/# ERROR error Traceback (most recent call later): File"./mqtt.py", line 510, in broadlink_bg1_state_timer for name in state: TypeError: 'NoneType' object is not iterable

eschava commented 4 years ago

Prefix (with default configuration) should look like broadlink/BG1_03_02_01 And you should use not broadlink/power/ topics, but broadlink/BG1_03_02_01/power/.... instead. E.g. "off" -> "broadlink/BG1_03_02_01/power/1" to switch off first outlet

I also get the following error... DEBUG Connected! to MQTT broker, subscribing to topic broadlink/# DEBUG OOOPS! Broadlink disconnects DEBUG Connected! to MQTT broker, subscribing to topic broadlink/#

Constant reconnection usually happens when you started two instances of broadlink-mqtt script. Could it be a problem?

ERROR error Traceback (most recent call later): File"./mqtt.py", line 510, in broadlink_bg1_state_timer for name in state: TypeError: 'NoneType' object is not iterable

This happens because no information was received from BG1 device. It could have the same reason as above but JIC I've added a fix to do not print an error in this case

cgorms commented 4 years ago

Updated my local files, thank you. I’ve followed what you said but no joy yet. Here is my json file details...

"broadlink": { "id": "broadlink", "name": "bg1_plugs", "manufacturer": "BG Electrical", "topicIdentify": "broadlink/#", "category": 7, "services": [ { "name": "Bedroom1", "service": "Outlet", "topic": { "setOn": "broadlink/BG1_01_02_03/power/1", "statusOn": "broadlink/BG1_01_02_03/state", "statusOutletInUse": "" }, "json": { "statusOn": "", "statusOutletInUse": "" }, "payload": { "onFalse": "off", "onTrue": "on" }, "config": {}, "props": {} } ], "payload": {}, "config": {} }

cgorms commented 4 years ago

2D25DE24-5A28-4E44-955F-2CBAFC16C595

eschava commented 4 years ago

All looks correct, MQTT commands are received by the script and processed but nothing happens, right? Also if you have broadlink_bg1_state_interval configuration parameter specified then BG1 devices state should be sent via MQTT periodically and be visible in logs. Something is wrong here

@vzorglub Do you have any ideas?

vzorglub commented 4 years ago

Yes, the bg code hasn't been merged in the main repository yet. You need to use the branch

cgorms commented 4 years ago

Correct nothing is happening with the outlet... broadlink_bg1_state_interval is set to 30.

I'm not sure what maybe going wrong... where can I check as you say I can see the commands being processed and broadlink_MQTT is identifying the devices.

cgorms commented 4 years ago

Yes, the bg code hasn't been merged in the main repository yet. You need to use the branch

What branch is required? I've installed...

git clone https://github.com/eschava/broadlink-mqtt.git pip install git+https://github.com/barnybug/python-broadlink@add_bgelectrical_sockets

eschava commented 4 years ago

@barnybug, sorry for disturbing you Do you have ideas about what could go wrong? Devices were identified correctly but get_state returns None and set_state does nothing

barnybug commented 4 years ago

I don't have anything to go on - someone needs to debug it, so I either need more debugging information to go on (python-broadlink has no useful logging), or someone to send me a non-working device.

cgorms commented 4 years ago

Where can I get debugging info from?

cgorms commented 4 years ago

What repository do I need to confirm are installed?

eschava commented 4 years ago

If your device was correctly identified then definitely you have correct libraries installed

cgorms commented 4 years ago

https://github.com/mjg59/python-broadlink/issues/289#issuecomment-541460611

You mention here, you got it working... how did you do that?

cgorms commented 4 years ago

Firmware version on the devices are V46043

cgorms commented 4 years ago

I used Hoobs on a clean install and did the installation all over again and it is now working.