Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Clipsal Control Link and Wiser Room #1

Open
asomervell opened this issue Jan 24, 2018 · 61 comments
Open

Support Clipsal Control Link and Wiser Room #1

asomervell opened this issue Jan 24, 2018 · 61 comments

Comments

@asomervell
Copy link

Clipsal has released their very low cost "Iconic" range of light switches that will replace the old school ones you see in every house.

They have "mechs" that are programmable by BLE and work together in a room.

https://www.clipsal.com/iconic#new-technology

We must be able to intercept or control them by BLE with the homebridge for epic dimmer and power and lighting control in AU, NZ!

https://www.youtube.com/watch?v=TMt_zeA56LI

http://www.clipsal.com/Trade/Products/ProductDetail?CatNo=41EPBM

@asomervell
Copy link
Author

@kenhuang
Copy link
Owner

Just need another plugin: https://github.com/anthonywebb/homebridge-cbus

@asomervell
Copy link
Author

asomervell commented Jan 24, 2018

Mmmm cbus != BLE with new stuff though. Maybe they do talk.

NZ Site and brand
https://www.pdl.co.nz/Trade/Ranges/Products/Switch-Socket-Ranges/Iconic

Maybe the Saturn brand is the one to go with that does do cbus
https://www.pdl.co.nz/Trade/Ranges/Products/Switch-Socket-Ranges/Saturn-Zen
http://updates.clipsal.com/ClipsalOnline/Files/Brochures/A0000291.pdf

On further investigation, cbus requires you to wire everything back to controllers (rewire the house). But I can see exactly how if that was done in the first place you'd be stoked with that integration!

@sj26
Copy link

sj26 commented Jul 12, 2019

I’m planning to install Clipsal Iconic BLE switches into my new apartment. I’m already using homebridge quite a bit, so I’ll probably write a homebridge plug-in. I’m writing this partly to advertise my interest and intent, but also to know if someone beats me to it. :-)

@sj26
Copy link

sj26 commented Jul 12, 2019

It looks like there’s already a plug-in for wiser, but nothing to directly control the ble switches yet:

https://github.com/paulw11/homebridge-wiser

@CalumOchkas
Copy link

Hey @sj26 - did you have any luck with this? About to buy a whole heap of switches in the next few days, wondering if I should invest in the BLE options

@sj26
Copy link

sj26 commented Aug 20, 2019

I haven't managed to grab any BLE switches myself yet, sorry. :-(

@sj26
Copy link

sj26 commented Aug 20, 2019

It sounds like installing the Iconic stuff is a good, future-proof plan, though. The mechanisms can be swapped out for BLE options later. And there are rumours that Clipsal may end up offering direct HomeKit and other integrations themselves.

@CalumOchkas
Copy link

Don't be sorry! Let us know if you have any luck once you get your hands on one. I'll grab just one for now so I can start playing, and I'll do the same!

@RobDeVoer
Copy link

Trying to decide to get PDL/Schneider iconic range for my new home or not. Unless there are any updates since Aug 2019 I think I may just opt to place SONOFF MINIS behind my switches and either control those through my own code or a Home Assistant setup. All advice/critique is welcome. Only 1-2 weeks away from getting the gib on the walls... ;)

@CalumOchkas
Copy link

CalumOchkas commented Mar 13, 2020 via email

@RobDeVoer
Copy link

RobDeVoer commented Mar 14, 2020

At the moment I am only concerned about remote on/off as we have two lighting sets in each room. Mood lighting (pendants, tiny LED lights, and LED strips) or full light (LED lights in a grid from the ceiling). Dimming may happen in the future although our current system hardly ever asks for dimming as mood lighting is nice and low already. Sounds from your experience I may be better off with the cheap Sonoff mini option.

Am surprised about your experiences with LED dimming since I have done that without any issues before with regular dimmable LED lights.

Big thanks for sharing your experiences!

@joshua-j-morley
Copy link

How has everyone gone with this? I'll be moving in to a house in 2 and a bit weeks with clipsal iconic and the BLE switches
Definitely keen to see if anybody progressed in adapting iconic series for wifi use before i sink some time into it

@phindmarsh
Copy link

I picked up some of the dimmers (under the PDL brand in New Zealand, but they are the Clipsal equivalent and work with the Wiser Room app) and have been poking at the BLE side of things for a few weeks.

I’ve managed to work out the GATT profile allows you to remotely turn it off/on, set the level, and toggle the current state. This works with a generic BLE app off the App Store, but I haven’t yet got it working with with a Raspberry Pi. The services and characteristics have descriptors so it’s pretty easy to find the correct characteristics, but writing the value from python is where I’m stuck.

BFB4AEB6-0895-4667-A338-5B0C2A98CDA5
9D2F089D-D262-47AB-A971-A05D1804AD78

The basic problem seems to be that the underlying Bluetooth library on the Pi disconnects automatically after a few seconds of connecting, sometimes more like 30s, and attempting to write to the characteristics with similar values used in the generic BLE app does nothing.

I’ve also tried sniffing the BLE traffic with the iOS sysdiagnose logging and pulling the actual data that the Wiser app uses, but that’s also been difficult because I’m not really familiar with that level of reverse engineering.

My plan was to first work out how to control them using the CLI on a Pi, then port those commands to python, then wrap that into a home assistant integration. So far I’m still stuck on the “control them with the CLI” part...

I don’t have another device with a Bluetooth stack other than a Pi and a MacBook, and many of the python BLE libs don’t support macOS so my next thing was to try something in Nodejs or something to rule out a bug somewhere in python land. I’m pretty sure the issue is lower down than that, but I’m not that familiar with bluez or the lower level Bluetooth stuff yet.

@sj26
Copy link

sj26 commented Oct 3, 2020

Ooh, nice one @phindmarsh, that's what I was hoping to do. Any chance you could share the gatt profile descriptions in copy pasteable form?

@sj26
Copy link

sj26 commented Oct 3, 2020

Oh I've found the equivalent devices and profiles via the same GATTBrowser app.

Any chance you could share which services/properties you've been poking, and how?

@phindmarsh
Copy link

It’s the section at the bottom that has the control parameters I’ve found so far:

CEA2AF7D-59F7-4857-B407-19E5FC8C8DDB

720A9081 is the on/off, you can write 0x00 for off and 0x01 for on.

720A9082 is set level, which takes a value from 0x0000 for lowest and something like 0x1027 for the highest. Note the value has the bytes flipped, so 0x1010 is like half the level. So something like this:

Low = 0000 = 0x0000
Mid = 1000 = 0x0010
High = 2710 = 0x1027

720A9083 is the toggle, so you can toggle it on/off relative to the current state, and also read the state of the physical button (depressed, undepressed). I haven’t done much with this one though.

The other ones you can read the firmware version, name, etc, but I also haven’t played with those much.

Also make sure you upgrade the firmware via the wiser app first, otherwise it tells you the encryption is insufficient.

