Comments (5)
@spinachpasta @devWaves If you would like to submit a PR, you can.
from python-host.
@donavanbecker I'm not using this implementation since I use my ESP32 code, I just happen to be browsing and mentioned a quick fix
The sample I provided would overwrite the default no-password option and isn't setup for dynamics password so it would take a bit more work for a full PR
from python-host.
if you want to use password you can make some minor code change to the python code
Example password = 'testpassword'
Steps
- get the CRC32 4 byte hexadecimal value for your password ( you can use an online tool like this https://crc32.online/)
- testpassword = 9dcb7360
- Modify this part of the code ....
if act == 'Turn On':
con.sendline('char-write-cmd ' + cmd_handle + ' 570101')
elif act == 'Turn Off':
con.sendline('char-write-cmd ' + cmd_handle + ' 570102')
elif act == 'Press':
con.sendline('char-write-cmd ' + cmd_handle + ' 570100')
to this...
if act == 'Turn On':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'01')
elif act == 'Turn Off':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'02')
elif act == 'Press':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360')
from python-host.
static byte bArrayPressPass[] = {0x57, 0x11, NULL, NULL, NULL, NULL};
static byte bArrayOnPass[] = {0x57, 0x11, NULL , NULL, NULL, NULL, 0x01};
static byte bArrayOffPass[] = {0x57, 0x11, NULL, NULL, NULL, NULL, 0x02};
static byte bArrayGetSettingsPass[] = {0x57, 0x12, NULL, NULL, NULL, NULL};
static byte bArrayHoldSecsPass[] = {0x57, 0x1F, NULL, NULL, NULL, NULL, 0x08, NULL };
//static byte bArrayBotModePass[] = {0x57, 0x13, 0x64, NULL, NULL, NULL, NULL, NULL}; // Other github documentation shows this to be the array for setting mode with password (firmware 4.5, 4.6)
static byte bArrayBotModePass[] = {0x57, 0x13, NULL, NULL, NULL, NULL, 0x64, NULL}; // The proper array to use for setting mode with password (firmware 4.9)
These implementations from SwitchBot-MQTT-BLE-ESP32 suggests that second bit should be 0x11 not 0x01 when controlling bots with password.
I only tested press signal, but other implementation seems plausible.
Thus, the correct code should be the following:(I haven't tested the python implementation yet. Tell me if this is wrong)
if act == 'Turn On':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'01')
elif act == 'Turn Off':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'02')
elif act == 'Press':
con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360')
from python-host.
static byte bArrayPressPass[] = {0x57, 0x11, NULL, NULL, NULL, NULL}; static byte bArrayOnPass[] = {0x57, 0x11, NULL , NULL, NULL, NULL, 0x01}; static byte bArrayOffPass[] = {0x57, 0x11, NULL, NULL, NULL, NULL, 0x02}; static byte bArrayGetSettingsPass[] = {0x57, 0x12, NULL, NULL, NULL, NULL}; static byte bArrayHoldSecsPass[] = {0x57, 0x1F, NULL, NULL, NULL, NULL, 0x08, NULL }; //static byte bArrayBotModePass[] = {0x57, 0x13, 0x64, NULL, NULL, NULL, NULL, NULL}; // Other github documentation shows this to be the array for setting mode with password (firmware 4.5, 4.6) static byte bArrayBotModePass[] = {0x57, 0x13, NULL, NULL, NULL, NULL, 0x64, NULL}; // The proper array to use for setting mode with password (firmware 4.9)These implementations from SwitchBot-MQTT-BLE-ESP32 suggests that second bit should be 0x11 not 0x01 when controlling bots with password. I only tested press signal, but other implementation seems plausible.
Thus, the correct code should be the following:(I haven't tested the python implementation yet. Tell me if this is wrong)
if act == 'Turn On': con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'01') elif act == 'Turn Off': con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360' +'02') elif act == 'Press': con.sendline('char-write-cmd ' + cmd_handle + ' 5711' + '9dcb7360')
yep, my bad. should be 11 not 01
That small change also assumes you use the same password for all bots
from python-host.
Related Issues (20)
- UnicodeDecodeError on pip3 download gattlib HOT 4
- Curtain support? HOT 8
- RuntimeError: Characteristic value/descriptor operation failed: Invalid handle HOT 1
- Add Curtain "pause" HOT 2
- Add curtain info output HOT 1
- Can't send commands - curtain HOT 2
- MagicSwitchbot -> ConnectionError... why? HOT 1
- Add Curtain left and right commands (same as calibration) HOT 4
- Contact Sensor, Motion Sensor Support
- Contact Sensor: Going out counter and entry counter are not increased
- Connection Refused (111) HOT 1
- Curtain BLE - Support slider control mode single side
- The documentation for the set RGB on the color bulb is incorrect HOT 1
- battery level still not possible? HOT 1
- Attribute can't be read on Meter device with BLE open API
- Can't send "Press" to Bot HOT 10
- Get historic temperature data from SwitchBot Meter Plus
- Documentation is too old to be understandable and need some review HOT 3
- Invalid handle on all commands HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-host.