From e1ca6b33c0521ee87ceffead226d65632bb5c9b1 Mon Sep 17 00:00:00 2001 From: kuestess Date: Sat, 29 Jul 2023 17:05:13 -0400 Subject: [PATCH] Initial support for new i3 keypad --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/InsteonLocalAccessory.ts | 36 ++++++++++++++++++++++++++++++++---- src/InsteonLocalPlatform.ts | 15 +++++++++++++-- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 670a851..9d1eb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 463d4c1..ca259d4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/InsteonLocalAccessory.ts b/src/InsteonLocalAccessory.ts index 50e6d67..a675ee7 100644 --- a/src/InsteonLocalAccessory.ts +++ b/src/InsteonLocalAccessory.ts @@ -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') { @@ -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; } @@ -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; @@ -1384,12 +1402,12 @@ export class InsteonLocalAccessory { //this.log.debug(' 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]]; @@ -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', @@ -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; } diff --git a/src/InsteonLocalPlatform.ts b/src/InsteonLocalPlatform.ts index b02da1b..3edb45c 100644 --- a/src/InsteonLocalPlatform.ts +++ b/src/InsteonLocalPlatform.ts @@ -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; @@ -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; } @@ -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; }