Skip to content

Commit

Permalink
Initial support for new i3 keypad
Browse files Browse the repository at this point in the history
  • Loading branch information
kuestess committed Jul 29, 2023
1 parent d68e95d commit e1ca6b3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.5.10] - 2023-07-29
### Enhanced
- Initial support for new i3 keypad

## [0.5.9] - 2023-07-07
### Enhanced
- Update device database to include new i3 devices
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "InsteonLocal",
"name": "homebridge-platform-insteonlocal",
"version": "0.5.9",
"version": "0.5.10",
"description": "Insteon platform plugin with local control for homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",
"repository": {
Expand Down
36 changes: 32 additions & 4 deletions src/InsteonLocalAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ export class InsteonLocalAccessory {
this.groupID = this.device.groupID;
this.keypadbtn = this.device.keypadbtn;
this.six_btn = this.device.six_btn;
this.four_btn = this.device.four_btn;
this.momentary = this.device.momentary || false;
}

if (this.deviceType == 'keypad') {
this.keypadbtn = typeof(this.device.keypadbtn) === 'string' ? this.device.keypadbtn : '?';
this.six_btn = this.device.six_btn === true;
this.four_btn = this.device.four_btn === true;
}

if (this.deviceType == 'iolinc') {
Expand Down Expand Up @@ -817,12 +819,21 @@ export class InsteonLocalAccessory {
'ON': eight_buttonArray['A'] | eight_buttonArray['B'],
'OFF': eight_buttonArray['G'] | eight_buttonArray['H']};

const four_buttonArray = {
'1': eight_buttonArray['A'],
'2': eight_buttonArray['B'],
'3': eight_buttonArray['C'],
'4': eight_buttonArray['D'],
};

let buttonArray;

this.platform.checkHubConnection();

if(this.six_btn == true){
buttonArray = six_buttonArray;
} else if (this.four_btn == true){
buttonArray = four_buttonArray;
} else {
buttonArray = eight_buttonArray;
}
Expand Down Expand Up @@ -1342,6 +1353,13 @@ export class InsteonLocalAccessory {
'D': eight_buttonArray['F'],
};

const four_buttonArray = {
'1': eight_buttonArray['A'],
'2': eight_buttonArray['B'],
'3': eight_buttonArray['C'],
'4': eight_buttonArray['D'],
};

let buttonArray;
const index1 = this.setTargetKeypadCount;

Expand Down Expand Up @@ -1384,12 +1402,12 @@ export class InsteonLocalAccessory {

//this.log.debug('<Check point 4> index1 = ' + index1)

if(this.targetKeypadSixBtn[index1] == true){
if(this.six_btn == true){
buttonArray = six_buttonArray;
this.log.debug(' Using 6-button keypad layout');
} else if (this.four_btn == true){
buttonArray = four_buttonArray;
} else {
buttonArray = eight_buttonArray;
this.log.debug(' Using 8-button keypad layout');
}

const buttonNumber = buttonArray[this.targetKeypadBtn[index1]];
Expand Down Expand Up @@ -1759,19 +1777,27 @@ export class InsteonLocalAccessory {
'G': 1,
'H': 0,
};

const six_buttonArray = {
'A': eight_buttonArray['C'],
'B': eight_buttonArray['D'],
'C': eight_buttonArray['E'],
'D': eight_buttonArray['F'],
};

const four_buttonArray = {
'1': eight_buttonArray['A'],
'2': eight_buttonArray['B'],
'3': eight_buttonArray['C'],
'4': eight_buttonArray['D'],
};

let buttonArray;

this.log('Setting state of ' + this.name + ' to ' + state);

this.platform.checkHubConnection();


const getButtonMap = (callback) => {
const command = {
cmd1: '19',
Expand Down Expand Up @@ -1802,6 +1828,8 @@ export class InsteonLocalAccessory {

if(this.six_btn == true){
buttonArray = six_buttonArray;
} else if (this.four_btn == true){
buttonArray = four_buttonArray;
} else {
buttonArray = eight_buttonArray;
}
Expand Down
15 changes: 13 additions & 2 deletions src/InsteonLocalPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ export class InsteonLocalPlatform implements DynamicPlatformPlugin {
eventListener() {
const eight_buttonArray = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8};
const six_buttonArray = {'ON': 1, 'A': 3, 'B': 4, 'C': 5, 'D': 6, 'OFF': 1};
const four_buttonArray = {
'1': eight_buttonArray['A'],
'2': eight_buttonArray['B'],
'3': eight_buttonArray['C'],
'4': eight_buttonArray['D'],
};

let buttonArray;

const deviceIDs = this.deviceIDs;
Expand Down Expand Up @@ -470,7 +477,9 @@ export class InsteonLocalPlatform implements DynamicPlatformPlugin {

if(foundDevice.six_btn == true){
buttonArray = six_buttonArray;
} else {
} else if (foundDevice.four_btn == true){
buttonArray = four_buttonArray;
}else {
buttonArray = eight_buttonArray;
}

Expand Down Expand Up @@ -500,7 +509,9 @@ export class InsteonLocalPlatform implements DynamicPlatformPlugin {

if(foundDevice.six_btn == true){
buttonArray = six_buttonArray;
} else {
} else if (foundDevice.four_btn == true){
buttonArray = four_buttonArray;
}else {
buttonArray = eight_buttonArray;
}

Expand Down

0 comments on commit e1ca6b3

Please sign in to comment.