Closed parisbutterfield closed 6 years ago
Thanks for the report and detailed steps, @parisbutterfield! I do have Bright and Original devices to test with.
Indeed it seems that 0x2E
actually controls the "reversed" flag of the Bright devices. Whoops!
0x30
is apparently the right handle to switch, but I found that sending consecutive "on" or "off" commands would actually toggle the switch to the opposite state. So I changed the implementation in #10 to check for the current state and write to 0x30
only if needed.
Let me know if you can confirm that the new implementation does what it should.
Hey @brianpeiris @F1nny
I noticed an issue when switching/reading state with the new script. Using the 0x2e handle will lead to on/off commands being reversed when physical presses are used. 0x2e also isn't reliable for getting the devices state. If the device is physically pressed 0x30 is updated and not 0x2e.
Hopefully this makes enough sense. What I’ve done in my restswitchmate project is use the 0x30 handle to switch on and off. This way physical presses never get out of sync with the API calls. Also the iOS application is using 0x30 for state.
I'm not sure how the classic (non-bright) behaves. Is this something you can test?
Switch is physically OFF.
Retrieving debug info... uuid common name handle properties value
00002a00-0000-1000-8000-00805f9b34fb Device Name 3 READ WRITE beacon 00002a01-0000-1000-8000-00805f9b34fb Appearance 5 READ 0000 00002a04-0000-1000-8000-00805f9b34fb Peripheral Preferred Connection Parameters 7 READ 5000a00000009001 00002aa6-0000-1000-8000-00805f9b34fb Central Address Resolution 9 READ 01 00002a05-0000-1000-8000-00805f9b34fb Service Changed c INDICATE 01 00002a19-0000-1000-8000-00805f9b34fb Battery Level 10 NOTIFY READ d 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String 14 READ Switchmate 00002a24-0000-1000-8000-00805f9b34fb Model Number String 16 READ Bright 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String 18 READ 3.0 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String 1a READ 2.9.15 00002a23-0000-1000-8000-00805f9b34fb System ID 1c READ 55aa55aa55eebbee a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab 1f READ WRITE 15063504 a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab 21 READ WRITE 000000000000 a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab 23 READ WRITE 000000000000 a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab 25 READ WRITE 000000000000 a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab 27 READ WRITE 0000000000000000000000000000000000 a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab 29 READ WRITE 00 a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab 2b NOTIFY READ 00000000 a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab 2e READ WRITE 01 a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab 30 READ WRITE 00 a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab 32 READ WRITE 000000000001 a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab 34 READ dd1678b----- a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab 36 READ b0857970f35c a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab 38 READ db2a2fc2034f5caef184e5a3f2447071 a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab 3a READ WRITE 00000000000000000000000000000000 a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab 3c READ 0.0 8ec90003-f315-4f60-9fb8-838830daea50 8ec90003-f315-4f60-9fb8-838830daea50 3f INDICATE WRITE 0.0
Retrieving debug info... uuid common name handle properties value
00002a00-0000-1000-8000-00805f9b34fb Device Name 3 READ WRITE beacon 00002a01-0000-1000-8000-00805f9b34fb Appearance 5 READ 0000 00002a04-0000-1000-8000-00805f9b34fb Peripheral Preferred Connection Parameters 7 READ 5000a00000009001 00002aa6-0000-1000-8000-00805f9b34fb Central Address Resolution 9 READ 01 00002a05-0000-1000-8000-00805f9b34fb Service Changed c INDICATE 01 00002a19-0000-1000-8000-00805f9b34fb Battery Level 10 NOTIFY READ d 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String 14 READ Switchmate 00002a24-0000-1000-8000-00805f9b34fb Model Number String 16 READ Bright 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String 18 READ 3.0 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String 1a READ 2.9.15 00002a23-0000-1000-8000-00805f9b34fb System ID 1c READ 55aa55aa55eebbee a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab 1f READ WRITE 150f0104 a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab 21 READ WRITE 000000000000 a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab 23 READ WRITE 000000000000 a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab 25 READ WRITE 000000000000 a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab 27 READ WRITE 0000000000000000000000000000000000 a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab 29 READ WRITE 00 a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab 2b NOTIFY READ 01000000 a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab 2e READ WRITE 01 a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab 30 READ WRITE 01 a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab 32 READ WRITE 000000000001 a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab 34 READ dd1678b----- a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab 36 READ b0857970f35c a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab 38 READ db2a2fc203b30454ef57296b6077f0b7 a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab 3a READ WRITE 00000000000000000000000000000000 a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab 3c READ 0.0 8ec90003-f315-4f60-9fb8-838830daea50 8ec90003-f315-4f60-9fb8-838830daea50 3f INDICATE WRITE 0.0
dev@dev:~/git/switchmate$ ./switchmate.py FF:EA:B6:--:--:-- none switch on Switched! dev@dev:~/git/switchmate$ ./switchmate.py FF:EA:B6:--:--:-- debug Retrieving debug info... uuid common name handle properties value
00002a00-0000-1000-8000-00805f9b34fb Device Name 3 READ WRITE beacon 00002a01-0000-1000-8000-00805f9b34fb Appearance 5 READ 0000 00002a04-0000-1000-8000-00805f9b34fb Peripheral Preferred Connection Parameters 7 READ 5000a00000009001 00002aa6-0000-1000-8000-00805f9b34fb Central Address Resolution 9 READ 01 00002a05-0000-1000-8000-00805f9b34fb Service Changed c INDICATE 01 00002a19-0000-1000-8000-00805f9b34fb Battery Level 10 NOTIFY READ d 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String 14 READ Switchmate 00002a24-0000-1000-8000-00805f9b34fb Model Number String 16 READ Bright 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String 18 READ 3.0 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String 1a READ 2.9.15 00002a23-0000-1000-8000-00805f9b34fb System ID 1c READ 55aa55aa55eebbee a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab 1f READ WRITE 15102704 a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab 21 READ WRITE 000000000000 a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab 23 READ WRITE 000000000000 a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab 25 READ WRITE 000000000000 a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab 27 READ WRITE 0000000000000000000000000000000000 a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab 29 READ WRITE 00 a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab 2b NOTIFY READ 01000000 a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab 2e READ WRITE 01 a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab 30 READ WRITE 01 a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab 32 READ WRITE 000000000001 a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab 34 READ dd1678b----- a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab 36 READ b0857970f35c a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab 38 READ db2a2fc203c47a59f1171d91ad43bccc a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab 3a READ WRITE 00000000000000000000000000000000 a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab 3c READ 0.0 8ec90003-f315-4f60-9fb8-838830daea50 8ec90003-f315-4f60-9fb8-838830daea50 3f INDICATE WRITE 0.0
dev@dev:~/git/switchmate$ ./switchmate.py FF:EA:B6:--:--:-- none switch off Switched! dev@dev:~/git/switchmate$ ./switchmate.py FF:EA:B6:--:--:-- debug Retrieving debug info... uuid common name handle properties value
00002a00-0000-1000-8000-00805f9b34fb Device Name 3 READ WRITE beacon 00002a01-0000-1000-8000-00805f9b34fb Appearance 5 READ 0000 00002a04-0000-1000-8000-00805f9b34fb Peripheral Preferred Connection Parameters 7 READ 5000a00000009001 00002aa6-0000-1000-8000-00805f9b34fb Central Address Resolution 9 READ 01 00002a05-0000-1000-8000-00805f9b34fb Service Changed c INDICATE 01 00002a19-0000-1000-8000-00805f9b34fb Battery Level 10 NOTIFY READ d 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String 14 READ Switchmate 00002a24-0000-1000-8000-00805f9b34fb Model Number String 16 READ Bright 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String 18 READ 3.0 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String 1a READ 2.9.15 00002a23-0000-1000-8000-00805f9b34fb System ID 1c READ 55aa55aa55eebbee a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab a22b0010-ebdd-49ac-b2e7-40eb55f5d0ab 1f READ WRITE 15123804 a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab a22b0020-ebdd-49ac-b2e7-40eb55f5d0ab 21 READ WRITE 000000000000 a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab a22b0030-ebdd-49ac-b2e7-40eb55f5d0ab 23 READ WRITE 000000000000 a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab a22b0040-ebdd-49ac-b2e7-40eb55f5d0ab 25 READ WRITE 000000000000 a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab a22b0050-ebdd-49ac-b2e7-40eb55f5d0ab 27 READ WRITE 0000000000000000000000000000000000 a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab a22b0060-ebdd-49ac-b2e7-40eb55f5d0ab 29 READ WRITE 00 a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab a22b0070-ebdd-49ac-b2e7-40eb55f5d0ab 2b NOTIFY READ 01000000 a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab a22b0080-ebdd-49ac-b2e7-40eb55f5d0ab 2e READ WRITE 00 a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab a22b0090-ebdd-49ac-b2e7-40eb55f5d0ab 30 READ WRITE 01 a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab a22b00d0-ebdd-49ac-b2e7-40eb55f5d0ab 32 READ WRITE 000000000001 a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab a22b0200-ebdd-49ac-b2e7-40eb55f5d0ab 34 READ dd1678b----- a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab a22b0210-ebdd-49ac-b2e7-40eb55f5d0ab 36 READ b0857970f35c a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab a22b0220-ebdd-49ac-b2e7-40eb55f5d0ab 38 READ db2a2fc203d5d644f255ff3de8ce47e7 a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab a22b0230-ebdd-49ac-b2e7-40eb55f5d0ab 3a READ WRITE 00000000000000000000000000000000 a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab a22b0310-ebdd-49ac-b2e7-40eb55f5d0ab 3c READ 0.0 8ec90003-f315-4f60-9fb8-838830daea50 8ec90003-f315-4f60-9fb8-838830daea50 3f INDICATE WRITE 0.0