The other thing I did was decompile the Android app and tried to read the code but it’s a kotlin app so the decompiled source is not that readable (to me at least!).

The only interesting thing is the Android app seems to use services with a slightly different uuid, one that starts with 720A8081 instead of 720A9081 for example. I haven’t yet poked around the edges of this yet though. I wonder if the app is using services that aren’t advertised like the other ones are.

@phindmarsh
Copy link

Here’s a screen recording for turning the dimmer on/off

https://share.icloud.com/photos/0GsHxG03jcrFJ6aIeza2o51Rg

@sj26
Copy link

sj26 commented Oct 4, 2020

So I can also control my device by reading and writing those properties, which is great!

But I can't do it from any device other than my iPhone.

My iPhone has the Wiser app installed, and has been paired to the switches. I think that's the missing piece — pairing. I need to read some more to figure it out. Maybe I'll try decompiling the android app like you did.

@phindmarsh
Copy link

Ha yeah that’s basically where I am.

I wondered if pairing has something to do with it, but I haven’t yet had the time to unpack that hypothesis yet.

Reading some attributes like firmware seems
to work, and not others. Let me know how you get on!

@sj26
Copy link

sj26 commented Oct 4, 2020

The linux bluetooth tooling is pretty good. I have a usb bluetooth adapter attached to my machine running homebridge. After doing a scan to find the dimmer devices:

sudo hcitool lescan | grep CH
D0:CF:5E:85:48:3D CH-DIMMER_483D

I can see the characteristics for one of my wiser dimmers:

sudo gatttool -b D0:CF:5E:85:48:3D --characteristics
handle = 0x0002, char properties = 0x02, char value handle = 0x0003, uuid = 00002a00-0000-1000-8000-00805f9b34fb
handle = 0x0004, char properties = 0x02, char value handle = 0x0005, uuid = 00002a01-0000-1000-8000-00805f9b34fb
handle = 0x0007, char properties = 0x02, char value handle = 0x0008, uuid = 00002a24-0000-1000-8000-00805f9b34fb
handle = 0x0009, char properties = 0x02, char value handle = 0x000a, uuid = 00002a26-0000-1000-8000-00805f9b34fb
handle = 0x000b, char properties = 0x02, char value handle = 0x000c, uuid = 00002a29-0000-1000-8000-00805f9b34fb
handle = 0x000e, char properties = 0x08, char value handle = 0x000f, uuid = 720a7081-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0011, char properties = 0x12, char value handle = 0x0012, uuid = 720a7082-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0015, char properties = 0x12, char value handle = 0x0016, uuid = 720a7083-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0019, char properties = 0x02, char value handle = 0x001a, uuid = 720a7084-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x001c, char properties = 0x08, char value handle = 0x001d, uuid = 720a7085-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x001f, char properties = 0x12, char value handle = 0x0020, uuid = 720a7086-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0024, char properties = 0x18, char value handle = 0x0025, uuid = f7bf3564-fb6d-4e53-88a4-5e37e0326063
handle = 0x0027, char properties = 0x04, char value handle = 0x0028, uuid = 984227f3-34fc-4045-a5d0-2c581f81a153
handle = 0x002a, char properties = 0x1a, char value handle = 0x002b, uuid = 720a9081-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x002e, char properties = 0x1a, char value handle = 0x002f, uuid = 720a9082-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0032, char properties = 0x1a, char value handle = 0x0033, uuid = 720a9083-9c7d-11e5-a7e3-0002a5d5c51b
handle = 0x0036, char properties = 0x1a, char value handle = 0x0037, uuid = 720a9084-9c7d-11e5-a7e3-0002a5d5c51b

I believe this is the on/off characteristic:

sj26@prowl:~$ sudo gatttool -b D0:CF:5E:85:48:3D --char-read --handle 0x002a
Characteristic value/descriptor: 1a 2b 00 1b c5 d5 a5 02 00 e3 a7 e5 11 7d 9c 81 90 0a 72

Reading via gatttool doesn't show a change after toggling power state, though, so I'm wondering if this value means "unauthorized" or something

@sj26
Copy link

sj26 commented Oct 4, 2020

apktool and ClassyShark are letting me poke around in the android app. There's an interesting "communicationlib" which has lots of BLE implementation. Skimming, I'm confident that the device is paired or bonded to the phone before interaction. It seems to use standard android bond creation gear:

https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createBond()

@sj26
Copy link

sj26 commented Oct 4, 2020

Useful reference on bonding/pairing in BLE: https://www.kynetics.com/docs/2018/BLE_Pairing_and_bonding/

@phindmarsh
Copy link

Yeh I’ve got about as far as reading the characteristics and the handles using a combination of lescan, gattctl, gatttool, and all the different python BLE libraries.

The trick I couldn’t get was being able to write to the chosen characteristic, or find the simple 0x00 or 0x01 values I expected on the on/off characteristic.

Perhaps you are right about the unauthorised response, didn’t think about that. I had tried to MITM or sniff the app traffic to see if there was some kind of handshake or key exchange happening, but then I figured that if I could do it with the generic GATT app it probably wasn’t using proprietary communication.

If you connect with gatttool does it automatically disconnect after a few seconds? I often got segfaults when using the gatttool CLI.

@phindmarsh
Copy link

I also noticed if you unpair/remove one of the dimmers from the Bluetooth settings on the iPhone the GATTBrowser app asks if you want to pair again before you can write data, which would lend more evidence to the fact you have to pair or bond with it first

@sj26
Copy link

sj26 commented Oct 4, 2020

My reading of the android code makes me think it's not doing anything special (authentication etc) beyond doing simple bonding (pairing) of the ble device once the switch is in "pairing" mode (three presses, flashing). But when I try pairing (which I confirmed tries to create a ble bond in the bluez code) it doesn't work, and I get this output:

Oct 04 16:31:56 prowl bluetoothd[20162]: mgmt: > 0c 00 00 00 08 00 d7 4b 3e 5e cf d0 01 00        .......K>^....
Oct 04 16:31:56 prowl bluetoothd[20162]: mgmt: [0x0000] event 0x000c
Oct 04 16:31:56 prowl bluetoothd[20162]: src/adapter.c:dev_disconnected() Device D0:CF:5E:3E:4B:D7 disconnected, reason 0
Oct 04 16:31:56 prowl bluetoothd[20162]: src/adapter.c:adapter_remove_connection()
Oct 04 16:31:56 prowl bluetoothd[20162]: plugins/policy.c:disconnect_cb() reason 0
Oct 04 16:31:56 prowl bluetoothd[20162]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0xe
Oct 04 16:31:56 prowl bluetoothd[20162]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
Oct 04 16:31:56 prowl bluetoothd[20162]: src/device.c:device_bonding_failed() status 14
Oct 04 16:31:56 prowl bluetoothd[20162]: src/adapter.c:resume_discovery()

I think my little adapter is Bluetooth 4.0, maybe it needs 4.2. Will keep digging

@phindmarsh
Copy link

