Skip to content

Commit

Permalink
feat(add): 929003711201, 929003711301 (#8069)
Browse files Browse the repository at this point in the history
* Add Philips Hue Twilight (white & black)

* Rename fromZigbee.ignore_command_off to ignore_command_off_with_effect

* Use new fromZigbee.ignore_command_off
  • Loading branch information
mundschenk-at authored Oct 3, 2024
1 parent 6c19808 commit b2949e2
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
24 changes: 24 additions & 0 deletions src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4339,6 +4339,25 @@ const converters1 = {
}
},
} satisfies Fz.Converter,
hue_twilight: {
cluster: 'manuSpecificPhilips',
type: 'commandHueNotification',
convert: (model, msg, publish, options, meta) => {
const buttonLookup: KeyValueAny = {1: 'dot', 2: 'hue'};
const button = buttonLookup[msg.data['button']];
const typeLookup: KeyValueAny = {0: 'press', 1: 'hold', 2: 'press_release', 3: 'hold_release'};
const type = typeLookup[msg.data['type']];
const payload: KeyValueAny = {action: `${button}_${type}`};

// duration
if (type === 'press') globalStore.putValue(msg.endpoint, 'press_start', Date.now());
else if (type === 'hold' || type === 'release') {
payload.action_duration = (Date.now() - globalStore.getValue(msg.endpoint, 'press_start')) / 1000;
}

return payload;
},
} satisfies Fz.Converter,
tuya_relay_din_led_indicator: {
cluster: 'genOnOff',
type: ['attributeReport', 'readResponse'],
Expand Down Expand Up @@ -4876,6 +4895,11 @@ const converters1 = {
convert: (model, msg, publish, options, meta) => {},
} satisfies Fz.Converter,
ignore_command_off: {
cluster: 'genOnOff',
type: 'commandOff',
convert: (model, msg, publish, options, meta) => {},
} satisfies Fz.Converter,
ignore_command_off_with_effect: {
cluster: 'genOnOff',
type: 'commandOffWithEffect',
convert: (model, msg, publish, options, meta) => {},
Expand Down
34 changes: 31 additions & 3 deletions src/devices/philips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as exposes from '../lib/exposes';
import * as legacy from '../lib/legacy';
import {deviceEndpoints, identify, quirkCheckinInterval} from '../lib/modernExtend';
import * as ota from '../lib/ota';
import {philipsFz, philipsLight, philipsOnOff, philipsTz} from '../lib/philips';
import {philipsFz, philipsLight, philipsOnOff, philipsTwilightOnOff, philipsTz} from '../lib/philips';
import * as reporting from '../lib/reporting';
import {DefinitionWithExtend} from '../lib/types';

Expand Down Expand Up @@ -2221,7 +2221,7 @@ const definitions: DefinitionWithExtend[] = [
description: 'Hue dimmer switch',
fromZigbee: [
fz.ignore_command_on,
fz.ignore_command_off,
fz.ignore_command_off_with_effect,
fz.ignore_command_step,
fz.ignore_command_stop,
legacy.fz.hue_dimmer_switch,
Expand Down Expand Up @@ -2273,7 +2273,7 @@ const definitions: DefinitionWithExtend[] = [
description: 'Hue dimmer switch',
fromZigbee: [
fz.ignore_command_on,
fz.ignore_command_off,
fz.ignore_command_off_with_effect,
fz.ignore_command_step,
fz.ignore_command_stop,
fz.hue_dimmer_switch,
Expand Down Expand Up @@ -3834,6 +3834,34 @@ const definitions: DefinitionWithExtend[] = [
description: 'Hue White and Color Ambiance Datura Ceiling light small',
extend: [philipsLight({colorTemp: {range: [153, 500]}, color: {modes: ['xy', 'hs'], enhancedHue: true}})],
},
{
zigbeeModel: ['LGT001'],
model: '929003711201',
vendor: 'Philips',
description: 'Hue Twilight sleep and wake-up light white',
extend: [
deviceEndpoints({endpoints: {switch: 1, back: 11, front: 12}}),

philipsLight({colorTemp: {range: [153, 500]}, color: true, endpointNames: ['front']}),
philipsLight({colorTemp: {range: [153, 500]}, color: true, gradient: true, endpointNames: ['back']}),

philipsTwilightOnOff(),
],
},
{
zigbeeModel: ['LGT002'],
model: '929003711301',
vendor: 'Philips',
description: 'Hue Twilight sleep and wake-up light black',
extend: [
deviceEndpoints({endpoints: {switch: 1, back: 11, front: 12}}),

philipsLight({colorTemp: {range: [153, 500]}, color: true, endpointNames: ['front']}),
philipsLight({colorTemp: {range: [153, 500]}, color: true, gradient: true, endpointNames: ['back']}),

philipsTwilightOnOff(),
],
},
];

export default definitions;
29 changes: 28 additions & 1 deletion src/lib/philips.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {Zcl} from 'zigbee-herdsman';

import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as reporting from '../lib/reporting';
import {ColorRGB, ColorXY} from './color';
import * as libColor from './color';
import * as exposes from './exposes';
import {logger} from './logger';
import * as modernExtend from './modernExtend';
import * as ota from './ota';
import * as globalStore from './store';
import {Fz, KeyValue, KeyValueAny, Tz} from './types';
import {Configure, Fz, KeyValue, KeyValueAny, ModernExtend, Tz} from './types';
import * as utils from './utils';
import {exposeEndpoints, isObject} from './utils';

Expand Down Expand Up @@ -100,6 +102,31 @@ export function philipsOnOff(args?: modernExtend.OnOffArgs) {
return result;
}

export function philipsTwilightOnOff() {
const fromZigbee = [fz.ignore_command_on, fz.ignore_command_off, fz.hue_twilight];
const exposes = [
e.action([
'dot_press',
'dot_hold',
'dot_press_release',
'dot_hold_release',
'hue_press',
'hue_hold',
'hue_press_release',
'hue_hold_release',
]),
];
const toZigbee: Tz.Converter[] = [];
const configure: Configure[] = [
async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff', 'manuSpecificPhilips']);
},
];
const result: ModernExtend = {exposes, fromZigbee, toZigbee, configure, isModernExtend: true};
return result;
}

export const philipsTz = {
gradient_scene: {
key: ['gradient_scene'],
Expand Down

0 comments on commit b2949e2

Please sign in to comment.