Smart Plug mit bluetoothctl steuern
Keine Ahnung wie viele Stunden mich dieser Post gekostet hat. Wenn ich von Anfang an gewusst hätte wie lange das braucht, hätte ich wohl gar nicht damit angefangen...
Selbst Google findet nur wenige Informationen und die meisten davon scheinen veraltet zu sein.
Erster Schritt
Factory Reset mit der Hue Bluetooth App oder dem Bedienpanel! Ohne diesen Schritt kann man den Plug nicht pairen.
Die Bluetooth App machte Probleme. Beim ersten mal gings noch so knapp, aber beim zweiten Reset-Versuch landete sie in einer Endlosschleife: Connecting -> Pairing -> Failure -> Connecting ...
Das Bedienpanel funktionierte jedesmal ohne Probleme.
Der Plug bekommt bei jedem Reset eine neue Adresse, die hier angegebene Adresse ist also nicht mehr gültig ;-)
Ungelöst
Wie wird man das Pairing wieder los? bluetoothctl hat zwar ein cancel-pairing, das führte aber regelmässig zu einer Fehlermeldung.
Im Internet wird zwar ein undokumentierter remove-Befehl empfohlen, aber der scheint nur einseitig zu wirken. bluez meldet den Plug zwar nicht mehr als Paired, aber er liess sich ohne Reset nicht wieder pairen.
Plug steuern mit bluetoothctl
Die Kommentarzeilen starten mit #. Sie dienen nur zur Erklärung.
root@Microknoppix:/home/knoppix# bluetoothctl Agent registered [CHG] Controller 18:1D:EA:5F:97:17 Pairable: yes # Nach Devices scannen [bluetooth]# scan on Discovery started [CHG] Controller 18:1D:EA:5F:97:17 Discovering: yes [NEW] Device C9:01:05:07:86:43 Hue Smart plug # Pairing starten [bluetooth]# pair C9:01:05:07:86:43 Attempting to pair with C9:01:05:07:86:43 [CHG] Device C9:01:05:07:86:43 Connected: yes [CHG] Device C9:01:05:07:86:43 UUIDs: 00001800-0000-1000-8000-00805f9b34fb [CHG] Device C9:01:05:07:86:43 UUIDs: 00001801-0000-1000-8000-00805f9b34fb [CHG] Device C9:01:05:07:86:43 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb [CHG] Device C9:01:05:07:86:43 UUIDs: 0000fe0f-0000-1000-8000-00805f9b34fb [CHG] Device C9:01:05:07:86:43 UUIDs: 932c32bd-0000-47a2-835a-a8d455b859dd [CHG] Device C9:01:05:07:86:43 UUIDs: 9da2ddf1-0000-44d0-909c-3f3d3cb34a7b [CHG] Device C9:01:05:07:86:43 UUIDs: b8843add-0000-4aa1-8794-c3f462030bda [CHG] Device C9:01:05:07:86:43 ServicesResolved: yes [CHG] Device C9:01:05:07:86:43 Paired: yes [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0001 00001801-0000-1000-8000-00805f9b34fb Generic Attribute Profile [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0001/char0002 00002a05-0000-1000-8000-00805f9b34fb Service Changed [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0001/char0002/desc0004 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0001/char0005 00002b2a-0000-1000-8000-00805f9b34fb Database Hash [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0001/char0007 00002b29-0000-1000-8000-00805f9b34fb Client Supported Features [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service000e 0000180a-0000-1000-8000-00805f9b34fb Device Information [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service000e/char000f 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service000e/char0011 00002a24-0000-1000-8000-00805f9b34fb Model Number String [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service000e/char0013 00002a28-0000-1000-8000-00805f9b34fb Software Revision String [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015 0000fe0f-0000-1000-8000-00805f9b34fb Signify Netherlands B.V. (formerly Philips Lighting B.V.) [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0016 97fe6561-0001-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0018 97fe6561-0003-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char001a 97fe6561-0004-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char001c 97fe6561-0008-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char001c/desc001e 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char001f 97fe6561-1001-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char001f/desc0021 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0022 97fe6561-2001-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0024 97fe6561-2002-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0026 97fe6561-2004-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0015/char0028 97fe6561-a001-4f62-86e9-b71ee2da3d22 Vendor specific [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a 932c32bd-0000-47a2-835a-a8d455b859dd Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002b 932c32bd-0001-47a2-835a-a8d455b859dd Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d 932c32bd-0002-47a2-835a-a8d455b859dd Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d/desc002f 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char0039 932c32bd-0006-47a2-835a-a8d455b859dd Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char003b 932c32bd-0007-47a2-835a-a8d455b859dd Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char003b/desc003d 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char003e 932c32bd-1005-47a2-835a-a8d455b859dd Vendor specific [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040 b8843add-0000-4aa1-8794-c3f462030bda Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040/char0041 b8843add-0001-4aa1-8794-c3f462030bda Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040/char0043 b8843add-0002-4aa1-8794-c3f462030bda Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040/char0043/desc0045 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040/char0046 b8843add-0003-4aa1-8794-c3f462030bda Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service0040/char0048 b8843add-0004-4aa1-8794-c3f462030bda Vendor specific [NEW] Primary Service (Handle 0x95ac) /org/bluez/hci0/dev_C9_01_05_07_86_43/service004a 9da2ddf1-0000-44d0-909c-3f3d3cb34a7b Vendor specific [NEW] Characteristic (Handle 0x728e) /org/bluez/hci0/dev_C9_01_05_07_86_43/service004a/char004b 9da2ddf1-0001-44d0-909c-3f3d3cb34a7b Vendor specific [NEW] Descriptor (Handle 0x0d1c) /org/bluez/hci0/dev_C9_01_05_07_86_43/service004a/char004b/desc004d 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration Pairing successful [CHG] Device C9:01:05:07:86:43 ServiceData Key: 0000fe0f-0000-1000-8000-00805f9b34fb [CHG] Device C9:01:05:07:86:43 ServiceData Value: 5a 10 ff ff 00 Z.... [Hue Smart plug]# menu gatt Menu gatt: Available commands: ------------------- list-attributes [dev/local] List attributes select-attribute <attribute/UUID> Select attribute attribute-info [attribute/UUID] Select attribute read [offset] Read attribute value write <data=xx xx ...> [offset] [type] 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 clone [dev/attribute/UUID] Clone a device or attribute register-application [UUID ...] Register profile to connect unregister-application Unregister profile register-service <UUID> [handle] Register application service. unregister-service <UUID/object> Unregister application service register-includes <UUID> [handle] Register as Included service in. unregister-includes <Service-UUID><Inc-UUID> Unregister Included service. register-characteristic <UUID> <Flags=read,write,notify...> [handle] Register application characteristic unregister-characteristic <UUID/object> Unregister application characteristic register-descriptor <UUID> <Flags=read,write...> [handle] 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 environment variables # Attribut auswählen [Hue Smart plug]# select-attribute 932c32bd-0002-47a2-835a-a8d455b859dd # Status abfragen [Hue Smart plug:/service002a/char002d]# read Attempting to read /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d [CHG] Attribute /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d Value: 01 . 01 . # Ausschalten [Hue Smart plug:/service002a/char002d]# write 00 Attempting to write /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d # Einschalten [Hue Smart plug:/service002a/char002d]# write 01 Attempting to write /org/bluez/hci0/dev_C9_01_05_07_86_43/service002a/char002d # Bedienungsfehler [Hue Smart plug:/service002a/char002d]# cancel-pairing Invalid command in menu gatt: cancel-pairing Use "help" for a list of available commands in a menu. Use "menu <submenu>" if you want to enter any submenu. Use "back" if you want to return to menu main. [Hue Smart plug:/service002a/char002d]# back Menu main: Available commands: ------------------- advertise Advertise Options Submenu scan Scan Options Submenu gatt Generic Attribute Submenu list List available controllers show [ctrl] Controller information select <ctrl> Select default controller devices List available devices paired-devices List paired devices system-alias <name> Set controller alias reset-alias Reset controller alias power <on/off> Set controller power pairable <on/off> Set controller pairable mode discoverable <on/off> Set controller discoverable mode discoverable-timeout [value] Set discoverable timeout agent <on/off/capability> Enable/disable agent with given capability default-agent Set agent as the default one advertise <on/off/type> Enable/disable advertising with given type set-alias <alias> Set device alias scan <on/off> Scan for devices info [dev] Device information pair [dev] Pair with device cancel-pairing [dev] Cancel pairing with device trust [dev] Trust device untrust [dev] Untrust device block [dev] Block device unblock [dev] Unblock device remove <dev> Remove device connect <dev> Connect device disconnect [dev] Disconnect device menu <name> Select submenu version Display version quit Quit program exit Quit program help Display help about this program export Print environment variables # So nicht [Hue Smart plug:/service002a/char002d]# cancel-pairing Attempting to cancel pairing with C9:01:05:07:86:43 Failed to cancel pairing: org.bluez.Error.DoesNotExist # So auch nicht [Hue Smart plug:/service002a/char002d]# cancel-pairing C9:01:05:07:86:43 Attempting to cancel pairing with C9:01:05:07:86:43 Failed to cancel pairing: org.bluez.Error.DoesNotExist [Hue Smart plug:/service002a/char002d]# exit # Kontrolle -> immer noch paired root@Microknoppix:/home/knoppix# bluetoothctl Agent registered [CHG] Controller 18:1D:EA:5F:97:17 Pairable: yes [Hue Smart plug]# connect C9:01:05:07:86:43 Attempting to connect to C9:01:05:07:86:43 Connection successful [Hue Smart plug]# info ) Name: Hue Smart plug Alias: Hue Smart plug Paired: yes Trusted: no Blocked: no Connected: yes LegacyPairing: no UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: Device Information (0000180a-0000-1000-8000-00805f9b34fb) UUID: Signify Netherlands B.V.. (0000fe0f-0000-1000-8000-00805f9b34fb) UUID: Vendor specific (932c32bd-0000-47a2-835a-a8d455b859dd) UUID: Vendor specific (9da2ddf1-0000-44d0-909c-3f3d3cb34a7b) UUID: Vendor specific (b8843add-0000-4aa1-8794-c3f462030bda) ServiceData Key: 0000fe0f-0000-1000-8000-00805f9b34fb ServiceData Value: 5a 10 ff ff 00 Z.... [CHG] Controller 18:1D:EA:5F:97:17 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb [CHG] Controller 18:1D:EA:5F:97:17 UUIDs: 00001200-0000-1000-8000-00805f9b34fb . . .