I was thinking about this earlier, and wondered what protection it had (if any) from a random device trying to control it without doing the triple tap thing first.

Presumably without some kind of bonding process it would be a Bad Idea and allow anyone to control your lights.

So based on what you’ve seen it would look like you need to bond with it through the triple tap process before it’ll allow you to control it?

@sj26
Copy link

sj26 commented Oct 4, 2020

Yeah, I'm pretty sure the triple tap puts it into some sort of "expect bonding" mode.

But I can't figure out how to successfully bond. I don't understanding bonding well enough, I think.

I figured out my UDM has a bluetooth radio in it, and is the ideal controller for me. I also noticed that it's got more modern bluetooth - 4.2:

# hciconfig -a
hci0:	Type: Primary  Bus: UART
	BD Address: 74:83:C2:D7:AA:C1  ACL MTU: 310:10  SCO MTU: 64:8
	UP RUNNING 
	RX bytes:5206497 acl:0 sco:0 events:138185 errors:0
	TX bytes:1020141 acl:0 sco:0 commands:2003 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'BlueZ 5.48'
	Class: 0x000000
	Service Classes: Unspecified
	Device Class: Miscellaneous, 
	HCI Version: 4.2 (0x8)  Revision: 0x2918
	LMP Version: 4.2 (0x8)  Subversion: 0x2918
	Manufacturer: Cambridge Silicon Radio (10)

I can scan the device and whatnot from this controller, but still pairing fails (during triple tap mode):

[bluetooth]# pair D0:CF:5E:3E:4B:D7
Attempting to pair with D0:CF:5E:3E:4B:D7
[CHG] Device D0:CF:5E:3E:4B:D7 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device D0:CF:5E:3E:4B:D7 Connected: no
[CHG] Controller 74:83:C2:D7:AA:C1 Powered: no
[CHG] Controller 74:83:C2:D7:AA:C1 Discovering: no
[CHG] Controller 74:83:C2:D7:AA:C1 Powered: yes

with the following daemon output:

bluetoothd[6945]: src/agent.c:agent_ref() 0x4d3de0: ref=1
bluetoothd[6945]: src/agent.c:register_agent() agent :1.9
bluetoothd[6945]: src/agent.c:agent_disconnect() Agent :1.9 disconnected
bluetoothd[6945]: src/agent.c:agent_destroy() agent :1.9
bluetoothd[6945]: src/agent.c:agent_unref() 0x4d3de0: ref=0
bluetoothd[6945]: src/agent.c:agent_ref() 0x4db3b0: ref=1
bluetoothd[6945]: src/agent.c:register_agent() agent :1.10
bluetoothd[6945]: src/agent.c:agent_disconnect() Agent :1.10 disconnected
bluetoothd[6945]: src/agent.c:agent_destroy() agent :1.10
bluetoothd[6945]: src/agent.c:agent_unref() 0x4db3b0: ref=0
bluetoothd[6945]: src/agent.c:agent_ref() 0x4d3de0: ref=1
bluetoothd[6945]: src/agent.c:register_agent() agent :1.11
bluetoothd[6945]: src/agent.c:agent_ref() 0x4d3de0: ref=2
bluetoothd[6945]: src/device.c:bonding_request_new() Requesting bonding for D0:CF:5E:3E:4B:D7
bluetoothd[6945]: src/agent.c:agent_ref() 0x4d3de0: ref=3
bluetoothd[6945]: src/agent.c:agent_unref() 0x4d3de0: ref=2
bluetoothd[6945]: src/adapter.c:suspend_discovery() 
bluetoothd[6945]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 io_cap 0x04
bluetoothd[6945]: src/adapter.c:connected_callback() hci0 device D0:CF:5E:3E:4B:D7 connected eir_len 0
bluetoothd[6945]: src/adapter.c:pair_device_complete() Not Powered (0x0f)
bluetoothd[6945]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0xf
bluetoothd[6945]: src/device.c:device_bonding_complete() bonding 0x4eb0c0 status 0x0f
bluetoothd[6945]: src/device.c:device_bonding_failed() status 15
bluetoothd[6945]: src/agent.c:agent_unref() 0x4d3de0: ref=1
bluetoothd[6945]: src/adapter.c:resume_discovery() 
bluetoothd[6945]: src/adapter.c:trigger_start_discovery() 
bluetoothd[6945]: src/adapter.c:cancel_passive_scanning() 
bluetoothd[6945]: src/adapter.c:new_settings_callback() Settings: 0x00000ad0
bluetoothd[6945]: src/adapter.c:settings_changed() Changed settings: 0x00000001
bluetoothd[6945]: src/adapter.c:cancel_passive_scanning() 
bluetoothd[6945]: src/adapter.c:adapter_remove_connection() 
bluetoothd[6945]: src/adapter.c:adapter_remove_connection() 
bluetoothd[6945]: src/adapter.c:adapter_stop() adapter /org/bluez/hci0 has been disabled
bluetoothd[6945]: src/adapter.c:new_settings_callback() Settings: 0x00000ad1
bluetoothd[6945]: src/adapter.c:settings_changed() Changed settings: 0x00000001
bluetoothd[6945]: src/adapter.c:adapter_start() adapter /org/bluez/hci0 has been enabled
bluetoothd[6945]: src/adapter.c:trigger_passive_scanning() 

I'm very suspicious of this "not powered" status, it makes me think I need to do something to this controller before it'll work.

@sj26
Copy link

sj26 commented Oct 4, 2020

It took some finessing to get the bluetooth stack up and running correctly, but then a pairing request worked:

