Publish 87,15,49
to topic BLE/c6:c7:52:66:3c:bf/SwitchBot/Request/Set
Subscribe to topic BLE/c6:c7:52:66:3c:bf/SwitchBot/Request/Request
and parse. Sample code in JS below.
Created
July 22, 2023 01:26
-
-
Save xanderificnl/c1416608cad708bc6c82010871fa4559 to your computer and use it in GitHub Desktop.
Switchbot - meter plus (via https://github.com/shmuelzon/esp32-ble2mqtt)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"network": { | |
"wifi": { | |
"ssid": "XiFi", | |
"password": "" | |
} | |
}, | |
"mqtt": { | |
"server": { | |
"host": "192.168.88.253", | |
"port": 1883 | |
}, | |
"publish": { | |
"retain": true | |
}, | |
"topics": { | |
"prefix": "BLE/", | |
"get_suffix": "/Get", | |
"set_suffix": "/Set" | |
} | |
}, | |
"ble": { | |
"whitelist": [ | |
"C6:C7:52:66:3C:BF" | |
], | |
"services": { | |
"definitions": { | |
"CBA20D00-224D-11E6-9FB8-0002A5D5C51B": { | |
"name": "SwitchBot" | |
} | |
} | |
}, | |
"characteristics": { | |
"definitions": { | |
"CBA20002-224D-11E6-9FB8-0002A5D5C51B": { | |
"name": "Request" | |
}, | |
"CBA20003-224D-11E6-9FB8-0002A5D5C51B": { | |
"name": "Response" | |
} | |
} | |
} | |
}, | |
"log": { | |
"host": "224.0.0.200", | |
"port": 5000 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let response = "1,4,150,51" | |
let [a, b, c, d] = response.split(",") | |
// console.log(c *= -1) | |
if (c <= 128) { | |
c *= -1 | |
b *= -1 | |
} else { | |
c -= 128 | |
} | |
temp = c + b; | |
console.log(`temp: ${c}.${b}c - ${d}%`); | |
//> "temp: 22.4c - 51%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment