Skip to content

Commit

Permalink
for debug, add compatibility mode in app-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
RWensveen committed Jul 13, 2018
1 parent bc4323e commit 50636f7
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 221 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.broadlink",
"version": "1.3.2",
"version": "1.3.3",
"compatibility": ">=1.5.0",
"sdk": 2,
"name": {
Expand Down
13 changes: 5 additions & 8 deletions drivers/A1/pair/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with com.broadlink. If not, see http://www.gnu.org/licenses/.
-->

<script>

</script>

<style type="text/css">
span label {
Expand Down Expand Up @@ -63,16 +66,15 @@

<script type="text/javascript">




Homey.setTitle(Homey.__('pair.title'));


function showError( msg ) {
$('.broadlink-error').show();
$('.broadlink-error-msg').html( msg );
}


function add( data ) {

var ipAddressElement = document.getElementById('address');
Expand All @@ -95,15 +97,10 @@
}




Homey.on('discovered', function (device) {

if( device ) {
//showError( "found " + device.data.devtype);

if( device.isCompatible ) {
//showError( `found complatible device: ${device.data.name} (${device.data.devtype})`);
Homey.showView('list_devices');
}
else {
Expand Down
15 changes: 11 additions & 4 deletions drivers/BroadlinkDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ class BroadlinkDriver extends Homey.Driver {
var that = this

socket.on('disconnect', function() {
that.discoveredDevices = [];
that._communicate.destroy();
that._communicate = undefined;
});
try {
that.discoveredDevices = [];
that._communicate.destroy();
that._communicate = undefined;
} catch( err ) { ; }
});

socket.on( 'start_discover', function(userdata, callback ) {

Expand All @@ -90,16 +92,21 @@ class BroadlinkDriver extends Homey.Driver {
isCompatible: devinfo.isCompatible
}
that.discoveredDevices.push( device )

Util.debugLog('->onPair.discovered = ' + JSON.stringify(device))
socket.emit('discovered', device )

}, rejectReason => {
Util.debugLog('**>onPair.reject: ' + rejectReason)
socket.emit('discovered', null )
})
.catch( err => {
Util.debugLog('**>onPair.catch: ' + err)
socket.emit('discovered', null )
})
})
.catch( function(err) {
Util.debugLog('**>onPair.catch: ' + err)
socket.emit('discovered',null)
})
})
Expand Down
13 changes: 5 additions & 8 deletions drivers/Hysen/pair/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with com.broadlink. If not, see http://www.gnu.org/licenses/.
-->

<script>

</script>

<style type="text/css">
span label {
Expand Down Expand Up @@ -63,16 +66,15 @@

<script type="text/javascript">




Homey.setTitle(Homey.__('pair.title'));


function showError( msg ) {
$('.broadlink-error').show();
$('.broadlink-error-msg').html( msg );
}


function add( data ) {

var ipAddressElement = document.getElementById('address');
Expand All @@ -95,15 +97,10 @@
}




Homey.on('discovered', function (device) {

if( device ) {
//showError( "found " + device.data.devtype);

if( device.isCompatible ) {
//showError( `found complatible device: ${device.data.name} (${device.data.devtype})`);
Homey.showView('list_devices');
}
else {
Expand Down
81 changes: 5 additions & 76 deletions drivers/MP1/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MP1Device extends BroadlinkDevice {
stop_state_check() {
if( this.checkTimer ) {
clearInterval( this.checkTimer);
this.checkTimer=undefined;
this.checkTimer = null;
}
}

Expand Down Expand Up @@ -129,10 +129,10 @@ class MP1Device extends BroadlinkDevice {

onInit() {
super.onInit();
this.registerCapabilityListener('onoff.s1', onCapabilityOnOff_1.bind(this) )
this.registerCapabilityListener('onoff.s2', onCapabilityOnOff_2.bind(this) )
this.registerCapabilityListener('onoff.s3', onCapabilityOnOff_3.bind(this) )
this.registerCapabilityListener('onoff.s4', onCapabilityOnOff_4.bind(this) )
this.registerCapabilityListener('onoff.s1', this.onCapabilityOnOff_1.bind(this) )
this.registerCapabilityListener('onoff.s2', this.onCapabilityOnOff_2.bind(this) )
this.registerCapabilityListener('onoff.s3', this.onCapabilityOnOff_3.bind(this) )
this.registerCapabilityListener('onoff.s4', this.onCapabilityOnOff_4.bind(this) )
}

/**
Expand All @@ -158,74 +158,3 @@ class MP1Device extends BroadlinkDevice {
}

module.exports = MP1Device;






/****
class mp1(device):
def __init__ (self, host, mac, devtype):
device.__init__(self, host, mac, devtype)
self.type = "MP1"
def set_power_mask(self, sid_mask, state):
"""Sets the power state of the smart power strip."""
packet = bytearray(16)
packet[0x00] = 0x0d
packet[0x02] = 0xa5
packet[0x03] = 0xa5
packet[0x04] = 0x5a
packet[0x05] = 0x5a
packet[0x06] = 0xb2 + ((sid_mask<<1) if state else sid_mask)
packet[0x07] = 0xc0
packet[0x08] = 0x02
packet[0x0a] = 0x03
packet[0x0d] = sid_mask
packet[0x0e] = sid_mask if state else 0
response = self.send_packet(0x6a, packet)
err = response[0x22] | (response[0x23] << 8)
def set_power(self, sid, state):
"""Sets the power state of the smart power strip."""
sid_mask = 0x01 << (sid - 1)
return self.set_power_mask(sid_mask, state)
def check_power_raw(self):
"""Returns the power state of the smart power strip in raw format."""
packet = bytearray(16)
packet[0x00] = 0x0a
packet[0x02] = 0xa5
packet[0x03] = 0xa5
packet[0x04] = 0x5a
packet[0x05] = 0x5a
packet[0x06] = 0xae
packet[0x07] = 0xc0
packet[0x08] = 0x01
response = self.send_packet(0x6a, packet)
err = response[0x22] | (response[0x23] << 8)
if err == 0:
payload = self.decrypt(bytes(response[0x38:]))
if type(payload[0x4]) == int:
state = payload[0x0e]
else:
state = ord(payload[0x0e])
return state
def check_power(self):
"""Returns the power state of the smart power strip."""
state = self.check_power_raw()
data = {}
data['s1'] = bool(state & 0x01)
data['s2'] = bool(state & 0x02)
data['s3'] = bool(state & 0x04)
data['s4'] = bool(state & 0x08)
return data
****/

13 changes: 5 additions & 8 deletions drivers/MP1/pair/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with com.broadlink. If not, see http://www.gnu.org/licenses/.
-->

<script>

</script>

<style type="text/css">
span label {
Expand Down Expand Up @@ -63,16 +66,15 @@

<script type="text/javascript">




Homey.setTitle(Homey.__('pair.title'));


function showError( msg ) {
$('.broadlink-error').show();
$('.broadlink-error-msg').html( msg );
}


function add( data ) {

var ipAddressElement = document.getElementById('address');
Expand All @@ -95,15 +97,10 @@
}




Homey.on('discovered', function (device) {

if( device ) {
//showError( "found " + device.data.devtype);

if( device.isCompatible ) {
//showError( `found complatible device: ${device.data.name} (${device.data.devtype})`);
Homey.showView('list_devices');
}
else {
Expand Down
13 changes: 5 additions & 8 deletions drivers/RM3_mini/pair/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with com.broadlink. If not, see http://www.gnu.org/licenses/.
-->

<script>

</script>

<style type="text/css">
span label {
Expand Down Expand Up @@ -63,16 +66,15 @@

<script type="text/javascript">




Homey.setTitle(Homey.__('pair.title'));


function showError( msg ) {
$('.broadlink-error').show();
$('.broadlink-error-msg').html( msg );
}


function add( data ) {

var ipAddressElement = document.getElementById('address');
Expand All @@ -95,15 +97,10 @@
}




Homey.on('discovered', function (device) {

if( device ) {
//showError( "found " + device.data.devtype);

if( device.isCompatible ) {
//showError( `found complatible device: ${device.data.name} (${device.data.devtype})`);
Homey.showView('list_devices');
}
else {
Expand Down
22 changes: 17 additions & 5 deletions drivers/RM_plus/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
'use strict';

const RM3MiniDevice = require('./../RM3_mini/device');
const Util = require('./../../lib/util.js');


class RmPlusDevice extends RM3MiniDevice {


onInit() {
super.onInit();
this.learn = false;

this.registerCapabilityListener('learnRFCmd', this.onCapabilityLearnRF.bind(this));
this.registerCapabilityListener('learnRFcmd', this.onCapabilityLearnRF.bind(this));
}


Expand All @@ -37,7 +39,7 @@ class RmPlusDevice extends RM3MiniDevice {
* @returns {Promise}
*/
onCapabilityLearnRF(onoff) {
//Util.debugLog('==>RM3miniDevice.onCapabilityLearnIR');
Util.debugLog('==>RM3miniDevice.onCapabilityLearnIR');
if( this.learn ) {
return Promise.resolve()
}
Expand All @@ -46,26 +48,36 @@ class RmPlusDevice extends RM3MiniDevice {
var that = this
return this._communicate.enterRFSweep()
.then( response => {
//Util.debugLog('entered learning');
Util.debugLog(' sweeping');
that._communicate.checkRFData()
.then( data => {
Util.debugLog(' checked RF data ')
that._communicate.cancelRFSweep();
that._communicate.checkRFData2()
.then( data => {
Util.debugLog(' checked RF data 2')
that.learn = false;
if( data ) {
that._communicate.cancelRFSweep();
let idx = that.dataStore.dataArray.length + 1;
let cmdname = 'cmd' + idx;
this.dataStore.addCommand( cmdname, data);

this.storeCmdSetting( cmdname )
this.storeCmdSetting( cmdname );
}
}, rej => {
Util.debugLog(' check RF data 2: reject')
})
}, rej => {
Util.debugLog(' check RF data : reject')
that._communicate.cancelRFSweep();
})
.catch( err => {
that.learn = false;
Util.debugLog('**> RMPlusDevice.onCapabilityLearnIR, error checking data: '+err);
})
}, rej => {
Util.debugLog(' sweep : reject ')
that._communicate.cancelRFSweep();
})
.catch( err => {
Util.debugLog('**> error learning: '+err);
Expand Down
Loading

0 comments on commit 50636f7

Please sign in to comment.