This app provides a simple server for controlling broadlink devices from google home.
Using MQTT publisher subscriber for homes with dynamic IP
In order to work with this sample you should register an mqtt account for instance in https://www.cloudmqtt.com/
The server part is running on your local network and there is the client part that runs on a machine in the cloud with public endpoint or a static ip
- Run:
$ cd home-server
$ npm install
$ MQTT_URL=mqtts://{{username}}:{{password}}@{{mqtt url}}:{{port}} node server.js
-
Send a request to your client endpoint,
something likehttps://{{your endpoint}}/sendCommand?topic=learn&message={deviceName}:{action}
-
See that your broadlink enters learning mode
- Create config.json on the root of your project config.json example:
{
"MQTT_URL": "mqtts://{{username}}:{{password}}@{{mqtt url}}:{{port}}"
}
- Run
$ cd home-server
$ npm install
$ node server.js
-
Send a request to your client endpoint,
something likehttps://{{your endpoint}}/sendCommand?topic=learn&message={deviceName}:{action}
-
See that your broadlink enters learning mode
In order to run on windows you need to:
- Provide your internal network ip prefix(or your full ip if you prefer)
in a global environment called
IP_PREFIX
- Find your broadcast ip by calling ipconfig as described here
- Set global environment called
BROADCAST_ADDRESS
with your broadcast address (or your broadlink address if you prefer)
You can also add a config.json to the root of your project with the above parameters
- run:
$ cd home-server
$ npm install
$ IP_PREFIX=10.0.0 BROADCAST_ADDRESS=10.0.0.255 MQTT_URL=mqtts://{{username}}:{{password}}@{{mqtt url}}:{{port}} node server.js
-
Send a request to your client endpoint,
something likehttps://{{your endpoint}}/sendCommand?topic=learn&message={deviceName}:{action}
-
See that your broadlink enters learning mode
- Create config.json on the root of your project config.json example:
{
"BROADCAST_ADDRESS": "10.0.0.255",
"MQTT_URL": "mqtts://{{username}}:{{password}}@{{mqtt url}}:{{port}}",
"IP_PREFIX": "10.0.0"
}
- Run
$ cd home-server
$ npm install
$ node server.js
-
Send a request to your client endpoint,
something likehttps://{{your endpoint}}/sendCommand?topic=learn&message={deviceName}:{action}
-
See that your broadlink enters learning mode
Scenes are several commands that runs on a single call
Add the scene name and commands to home-server/scenes-data.json
for example:
{
"switchInput": [{"topic":"tv","action":"input"},{"topic":"tv","action":"input"},{"topic":"tv","action":"ok"}],
"secondScene": [{"topic":"devicename","action":"action"},{}]
}
- Based on this blog
- Using this nodejs broadlink connector