New binding for DAIKIN Madoka Controller (BLE)

For those interested - I’ve also developed a HABPanel Thermostat Widget:

Okay… I just checked your code - I’ll refactor mine to align with same design patterns!

Hi Benjamin @hairdresser and thank you for your hard work! I just bought a Madoka and it will be wonderful if I can use it with OH.

Currently, I’m having trouble with the initial pairing process. When I try to pair via bluetoothctl I got a Failed to pair: org.bluez.Error.AuthenticationTimeout error (that happens only with my raspberry pi, with my laptop it works fine).
I saw you mentioned that kind of a problem in the docs, but I can’t find any solution. Do you have any insight on this?

Thanks again!

Thanks @OhadEytan !

So first of all - I would recommend:
1/ stop OH
2/ physically power off the madoka (remove the power - not “standby” or “off”), and after 30 seconds, re-enable the power. I’ve seen that the Madoka does not really handle correctly the pairing of multiple devices, and sometimes a cold restart is necessary (only for pairing!)
3/ on your OH Linux Box:

hciconfig hci0 down
hciconfig hci0 up
hciconfig hci0 sspmode 1
bluetoothctl
scan on
# after a while - 15 secs 
scan off
devices # < will print devices in range
trust xx:xx:xx:xx:xx #< with the mac address of your device
pair xx:xx:xx:xx:xx 
# At this point, the madoka will ask confirmation code, as well as your bluetoothctl prompt. My experience is first press the "ok" on the madoka, then after 2 or 3 seconds, type "yes" in the bluetoothctl prompt.

Hopefully - this must only be done once!

Tell me if it works

1 Like

Thanks for the guidance. Unfortunately, I have no success yet, even with the powering off.
I suspect it’s not a Madoka problem, but something with my raspberry, since I can pair it to my arch-linux laptop.

What is the bluez version ?

ben@openhab-dev:~$ bluetoothctl -v
bluetoothctl: 5.53
$ bluetoothctl -v
bluetoothctl: 5.50

I’ll try update it.
(Totally forget about that, in the meantime I’m using my android phone)

Ah!
The Madoka is not able to talk to 2 devices at a time. So you absolutely need to gracefully close the connection from your phone. That is why I suggest completely turning the power off to perform a “cold start” before pairing.

Are you sure? Anyway, it seems that is not the problem.
I tried to unbind the android phone, restarted the Madoka, and my laptop is pairing just fine with the same conditions.
:tired_face:

Updated to:

bluetoothctl: 5.54

Didn’t helped

Yep I am - once the Madoka has a session established with one device - it cannot talk at the same time with another.

When you try to pair - does the Madoka or your PI ask to confirm a passcode ? Or it fails before ?

Fail before, any time with one of the below errors:

Failed to pair: org.bluez.Error.AuthenticationCanceled
Failed to pair: org.bluez.Error.AuthenticationTimeout
Failed to pair: org.bluez.Error.AuthenticationFailed

it seems like you don’t have any agent running.

Have you issued bluetoothctl commands before pairing:

[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful

Sure. Doesn’t help:

openhabian@192:~ $ sudo hciconfig hci0 down; sudo hciconfig hci0 up; sudo hciconfig hci0 sspmode 1; sudo bluetoothctl 
Agent registered
[bluetooth]# agent on
Agent is already registered
[bluetooth]# default-agent 
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:99:E3:2B Discovering: yes
[CHG] Device 00:CC:3F:E4:EE:2A RSSI: -48
[CHG] Device 58:7A:62:43:9D:ED RSSI: -59
[CHG] Device C1:97:91:3E:74:81 RSSI: -53
[bluetooth]# scan off
Discovery stopped
[CHG] Controller B8:27:EB:99:E3:2B Discovering: no
[CHG] Device C1:97:91:3E:74:81 RSSI is nil
[CHG] Device 58:7A:62:43:9D:ED RSSI is nil
[CHG] Device 00:CC:3F:E4:EE:2A RSSI is nil
[bluetooth]# devices
Device C1:97:91:3E:74:81 C1-97-91-3E-74-81
Device 58:7A:62:43:9D:ED OhadDesk
Device 00:CC:3F:E4:EE:2A OhadAir
Device 20:79:18:BA:93:74 ohadlaptop
[bluetooth]# trust 00:CC:3F:E4:EE:2A 
Changing 00:CC:3F:E4:EE:2A trust succeeded
[bluetooth]# pair 00:CC:3F:E4:EE:2A 
Attempting to pair with 00:CC:3F:E4:EE:2A
[CHG] Device 00:CC:3F:E4:EE:2A Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 00:CC:3F:E4:EE:2A Connected: no
[bluetooth]# pair 00:CC:3F:E4:EE:2A 
Attempting to pair with 00:CC:3F:E4:EE:2A
[CHG] Device 00:CC:3F:E4:EE:2A Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 00:CC:3F:E4:EE:2A Connected: no
[bluetooth]# pair 00:CC:3F:E4:EE:2A 
Attempting to pair with 00:CC:3F:E4:EE:2A
[CHG] Device 00:CC:3F:E4:EE:2A Connected: yes
[CHG] Device 00:CC:3F:E4:EE:2A Connected: no
Failed to pair: org.bluez.Error.AuthenticationCanceled
[bluetooth]# pair 00:CC:3F:E4:EE:2A 
Attempting to pair with 00:CC:3F:E4:EE:2A
Failed to pair: org.bluez.Error.AuthenticationFailed
[bluetooth]#

what does the following command return ?

systemctl status bluetooth

It seems some people have experienced problems with PI.

Can you try the workaround advised here ?

https://www.raspberrypi.org/forums/viewtopic.php?p=947185#p947185

That is the output:

● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
   Active: active (running) since Sun 2020-08-09 07:17:09 IDT; 2 days ago
     Docs: man:bluetoothd
 Main PID: 604 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─604 /usr/libexec/bluetooth/bluetoothd -d -d

Aug 11 14:12:06 192.168.1.2 bluetoothd[604]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr 00:CC:3F:E4:EE:2A type 1 io_cap 0x04
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/adapter.c:pair_device_complete() Not Connected (0x02)
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:CC:3F:E4:EE:2A type 1 status 0x2
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/device.c:device_bonding_complete() bonding 0x1422708 status 0x02
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/device.c:device_bonding_failed() status 2
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/agent.c:agent_unref() 0x14315a0: ref=1
Aug 11 14:12:09 192.168.1.2 bluetoothd[604]: src/adapter.c:resume_discovery()
Aug 11 14:12:13 192.168.1.2 bluetoothd[604]: src/agent.c:agent_disconnect() Agent :1.43 disconnected
Aug 11 14:12:13 192.168.1.2 bluetoothd[604]: src/agent.c:agent_destroy() agent :1.43
Aug 11 14:12:13 192.168.1.2 bluetoothd[604]: src/agent.c:agent_unref() 0x14315a0: ref=0

Warning: Unit file changed on disk, 'systemctl daemon-reload' recommended.

No luck with this fix either :frowning_face:

stupid question - is your PI close or far from your Madoka unit ? (the thermostat)

1 Like

Something like 2 meter maybe, I tried once to get it closer but it didn’t helped. It see it in the scan so I suppose it’s not too far.