Skip to content

Commit

Permalink
Unpairing feature + version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
louis49 committed Feb 17, 2022
1 parent 5cbaa7a commit 5d453c3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-androidtv",
"version": "2.1.0",
"version": "2.2.0",
"description": "Homebridge plugin to control your AndroidTV / Freebox Player Pop / Freemox Mini 4k",
"main": "dist/index.js",
"engines": {
Expand Down
1 change: 1 addition & 0 deletions src/homebridge/DeviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class DeviceManager extends EventEmitter {
device.paired = false;
device.android_remote.cert = {};
this.save();
return device;
}

async pair(host){
Expand Down
5 changes: 5 additions & 0 deletions src/homebridge/admin/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function api(deviceManager) {
res.json(deviceManager.get(req.params.host).toJSON());
});

api.put('/devices/:host/unpair', async (req, res) => {
await deviceManager.unpair(req.params.host);
res.json(deviceManager.get(req.params.host).toJSON());
});

api.put('/devices/:host/secret', async(req, res) => {
let device = await deviceManager.sendCode(req.params.host, req.body.code);

Expand Down
1 change: 1 addition & 0 deletions src/homebridge/admin/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h6>It seems that no AndroidTV is connected and powered on this network</h6>
</td>
<td style="text-align: center">
<button class="btn btn-primary btn-sm" v-on:click="pair(device)" v-if="device.online && !device.paired && !device.pairing">Pair</button>
<button class="btn btn-danger btn-sm" v-on:click="unpair(device)" v-if="!device.online && device.paired">Unpair</button>
<button class="btn btn-warning btn-sm" v-on:click="power(device)" v-if="device.started">Power</button>
<div class="row" v-if="device.pairing">
<div class="col-sm-4">
Expand Down
7 changes: 7 additions & 0 deletions src/homebridge/admin/static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ const Devices = {
this.devices[device.host] = response.data;
});
},
unpair: function (device){
console.log('Unpair ' + device.host);
axios.put('api/devices/' + device.host + '/unpair').then((response) => {
console.log('Unpaired', response);
this.devices[device.host] = response.data;
});
},
send_code: function (device){
console.log('sendCode ' + device.host + ' ' + this.code);
axios.put('api/devices/' + device.host + '/secret', {code:this.code}).then((response) => {
Expand Down

0 comments on commit 5d453c3

Please sign in to comment.