[bluetooth]# pair D0:CF:5E:3E:4B:D7
Attempting to pair with D0:CF:5E:3E:4B:D7
[CHG] Device D0:CF:5E:3E:4B:D7 Connected: yes
[CHG] Device D0:CF:5E:3E:4B:D7 Paired: yes
Pairing successful
[CHG] Device D0:CF:5E:3E:4B:D7 ServicesResolved: yes
bluetoothd[19834]: src/device.c:bonding_request_new() Requesting bonding for D0:CF:5E:3E:4B:D7
bluetoothd[19834]: src/agent.c:agent_ref() 0x4d8690: ref=3
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=2
bluetoothd[19834]: src/adapter.c:suspend_discovery() 
bluetoothd[19834]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 io_cap 0x04
bluetoothd[19834]: src/adapter.c:connected_callback() hci0 device D0:CF:5E:3E:4B:D7 connected eir_len 0
bluetoothd[19834]: src/gatt-database.c:connect_cb() New incoming LE ATT connection
bluetoothd[19834]: attrib/gattrib.c:g_attrib_ref() 0x4e72b0: g_attrib_ref=1 
bluetoothd[19834]: profiles/gap/gas.c:gap_accept() GAP profile accept (D0:CF:5E:3E:4B:D7)
bluetoothd[19834]: src/service.c:change_state() 0x4e3180: device D0:CF:5E:3E:4B:D7 profile gap-profile state changed: disconnected -> connected (0)
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:deviceinfo_accept() deviceinfo profile accept (D0:CF:5E:3E:4B:D7)
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a24-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a26-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a29-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: src/service.c:change_state() 0x4e3750: device D0:CF:5E:3E:4B:D7 profile deviceinfo state changed: disconnected -> connected (0)
bluetoothd[19834]: src/gatt-client.c:btd_gatt_client_connected() Device connected.
bluetoothd[19834]: src/device.c:gatt_debug() MTU exchange complete, with MTU: 247
bluetoothd[19834]: src/adapter.c:pair_device_complete() Authentication Failed (0x05)
bluetoothd[19834]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0x5
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding 0x4e0d10 status 0x05
bluetoothd[19834]: src/device.c:device_bonding_failed() status 5
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=1
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: src/adapter.c:dev_disconnected() Device D0:CF:5E:3E:4B:D7 disconnected, reason 2
bluetoothd[19834]: src/adapter.c:adapter_remove_connection() 
bluetoothd[19834]: plugins/policy.c:disconnect_cb() reason 2
bluetoothd[19834]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0xe
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[19834]: src/device.c:device_bonding_failed() status 14
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: profiles/gap/gas.c:read_device_name_cb() Reading device name failed with ATT errror: 0
bluetoothd[19834]: profiles/gap/gas.c:read_appearance_cb() Reading appearance failed with ATT error: 0
bluetoothd[19834]: src/device.c:gatt_debug() MTU Exchange failed. ATT ECODE: 0x00
bluetoothd[19834]: src/device.c:gatt_client_ready_cb() status: failed, error: 0
bluetoothd[19834]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7 err -5
bluetoothd[19834]: src/device.c:att_disconnected_cb() 
bluetoothd[19834]: src/device.c:att_disconnected_cb() Software caused connection abort (103)
bluetoothd[19834]: src/service.c:change_state() 0x4e3180: device D0:CF:5E:3E:4B:D7 profile gap-profile state changed: connected -> disconnecting (0)
bluetoothd[19834]: src/service.c:change_state() 0x4e3180: device D0:CF:5E:3E:4B:D7 profile gap-profile state changed: disconnecting -> disconnected (0)
bluetoothd[19834]: src/service.c:change_state() 0x4e3750: device D0:CF:5E:3E:4B:D7 profile deviceinfo state changed: connected -> disconnecting (0)
bluetoothd[19834]: src/service.c:change_state() 0x4e3750: device D0:CF:5E:3E:4B:D7 profile deviceinfo state changed: disconnecting -> disconnected (0)
bluetoothd[19834]: src/gatt-client.c:btd_gatt_client_disconnected() Device disconnected. Cleaning up.
bluetoothd[19834]: src/device.c:att_disconnected_cb() Automatic connection disabled
bluetoothd[19834]: attrib/gattrib.c:g_attrib_unref() 0x4e72b0: g_attrib_unref=0 
bluetoothd[19834]: src/agent.c:agent_ref() 0x4d8690: ref=2
bluetoothd[19834]: src/device.c:bonding_request_new() Requesting bonding for D0:CF:5E:3E:4B:D7
bluetoothd[19834]: src/agent.c:agent_ref() 0x4d8690: ref=3
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=2
bluetoothd[19834]: src/adapter.c:suspend_discovery() 
bluetoothd[19834]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 io_cap 0x04
bluetoothd[19834]: src/adapter.c:connected_callback() hci0 device D0:CF:5E:3E:4B:D7 connected eir_len 0
bluetoothd[19834]: src/adapter.c:pair_device_complete() Failed (0x03)
bluetoothd[19834]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0x3
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding 0x4d66a0 status 0x03
bluetoothd[19834]: src/device.c:device_bonding_failed() status 3
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=1
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: src/adapter.c:dev_disconnected() Device D0:CF:5E:3E:4B:D7 disconnected, reason 0
bluetoothd[19834]: src/adapter.c:adapter_remove_connection() 
bluetoothd[19834]: plugins/policy.c:disconnect_cb() reason 0
bluetoothd[19834]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0xe
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[19834]: src/device.c:device_bonding_failed() status 14
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: src/agent.c:agent_ref() 0x4d8690: ref=2
bluetoothd[19834]: src/device.c:bonding_request_new() Requesting bonding for D0:CF:5E:3E:4B:D7
bluetoothd[19834]: src/agent.c:agent_ref() 0x4d8690: ref=3
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=2
bluetoothd[19834]: src/adapter.c:suspend_discovery() 
bluetoothd[19834]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 io_cap 0x04
bluetoothd[19834]: src/adapter.c:connected_callback() hci0 device D0:CF:5E:3E:4B:D7 connected eir_len 0
bluetoothd[19834]: src/gatt-database.c:connect_cb() New incoming LE ATT connection
bluetoothd[19834]: attrib/gattrib.c:g_attrib_ref() 0x4db100: g_attrib_ref=1 
bluetoothd[19834]: profiles/gap/gas.c:gap_accept() GAP profile accept (D0:CF:5E:3E:4B:D7)
bluetoothd[19834]: src/service.c:change_state() 0x4e3180: device D0:CF:5E:3E:4B:D7 profile gap-profile state changed: disconnected -> connected (0)
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:deviceinfo_accept() deviceinfo profile accept (D0:CF:5E:3E:4B:D7)
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a24-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a26-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a29-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: src/service.c:change_state() 0x4e3750: device D0:CF:5E:3E:4B:D7 profile deviceinfo state changed: disconnected -> connected (0)
bluetoothd[19834]: src/gatt-client.c:btd_gatt_client_connected() Device connected.
bluetoothd[19834]: src/device.c:gatt_debug() MTU exchange complete, with MTU: 247
bluetoothd[19834]: src/device.c:gatt_debug() MTU exchange complete, with MTU: 247
bluetoothd[19834]: profiles/gap/gas.c:read_device_name_cb() GAP Device Name: CH-DIMMER_4BD7
bluetoothd[19834]: profiles/gap/gas.c:read_appearance_cb() GAP Appearance: 0x6009
bluetoothd[19834]: src/adapter.c:new_irk_callback() hci0 new IRK for D0:CF:5E:3E:4B:D7 RPA 00:00:00:00:00:00
bluetoothd[19834]: src/adapter.c:new_long_term_key_callback() hci0 new LTK for D0:CF:5E:3E:4B:D7 type 2 enc_size 16
bluetoothd[19834]: src/device.c:device_set_bonded() 
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding 0x4d1db0 status 0x00
bluetoothd[19834]: src/agent.c:agent_unref() 0x4d8690: ref=1
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: src/adapter.c:pair_device_complete() Success (0x00)
bluetoothd[19834]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr D0:CF:5E:3E:4B:D7 type 1 status 0x0
bluetoothd[19834]: src/device.c:device_bonding_complete() bonding (nil) status 0x00
bluetoothd[19834]: src/adapter.c:resume_discovery() 
bluetoothd[19834]: src/device.c:gatt_debug() Primary services found: 5
bluetoothd[19834]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005, uuid: 00001800-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: src/device.c:gatt_debug() start: 0x0006, end: 0x000c, uuid: 0000180a-0000-1000-8000-00805f9b34fb
bluetoothd[19834]: src/device.c:gatt_debug() start: 0x000d, end: 0x0022, uuid: 720a7080-9c7d-11e5-a7e3-0002a5d5c51b
bluetoothd[19834]: src/device.c:gatt_debug() start: 0x0023, end: 0x0028, uuid: 1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
bluetoothd[19834]: src/device.c:gatt_debug() start: 0x0029, end: 0xffff, uuid: 720a9080-9c7d-11e5-a7e3-0002a5d5c51b
bluetoothd[19834]: src/device.c:gatt_client_ready_cb() status: success, error: 0
bluetoothd[19834]: src/gatt-client.c:btd_gatt_client_ready() GATT client ready
bluetoothd[19834]: src/gatt-client.c:create_services() Exporting objects for GATT services: D0:CF:5E:3E:4B:D7
bluetoothd[19834]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7 err 0

