在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:AMoo-Miki/homebridge-switchmate-ble开源软件地址:https://github.com/AMoo-Miki/homebridge-switchmate-ble开源编程语言:JavaScript 100.0%开源软件介绍:homebridge-switchmate-bleHomebridge plugin for Switchmate light switches and power outlets, allowing them to be exposed to Apple's HomeKit and HTTP. Note: v1.3.0 adds the new v3 signature and depends on NodeJS v14. I like to test the plugin for a few weeks but I have rushed it out to allow you to use it. I will be testing and improving the plugin for a few weeks. My setup uses BlueZ v5.55 on an RPi 3 but if you face a problem, don't hesitate to raise an issue; bare in mind that I might not be able to address it for weeks due to... hmm... you know... life! InstallationAfter fulfilling the prerequisites, install this plugin using Update the PrerequisitesThis plugin depends on @abandonware/noble. Refer to their prerequisites to prepare your system. The node-bluetooth-hci-socket package, a nested dependency, is not installable on OSX. Hence, this plugin will not be usable on that platform. PermissionsNodeJS needs permission to control the Bluetooth radio on your system. Execute the command below to give NodeJS the capability use raw sockets and manage the interface.
UpdatingUpdate to the latest release of this plugin using If you feel brave, want to help test unreleased updates, or are asked to update to the latest unreleased version of the plugin, use ConfigurationsThis plugin lets you group switches to manage three-way switches. It also optionally exposes your devices via HTTP, with and without authentication. Finding your SwitchmateRun
The configuration parameters to enable your devices would need to be added to {
...
"platforms": [
...
/* The block you need to enable this plugin */
{
"platform": "SwitchmateBLE",
/* To enable HTTP control, set the port number you want it to listen on.
* Omitting this field or setting it to false will disable the HTTP server
* and setting it to anything other than a finite number will turn on the
* server on port 8282.
*/
"http": 50505,
/* To enable authentication, set both the fields below; omit to ignore. */
"httpUser": "unique-user",
"httpPass": "Un!9u3p4$5W0rD",
"devices": [
/* This is a v1 switch */
{
"name": "Garage Light",
"id": "ffee5500eeaa",
"authCode": "aOsDXw=="
},
/* This is a v3 switch or plug */
{
"name": "Hallway Plug",
"id": "aacc2211aabb"
},
/* This is a 3-way switch with v1 and v3 mixed */
{
"name": "Kitchen Lights",
"group" : [
{
"id": "aa11bb22cc33",
"authCode": "3WeRbA=="
},
{
"id": "aa11bb22cc44"
}
]
}
]
}
/* End of the block needed to enable this plugin */
]
...
} HTTP controlListTo get a list of the controllable devices and their IDs: curl -X GET http://0.0.0.0:50505 The output would be a JSON object of key-values: keys are IDs and values are names. {"e9181f6b-40f7-4cd4-aa4b-a1caf038305e": "Garage Light", ...} Get stateAppending the device ID to the base URL, you can get the state of a light switch. Power plugs have 3 devices; adding ":" followed by a number indicates which device you are querying. #Light switch
curl -X GET http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e
# Power plug night light uses ":0"
curl -X GET http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:0
# Top plug uses ":1"
curl -X GET http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:1
# Bottom plug uses ":2"
curl -X GET http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:2 The output would be a JSON object with the state indicating if the device is on ( {"device": "e9181f6b-40f7-4cd4-aa4b-a1caf038305e", "state": true} Set stateControlling a device is done using the Method 1: Putting JSONThe state is fed into #Light switch
curl -X PUT -d "{\"state\":true}" http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e
# Power plug night light uses ":0"
curl -X PUT -d "{\"state\":true}" http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:0
# Top plug uses ":1"
curl -X PUT -d "{\"state\":true}" http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:1
# Bottom plug uses ":2"
curl -X PUT -d "{\"state\":true}" http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:2 Method 2: Using a suffixThis method omits passing any data, in favor of "/on" and "/off" suffices. #Light switch
curl -X PUT http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e/on
# Power plug night light uses ":0"
curl -X PUT http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:0/on
# Top plug uses ":1"
curl -X PUT http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:1/on
# Bottom plug uses ":2"
curl -X PUT http://0.0.0.0:50505/e9181f6b-40f7-4cd4-aa4b-a1caf038305e:2/on NoteThe plugin periodically checks on If you use the Switchmate app on your phone or tablet to control a switch or plug, the I recommend you not add the plugs and switches to the Switchmate app to prevent them from updating and instead use the HTTP server to integrate with Alexa and others. Also, some Switchmates are simply unreliable. I have a bunch that work for a day and then just stop working. There is nothing the plugin can do to wake them up or prevent them from going bad. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论