Skip to content

Commit

Permalink
Add support for Pico 4-button remotes
Browse files Browse the repository at this point in the history
This change adds support for Pico 4-button *scene* and *zone* remotes.
In all truth, I only have a Pico4ButtonZone on-hand, but I very strongly
suspect the Pico4ButtonScene remotes share the button mapping. This does
not add support for Pico4Button remotes.
  • Loading branch information
thenewwazoo committed May 7, 2022
1 parent 4659208 commit 1f625d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
35 changes: 29 additions & 6 deletions src/PicoRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ import { ExceptionDetail, OneButtonStatusEvent, Response, SmartBridge } from 'lu

import { inspect } from 'util';

// This maps device types and button numbers to human-readable labels and
// This maps DeviceType and ButtonNumber to human-readable labels and
// ServiceLabelIndex values. n.b. the labels are not shown in Apple's Home app,
// but are shown in other apps. The index value determines the order that
// buttons are shown in the Home app. They're ordered top-to-bottom here.
// buttons are shown in the Home app. They're ordered top-to-bottom (as they
// appear on the physical remote) in this map.
//
// [
// $DeviceType,
// new Map([
// [$ButtonNumber, { label: '...', index: ... }],
// ...
// ]),
// ]
const BUTTON_MAP = new Map<string, Map<number, { label: string; index: number }>>([
[
'Pico2Button',
Expand Down Expand Up @@ -44,14 +53,28 @@ const BUTTON_MAP = new Map<string, Map<number, { label: string; index: number }>
[4, { label: 'Lower', index: 4 }],
]),
],
[
'Pico4ButtonScene',
new Map([
[1, { label: 'Button 1', index: 1 }],
[2, { label: 'Button 2', index: 2 }],
[3, { label: 'Button 3', index: 3 }],
[4, { label: 'Button 4', index: 4 }],
]),
],
[
'Pico4ButtonZone',
new Map([
[1, { label: 'Button 1', index: 1 }],
[2, { label: 'Button 2', index: 2 }],
[3, { label: 'Button 3', index: 3 }],
[4, { label: 'Button 4', index: 4 }],
]),
],
// TODO
/*
['Pico4Button', new Map([
])],
['Pico4ButtonScene', new Map([
])],
['Pico4ButtonZone', new Map([
])],
['Pico4Button2Group', new Map([
])],
*/
Expand Down
12 changes: 8 additions & 4 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ export class LutronCasetaLeap
case 'Pico2Button':
case 'Pico2ButtonRaiseLower':
case 'Pico3Button':
case 'Pico3ButtonRaiseLower': {
case 'Pico3ButtonRaiseLower':
case 'Pico4ButtonZone':
case 'Pico4ButtonScene':
{
this.log.info(
'Restoring Pico remote',
accessory.context.device.FullyQualifiedName.join(' '),
Expand Down Expand Up @@ -235,7 +238,10 @@ export class LutronCasetaLeap
case 'Pico2Button':
case 'Pico2ButtonRaiseLower':
case 'Pico3Button':
case 'Pico3ButtonRaiseLower': {
case 'Pico3ButtonRaiseLower':
case 'Pico4ButtonScene':
case 'Pico4ButtonZone':
{
this.log.info('Found a new', d.DeviceType, 'remote', fullName);

// SIDE EFFECT: this constructor mutates the accessory object
Expand Down Expand Up @@ -264,8 +270,6 @@ export class LutronCasetaLeap
// TODO
// known devices that are not exposed to homekit, pending support
case 'Pico4Button':
case 'Pico4ButtonScene':
case 'Pico4ButtonZone':
case 'Pico4Button2Group':
case 'FourGroupRemote': {
this.log.info('Device type', d.DeviceType, 'not yet supported, skipping setup');
Expand Down

0 comments on commit 1f625d3

Please sign in to comment.