@sj26
Copy link

sj26 commented Oct 4, 2020

[CH-DIMMER_4BD7]# list-attributes
Primary Service
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0006
	0000180a-0000-1000-8000-00805f9b34fb
	Device Information
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0006/char0007
	00002a24-0000-1000-8000-00805f9b34fb
	Model Number String
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0006/char0009
	00002a26-0000-1000-8000-00805f9b34fb
	Firmware Revision String
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0006/char000b
	00002a29-0000-1000-8000-00805f9b34fb
	Manufacturer Name String
Primary Service
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d
	720a7080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char000e
	720a7081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char000e/desc0010
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0011
	720a7082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0011/desc0013
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0011/desc0014
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0015
	720a7083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0015/desc0017
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0015/desc0018
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0019
	720a7084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char0019/desc001b
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char001c
	720a7085-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char001c/desc001e
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char001f
	720a7086-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char001f/desc0021
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service000d/char001f/desc0022
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Primary Service
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0023
	1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0023/char0024
	f7bf3564-fb6d-4e53-88a4-5e37e0326063
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0023/char0024/desc0026
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0023/char0027
	984227f3-34fc-4045-a5d0-2c581f81a153
	Vendor specific
Primary Service
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029
	720a9080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a
	720a9081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a/desc002c
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a/desc002d
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002e
	720a9082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002e/desc0030
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002e/desc0031
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0032
	720a9083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0032/desc0034
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0032/desc0035
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0036
	720a9084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0036/desc0038
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char0036/desc0039
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description

[CH-DIMMER_4BD7]# select-attribute 720a9081-9c7d-11e5-a7e3-0002a5d5c51b
[CH-DIMMER_4BD7:/service0029/char002a]# select-attribute 720a9081-9c7d-11e5-a7e3-0002a5d5c51b[CH-DIMMER_4BD7:/service0029/char002a]# read
Attempting to read /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a
[CHG] Attribute /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a Value:
  01                                               .               
  01                                               .               
[CH-DIMMER_4BD7:/service0029/char002a]# write data=00
Invalid value at index 0
[CH-DIMMER_4BD7:/service0029/char002a]# write 0      
Attempting to write /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a
[CH-DIMMER_4BD7:/service0029/char002a]# write 1
Attempting to write /org/bluez/hci0/dev_D0_CF_5E_3E_4B_D7/service0029/char002a

My lights just turned on and off, controlled from my wifi router 🎉

@sj26
Copy link

sj26 commented Oct 4, 2020

Yeah I reckon it's Bluetooth 4.2. It introduced a new key exchange mode for BLE devices that I think this is using. Fortunately bluez takes care of most of it.

I'll be ordering some new usb bluetooth adapters 😅

@phindmarsh
Copy link

Nice, I've got some Pi 3s which only have 4.1, and trying a pair doesn't seem to work:

[bluetooth]# pair CC:CC:CC:F8:C3:E0
Attempting to pair with CC:CC:CC:F8:C3:E0
Failed to pair: org.bluez.Error.AuthenticationCanceled

Looks like I need to buy some more adapters too, or just a new Pi 4

@sj26
Copy link

sj26 commented Oct 4, 2020

Check your software, too — you might just need a new kernel or bluetooth stack.

@CalumOchkas
Copy link

Been following this intently :-)

It took some finessing to get the bluetooth stack up and running correctly, but then a pairing request worked

What did you try differently? I've just tried from a Pi4 with the standard bluez stack and I'm getting the same error:

[bluetooth]# version
Version 5.50
[bluetooth]# info 90:FD:9F:5C:E0:28
Device 90:FD:9F:5C:E0:28 (public)
	Name: CH-DIMMER_E028
	Alias: CH-DIMMER_E028
	Paired: no
	Trusted: yes
	Blocked: no
	Connected: no
	LegacyPairing: no
	ManufacturerData Key: 0x02b6
	ManufacturerData Value:

Made trusted to test ^

[bluetooth]# pair 90:FD:9F:5C:E0:28
Attempting to pair with 90:FD:9F:5C:E0:28
[CHG] Device 90:FD:9F:5C:E0:28 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationTimeout
[CHG] Device 90:FD:9F:5C:E0:28 Connected: no

Know what I might be missing?

@CalumOchkas
Copy link

Note this after the 3x Tap to begin pairing mode (red flashing).
Here's the debug logs:

Oct 08 15:54:20 raspberrypi-bedroom bluetoothd[3836]: src/device.c:bonding_request_new() Requesting bonding for 90:FD:9F:5C:E0:28
Oct 08 15:54:20 raspberrypi-bedroom bluetoothd[3836]: src/agent.c:agent_ref() 0x11c0fb0: ref=3
Oct 08 15:54:20 raspberrypi-bedroom bluetoothd[3836]: src/agent.c:agent_unref() 0x11c0fb0: ref=2
Oct 08 15:54:20 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:suspend_discovery()
Oct 08 15:54:20 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr 90:FD:9F:5C:E0:28 type 1 io_cap 0x04
Oct 08 15:54:21 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:connected_callback() hci0 device 90:FD:9F:5C:E0:28 connected eir_len 31
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:pair_device_complete() Timeout (0x08)
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 90:FD:9F:5C:E0:28 type 1 status 0x8
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/device.c:device_bonding_complete() bonding 0x11bb138 status 0x08
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/device.c:device_bonding_failed() status 8
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/agent.c:agent_unref() 0x11c0fb0: ref=1
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:resume_discovery()
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:dev_disconnected() Device 90:FD:9F:5C:E0:28 disconnected, reason 1
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:adapter_remove_connection()
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: plugins/policy.c:disconnect_cb() reason 1
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 90:FD:9F:5C:E0:28 type 1 status 0xe
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/device.c:device_bonding_failed() status 14
Oct 08 15:54:22 raspberrypi-bedroom bluetoothd[3836]: src/adapter.c:resume_discovery()

@phindmarsh
Copy link

My new Pi4 just arrived, and I managed to get it to turn the lights on and off just now after a bit of trial and error, here's what I did. This is on a vanilla install of RaspberryOS, no additional packages installed. I had also upgraded the firmware from the initial version using the Wiser Room app (currently v2.2.0).

Pi 4 info:

[bluetooth]# version
Version 5.50
[bluetooth]# show
Controller DC:A6:32:C6:D9:F9 (public)
	Name: raspberrypi
	Alias: raspberrypi
	Class: 0x00000000
	Powered: yes
	Discoverable: no
	Pairable: yes
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v1D6Bp0246d0532
	Discovering: no

First, I removed any previous devices I had from past attempts:

[bluetooth]# devices
Device XX:XX:XX:XX:C3:E0 CH-DIMMER_C3E0
[bluetooth]# remove XX:XX:XX:XX:C3:E0
[DEL] Device XX:XX:XX:XX:C3:E0 CH-DIMMER_C3E0
Device has been removed

Then, inspired by these instructions, I did these commands:

[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent is already registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Controller YY:YY:YY:YY:D9:F9 Discovering: yes
... <other devices>
[NEW] Device XX:XX:XX:XX:C3:E0 CH-DIMMER_C3E0
... <other devices>
[bluetooth]# scan off
Discovery stopped
[CHG] Controller YY:YY:YY:YY:D9:F9 Discovering: no
[CHG] Device XX:XX:XX:XX:C3:E0 TxPower is nil
[CHG] Device XX:XX:XX:XX:C3:E0 RSSI is nil
[bluetooth]# trust XX:XX:XX:XX:C3:E0
[CHG] Device XX:XX:XX:XX:C3:E0 Trusted: yes
Changing XX:XX:XX:XX:C3:E0 trust succeeded

At this point I triple pressed the dimmer button to get it to flash green and red, then

[bluetooth]# pair XX:XX:XX:XX:C3:E0
Attempting to pair with XX:XX:XX:XX:C3:E0
[CHG] Device XX:XX:XX:XX:C3:E0 Connected: yes
[CHG] Device XX:XX:XX:XX:C3:E0 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:C3:E0 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:C3:E0 UUIDs: 1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
[CHG] Device XX:XX:XX:XX:C3:E0 UUIDs: 720a7080-9c7d-11e5-a7e3-0002a5d5c51b
[CHG] Device XX:XX:XX:XX:C3:E0 UUIDs: 720a9080-9c7d-11e5-a7e3-0002a5d5c51b
[CHG] Device XX:XX:XX:XX:C3:E0 ServicesResolved: yes
[CHG] Device XX:XX:XX:XX:C3:E0 Paired: yes
[NEW] Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006
	0000180a-0000-1000-8000-00805f9b34fb
	Device Information
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char0007
	00002a24-0000-1000-8000-00805f9b34fb
	Model Number String
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char0009
	00002a26-0000-1000-8000-00805f9b34fb
	Firmware Revision String
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char000b
	00002a29-0000-1000-8000-00805f9b34fb
	Manufacturer Name String
[NEW] Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d
	720a7080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char000e
	720a7081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char000e/desc0010
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011
	720a7082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011/desc0013
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011/desc0014
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015
	720a7083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015/desc0017
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015/desc0018
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0019
	720a7084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0019/desc001b
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001c
	720a7085-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001c/desc001e
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f
	720a7086-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f/desc0021
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f/desc0022
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023
	1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
	Vendor specific
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0024
	f7bf3564-fb6d-4e53-88a4-5e37e0326063
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0024/desc0026
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0027
	984227f3-34fc-4045-a5d0-2c581f81a153
	Vendor specific
[NEW] Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029
	720a9080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a
	720a9081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a/desc002c
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a/desc002d
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e
	720a9082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e/desc0030
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e/desc0031
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032
	720a9083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032/desc0034
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032/desc0035
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[NEW] Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036
	720a9084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036/desc0038
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
[NEW] Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036/desc0039
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Pairing successful
[CHG] Device XX:XX:XX:XX:C3:E0 Appearance: 0x6009

Pairing successful!

Switching to the gatt menu now, and reading the attribute for the current on/off status:

[CH-DIMMER_C3E0]# menu gatt 
Menu gatt:
Available commands:
-------------------
list-attributes [dev]                             List attributes
select-attribute <attribute/UUID>                 Select attribute
attribute-info [attribute/UUID]                   Select attribute
read [offset]                                     Read attribute value
write <data=xx xx ...> [offset]                   Write attribute value
acquire-write                                     Acquire Write file descriptor
release-write                                     Release Write file descriptor
acquire-notify                                    Acquire Notify file descriptor
release-notify                                    Release Notify file descriptor
notify <on/off>                                   Notify attribute value
register-application [UUID ...]                   Register profile to connect
unregister-application                            Unregister profile
register-service <UUID>                           Register application service.
unregister-service <UUID/object>                  Unregister application service
register-includes <UUID>                          Register as Included service in.
unregister-includes <Service-UUID><Inc-UUID>      Unregister Included service.
register-characteristic <UUID> <Flags=read,write,notify...>  Register application characteristic
unregister-characteristic <UUID/object>           Unregister application characteristic
register-descriptor <UUID> <Flags=read,write...>  Register application descriptor
unregister-descriptor <UUID/object>               Unregister application descriptor
back                                              Return to main menu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program
export                                            Print evironment variables
[CH-DIMMER_C3E0]# list-attributes
Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006
	0000180a-0000-1000-8000-00805f9b34fb
	Device Information
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char0007
	00002a24-0000-1000-8000-00805f9b34fb
	Model Number String
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char0009
	00002a26-0000-1000-8000-00805f9b34fb
	Firmware Revision String
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0006/char000b
	00002a29-0000-1000-8000-00805f9b34fb
	Manufacturer Name String
Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d
	720a7080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char000e
	720a7081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char000e/desc0010
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011
	720a7082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011/desc0013
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0011/desc0014
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015
	720a7083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015/desc0017
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0015/desc0018
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0019
	720a7084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char0019/desc001b
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001c
	720a7085-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001c/desc001e
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f
	720a7086-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f/desc0021
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service000d/char001f/desc0022
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023
	1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0024
	f7bf3564-fb6d-4e53-88a4-5e37e0326063
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0024/desc0026
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0023/char0027
	984227f3-34fc-4045-a5d0-2c581f81a153
	Vendor specific
Primary Service
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029
	720a9080-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a
	720a9081-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a/desc002c
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a/desc002d
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e
	720a9082-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e/desc0030
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e/desc0031
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032
	720a9083-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032/desc0034
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0032/desc0035
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
Characteristic
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036
	720a9084-9c7d-11e5-a7e3-0002a5d5c51b
	Vendor specific
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036/desc0038
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
Descriptor
	/org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char0036/desc0039
	00002901-0000-1000-8000-00805f9b34fb
	Characteristic User Description
[CH-DIMMER_C3E0]# select-attribute 720a9081-9c7d-11e5-a7e3-0002a5d5c51b
[CH-DIMMER_C3E0:/service0029/char002a]# select-attribute 720a9081-9c7d-11e5-a7e3-0002a5d5c51b

The light was currently switched on, so read the state should give me a 1...

[CH-DIMMER_C3E0:/service0029/char002a]# read
Attempting to read /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a
[CHG] Attribute /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a Value:
  01                                               .               
  01                                               .               

Which it did, so writing a 0 should turn it off...

[CH-DIMMER_C3E0:/service0029/char002a]# write 0
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a

Which it did!

[CH-DIMMER_C3E0:/service0029/char002a]# write 1
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a
[CH-DIMMER_C3E0:/service0029/char002a]# write 0
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a
[CH-DIMMER_C3E0:/service0029/char002a]# write 1
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002a

With this I'll now focus on getting it working from Python, so I can wrap that in a home assistant plugin. @sj26 have you started work in that area yet?

@CalumOchkas
Copy link

Thanks so much for all the information, but still no good for me.

So weird, I'm doing exactly the same on my Pi, the controller looks identical, deleted the device (which I was running 2.2.0, but now 2.2.8) but still getting AuthenticationTimeout (in < 2 seconds) on pairing after following the same process as you .

I wonder if my BLE switch module is a slightly different model (in New Zealand).

@phindmarsh
Copy link

I’m in NZ too, got the dimmers from JA Russell, they are the PDL branded ones.

I have had some problems reconnecting to them after pairing, so it’s not 100% reliable.

I’m away for the long weekend, so will be back to it next week

@CalumOchkas
Copy link

Yeah I got mine from JA Russell too. Very odd! Is your intermittent message the same src/adapter.c:pair_device_complete() Timeout (0x08) error?
I was running the Lite version of RaspberryPi OS. I've just attempted a reinstall of the full OS and retried but getting the same issue. (Clutching at straw)

@CalumOchkas
Copy link

btmon extract showing where the timeout occurs:

> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                                                                              #16 [hci0] 24.909589
      LE Read Remote Used Features (0x04)
        Status: Connection Timeout (0x08)
        Handle: 64
        Features: 0x2d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Data Packet Length Extension

Full log:

@ MGMT Command: Pair Device (0x0019) plen 8                                                                                                                                                                       {0x0001} [hci0] 22.865885
        LE Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Capability: KeyboardDisplay (0x04)
< HCI Command: LE Add Device To White List (0x08|0x0011) plen 7                                                                                                                                                         #1 [hci0] 22.866038
        Address type: Public (0x00)
        Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                             #2 [hci0] 22.866603
      LE Add Device To White List (0x08|0x0011) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                                                                                                                              #3 [hci0] 22.866684
        Type: Passive (0x00)
        Interval: 60.000 msec (0x0060)
        Window: 30.000 msec (0x0030)
        Own address type: Public (0x00)
        Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                             #4 [hci0] 22.867078
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                                                                                                                                  #5 [hci0] 22.867151
        Scanning: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                             #6 [hci0] 22.867783
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 43                                                                                                                                                                               #7 [hci0] 23.580207
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Connectable undirected - ADV_IND (0x00)
        Address type: Public (0x00)
        Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Data length: 31
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Company: Schneider Electric (694)
          Data: 1a4430003700016d00010700010028e05c9ffd9000000000
        RSSI: -54 dBm (0xca)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                                                                                                                                  #8 [hci0] 23.580303
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                             #9 [hci0] 23.582606
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Create Connection (0x08|0x000d) plen 25                                                                                                                                                              #10 [hci0] 23.582688
        Scan interval: 60.000 msec (0x0060)
        Scan window: 60.000 msec (0x0060)
        Filter policy: White list is not used (0x00)
        Peer address type: Public (0x00)
        Peer address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Own address type: Public (0x00)
        Min connection interval: 30.00 msec (0x0018)
        Max connection interval: 50.00 msec (0x0028)
        Connection latency: 0 (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Min connection length: 0.000 msec (0x0000)
        Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                              #11 [hci0] 23.583259
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19                                                                                                                                                                              #12 [hci0] 24.090202
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Connection interval: 48.75 msec (0x0027)
        Connection latency: 0 (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Master clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 44                                                                                                                                                                   {0x0002} [hci0] 24.090269
        LE Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Flags: 0x00000000
        Data length: 31
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Company: Schneider Electric (694)
          Data: 1a4430003700016d00010700010028e05c9ffd9000000000
@ MGMT Event: Device Connected (0x000b) plen 44                                                                                                                                                                   {0x0001} [hci0] 24.090269
        LE Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Flags: 0x00000000
        Data length: 31
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Company: Schneider Electric (694)
          Data: 1a4430003700016d00010700010028e05c9ffd9000000000
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                                                                                       #13 [hci0] 24.090482
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                              #14 [hci0] 24.090971
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 14                                                                                                                                                                           #15 [hci0] 24.091042
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
        00 00 00 00 00 00 00 00 00 00                    ..........      
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                                                                              #16 [hci0] 24.909589
      LE Read Remote Used Features (0x04)
        Status: Connection Timeout (0x08)
        Handle: 64
        Features: 0x2d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Data Packet Length Extension
@ MGMT Event: Command Complete (0x0001) plen 10                                                                                                                                                                   {0x0001} [hci0] 24.909624
      Pair Device (0x0019) plen 7
        Status: Timeout (0x08)
        LE Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                                                                                         #17 [hci0] 24.910445
        Status: Success (0x00)
        Handle: 64
        Reason: Connection Timeout (0x08)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                                                                                 {0x0002} [hci0] 24.910467
        LE Address: 90:FD:9F:5C:E0:28 (Silicon Laboratories)
        Reason: Connection timeout (0x01)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                                                                                 {0x0001} [hci0] 24.910467

@phindmarsh
Copy link

I found I couldn't reconnect after completing those steps. After some digging it appears there might be a firmware issue on the RPi.

Rolling it back has mean I can connect again.

I've also mucked about setting levels, here's the examples that worked:

# select the level attribute
[CH-DIMMER_C3E0:/service0029/char002a]# select-attribute 720a9082-9c7d-11e5-a7e3-0002a5d5c51b

# write the level to be "off"
[CH-DIMMER_C3E0:/service0029/char002e]# write "0x00 0x00"
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e

# write the level to be max (where the "integer value" is 2710)
[CH-DIMMER_C3E0:/service0029/char002e]# write "0x10 0x27"
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e

#write the level to be half(ish) ("integer level" of 1000)
[CH-DIMMER_C3E0:/service0029/char002e]# write "0x00 0x10"
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_C3_E0/service0029/char002e

Still to start with the python side of things, been a busy couple of weeks.

@CalumOchkas
Copy link

@phindmarsh Yes I'm in! Thanks a lot, the version was the trick. I had tried a couple of versions but the one you linked worked a treat.

@CalumOchkas
Copy link

A really quick play with BluePy this evening and the connection looks good:

> import bluepy
> from bluepy import btle

> p = btle.Peripheral("90:FD:9F:5C:E0:28")

> c = p.getCharacteristics(uuid="720a9082-9c7d-11e5-a7e3-0002a5d5c51b")[0]

> c.read()
'\x00\x00'

@phindmarsh
Copy link

Here's my progress so far, a class that can turn on/off a dimmer, and set the level. Assumes the dimmer is already paired with the bluetooth controller device (using bluetoothctl or whatever).

Next step for me is to bridge this into MQTT, because my home assistant instance runs on a VM that doesn't have a bluetooth stack.

https://gist.github.com/phindmarsh/a89cd407a57926e9f604e23cc9f9f5ce

@ell249
Copy link

ell249 commented Nov 8, 2020

Following with interest guys - I reckon i've tried BLE connections with Iconic switches since they were released. My experience has been similar - works every time from my iPhone with BLE/GATT apps but really hit and miss from anything else. Interestingly I have some switches in my house that pair no problem and can reconnect anytime, and others that just refuse to even pair. Definitely keen on MQTT - keen to integrate with my Home Assistant!

@CalumOchkas
Copy link

CalumOchkas commented Nov 14, 2020

Using @phindmarsh 's good work, I've got mine working at least in a test scenario with MQTT, here's the quickly thrown together code which I intend to clean up at some point:
https://gist.github.com/CalumOchkas/5c148cecdb33baea32374a0e266b3792

It utilises the MQTT-Light HomeAssistant Integration with the config YAML as follows:

light:
  - platform: mqtt
    name: "Bedroom Light"
    unique_id: bedroomlight
    state_topic: "bedroom/light/status"
    command_topic: "bedroom/light/switch"
    brightness_state_topic: 'bedroom/light/brightness'
    brightness_command_topic: 'bedroom/light/brightness/set'
    brightness_scale: 10000
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false

@QuantumImmortality
Copy link

QuantumImmortality commented Apr 13, 2021

Any update on this fellas? Considering buying these Clipsal smart modules but the only thing I'm not keen on is the lack of Home Assistant integration

@CalumOchkas @phindmarsh

@CalumOchkas
Copy link

I put this together a while ago, works well for me so I haven’t tried any further:
https://github.com/CalumOchkas/PDL-Clipsal-BLEDimmer2MQTT

@mathew-ryan
Copy link

I’ve been following this for quite a while too, and have just installed switches but not integrated them yet.

A quick note to keep in mind is that Clipsal have finally made some movement on a hub with smart home integration. If you have a look at the new wiser app it shows options for both direct connection and hub connection, there are also references online to firmware upgrades for the switches which will support this. I’m not holding my breath but it could have impacts on the current solutions.

@phindmarsh
Copy link

Hey folks, an update on this for anyone interested: I've just submitted a PR to add support for the PDL354PBDMBTZ (and similar) devices to zigbee2mqtt. This means they are controllable within home assistant without needing the Wiser Bridge or fudging support via BLE.

If you already have the PDL354PBDMBTW (i.e. the ones with BLE out of the box) you can convert these to zigbee mode by pressing the button 12 times and waiting a bit for them to switch modes. I recommend you use the Wiser Room app first to make sure they run the latest firmware.

If you want to switch them back you can just factory reset them by pressing the button three times then holding until the red light flashes quickly.

This is essentially what I've done with the 4 dimmers I already own, and its working great. No need to use the BLE mode and if you already run a zigbee2mqtt once this is merged it should "just work". More details in this gist.

@atomic10
Copy link

atomic10 commented Jun 4, 2021

Was looking at connecting a few of the Iconic wiser power points to Zigbee and stumbled across this project. Awesome work here gents! Wasn't able to get the power point to go into Zigbee mode and contacted Clipsal for some help. They told me that new firmware will be released in the coming weeks/month for the power points as the Zigbee firmware is still being tested.

@sj26
Copy link

sj26 commented Jun 4, 2021

This is great! Has anybody managed to connect them to a Philips Hue Bridge — does that work?

@phindmarsh
Copy link

Not sure about the Hue Bridge, but I’ve heard that the Samsung SmartHub bridge seems to work.

@CalumOchkas
Copy link

I can confirm that ZHA with the Sonoff Zigbee Hub works a treat too. Thanks for the tip @phindmarsh !!

@mathew-ryan
Copy link

I can confirm that ZHA with the Sonoff Zigbee Hub works a treat too. Thanks for the tip @phindmarsh !!

Any tips on getting this to work? I’ve just changed one of my switches over to Zigbee and by ConBee II isn’t seeing anything. Did you need to keep the module close to your Zigbee hub? Mine is only about 4 metres away.

@phindmarsh
Copy link

For me I have a Electrollama zzh! stick and it was up in the ceiling when I paired it, one was easily over 8m away.

I did find that I needed to reboot things occasionally early on when I was testing things, but not sure if that was needed. Do you see any logs about ZHA interviewing the dimmer?

@CalumOchkas
Copy link

@mathew-ryan I should preface that my Sonoff ZBBrige is flashed with Tasmota, but I literally just did the 12 button presses and it showed in he ZHA scan after 20 seconds or so.

@atomic10
Copy link

Quick update on the Clipsal Iconic power points for those interested - Clipsal have release the new firmware and they can now be configured to work in Zigbee mode.

Update the power points firmware via the Wiser phone app, then tap the button 12 on the power point times to switch modes.

Added mine to Home Assistant ZHA this morning and they are working perfectly (Using Texas Instruments CC2531 USB).

@jamesmccarthy
Copy link

This is great! Has anybody managed to connect them to a Philips Hue Bridge — does that work?

Hey there. I've got the dimmer mech connected using Zigbee to a Hue bridge (2/square w/ v1.47.x on it). The outcome is not ideal so far.

Dimming works as expected, both via Hue/Hue HomeKit and Hue Homebridge plugin.

Turning on works via both mechanisms as well.

No ability to turn off the switch, via any means except by pressing it.

Turning on/off and dimming worked flawlessly using BLE and the wiser apps.

I've tried channels 15, 20 and 25, so unlikely a channel issue. The switch is <2m from my bridge.

Suspect it's an inconsistency in the way off is handled (either for dimmable or all switches) with either PDL/Clipsal or Hue or both being non-standard. Haven't bothered trying to dig any further yet, probably won't.

Some other notes. The update process was a pita. The app (iOS PDL Wiser Room) failed to read settings. The app is gone from the play store, so I had to side load it onto an old Android to update. Post-upgrade the new Wiser app works well.

I've got another six switches (both 2A and 10A) that I'm going to hook up shortly. Will see if they suffer the same issue and if so will install a conbee. (Sean H has this working).

@jamesmccarthy
Copy link

Update on my last comment: hue bridge was unable to add the 2AX switches so I bought a RaspBee II. Works as expected. Really happy with the setup eh. Confirmed working with the dimming switch, the 2AX switch and the 10AX switch from PDL/Clipsal/Schneider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests