Skip to content

Commit

Permalink
fix: Use deviceEndpoints extend instead of endpoint definitions (#7107)
Browse files Browse the repository at this point in the history
* Separate endpoint defenition and application

* Fixes and tests
  • Loading branch information
mrskycriper committed Feb 24, 2024
1 parent 2666891 commit 1d33581
Show file tree
Hide file tree
Showing 35 changed files with 405 additions and 160 deletions.
7 changes: 5 additions & 2 deletions src/devices/atsmart.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {Definition} from '../lib/types';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';

const definitions: Definition[] = [
{
zigbeeModel: ['Z601', 'Z602', 'Z603', 'Z604'],
model: 'Z6',
vendor: 'Atsmart',
description: '3 gang smart wall switch (no neutral wire)',
extend: [onOff({endpoints: {left: 1, center: 2, right: 3}})],
extend: [
deviceEndpoints({endpoints: {'left': 1, 'center': 2, 'right': 3}}),
onOff({endpointNames: ['left', 'center', 'right']}),
],
},
];

Expand Down
34 changes: 27 additions & 7 deletions src/devices/dawon_dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as reporting from '../lib/reporting';
import {forcePowerSource, onOff} from '../lib/modernExtend';
import {deviceEndpoints, forcePowerSource, onOff} from '../lib/modernExtend';
import {Definition, Fz, Tz} from '../lib/types';
const e = exposes.presets;
const ea = exposes.access;
Expand Down Expand Up @@ -117,14 +117,20 @@ const definitions: Definition[] = [
model: 'PM-S240-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 2 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, bottom: 2}, powerOnBehavior: false})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'bottom': 2}}),
onOff({endpointNames: ['top', 'bottom'], powerOnBehavior: false}),
],
},
{
zigbeeModel: ['PM-S340-ZB'],
model: 'PM-S340-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 3 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, center: 2, bottom: 3}, powerOnBehavior: false})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'center': 2, 'bottom': 3}}),
onOff({endpointNames: ['top', 'center', 'bottom'], powerOnBehavior: false}),
],
},
{
zigbeeModel: ['PM-S140R-ZB'],
Expand All @@ -138,14 +144,20 @@ const definitions: Definition[] = [
model: 'PM-S240R-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 2 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, bottom: 2}, powerOnBehavior: false})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'bottom': 2}}),
onOff({endpointNames: ['top', 'bottom'], powerOnBehavior: false}),
],
},
{
zigbeeModel: ['PM-S340R-ZB'],
model: 'PM-S340R-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 3 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, center: 2, bottom: 3}, powerOnBehavior: false})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'center': 2, 'bottom': 3}}),
onOff({endpointNames: ['top', 'center', 'bottom'], powerOnBehavior: false}),
],
},
{
zigbeeModel: ['PM-S150-ZB'],
Expand All @@ -159,14 +171,22 @@ const definitions: Definition[] = [
model: 'PM-S250-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 2 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, bottom: 2}, powerOnBehavior: false}), forcePowerSource({powerSource: 'Mains (single phase)'})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'bottom': 2}}),
onOff({endpointNames: ['top', 'bottom'], powerOnBehavior: false}),
forcePowerSource({powerSource: 'Mains (single phase)'}),
],
},
{
zigbeeModel: ['PM-S350-ZB'],
model: 'PM-S350-ZB',
vendor: 'Dawon DNS',
description: 'IOT smart switch 3 gang without neutral wire',
extend: [onOff({endpoints: {top: 1, center: 2, bottom: 3}, powerOnBehavior: false}), forcePowerSource({powerSource: 'Mains (single phase)'})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'center': 2, 'bottom': 3}}),
onOff({endpointNames: ['top', 'center', 'bottom'], powerOnBehavior: false}),
forcePowerSource({powerSource: 'Mains (single phase)'}),
],
},
{
zigbeeModel: ['PM-C150-ZB'],
Expand Down
7 changes: 5 additions & 2 deletions src/devices/diyruz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as constants from '../lib/constants';
import * as reporting from '../lib/reporting';
import extend from '../lib/extend';
import {Definition} from '../lib/types';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';

const e = exposes.presets;
const ea = exposes.access;
Expand All @@ -17,7 +17,10 @@ const definitions: Definition[] = [
model: 'DIYRuZ_R4_5',
vendor: 'DIYRuZ',
description: '[DiY 4 Relays + 4 switches + 1 buzzer](http://modkam.ru/?p=1054)',
extend: [onOff({endpoints: {bottom_left: 1, bottom_right: 2, top_left: 3, top_right: 4, center: 5}})],
extend: [
deviceEndpoints({endpoints: {'bottom_left': 1, 'bottom_right': 2, 'top_left': 3, 'top_right': 4, 'center': 5}}),
onOff({endpointNames: ['bottom_left', 'bottom_right', 'top_left', 'top_right', 'center']}),
],
},
{
zigbeeModel: ['DIYRuZ_KEYPAD20'],
Expand Down
12 changes: 9 additions & 3 deletions src/devices/dresden_elektronik.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Definition} from '../lib/types';
import * as ota from '../lib/ota';
import {batteryPercentage, light} from '../lib/modernExtend';
import {batteryPercentage, deviceEndpoints, light} from '../lib/modernExtend';

const definitions: Definition[] = [
{
Expand All @@ -9,7 +9,10 @@ const definitions: Definition[] = [
vendor: 'Dresden Elektronik',
description: 'ZigBee Light Link wireless electronic ballast',
ota: ota.zigbeeOTA,
extend: [light({colorTemp: {range: undefined}, color: true, endpoints: {rgb: 10, white: 11}})],
extend: [
deviceEndpoints({endpoints: {'rgb': 10, 'white': 11}}),
light({colorTemp: {range: undefined}, color: true, endpointNames: ['rgb', 'white']}),
],
},
{
zigbeeModel: ['FLS-CT'],
Expand Down Expand Up @@ -39,7 +42,10 @@ const definitions: Definition[] = [
model: 'BN-600078',
vendor: 'Dresden Elektronik',
description: 'Zigbee controller for 1-10V/PWM',
extend: [light({endpoints: {l1: 11, l2: 12, l3: 13, l4: 14}})],
extend: [
deviceEndpoints({endpoints: {'l1': 11, 'l2': 12, 'l3': 13, 'l4': 14}}),
light({endpointNames: ['l1', 'l2', 'l3', 'l4']}),
],
meta: {disableDefaultResponse: true},
},
];
Expand Down
7 changes: 5 additions & 2 deletions src/devices/ecodim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fz from '../converters/fromZigbee';
const e = exposes.presets;
import * as ota from '../lib/ota';
import * as tuya from '../lib/tuya';
import {light} from '../lib/modernExtend';
import {deviceEndpoints, light} from '../lib/modernExtend';

const definitions: Definition[] = [
{
Expand All @@ -23,7 +23,10 @@ const definitions: Definition[] = [
model: 'Eco-Dim.05',
vendor: 'EcoDim',
description: 'LED dimmer duo 2x 0-100W',
extend: [light({effect: false, configureReporting: true, endpoints: {left: 2, right: 1}})],
extend: [
deviceEndpoints({endpoints: {'left': 2, 'right': 1}}),
light({effect: false, configureReporting: true, endpointNames: ['left', 'right']}),
],
},
{
fingerprint: [
Expand Down
7 changes: 5 additions & 2 deletions src/devices/envilar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Definition} from '../lib/types';
import * as exposes from '../lib/exposes';
const e = exposes.presets;
import fz from '../converters/fromZigbee';
import {light, onOff} from '../lib/modernExtend';
import {deviceEndpoints, light, onOff} from '../lib/modernExtend';

const definitions: Definition[] = [
{
Expand Down Expand Up @@ -49,7 +49,10 @@ const definitions: Definition[] = [
model: '2CH-ZG-BOX-RELAY',
vendor: 'Envilar',
description: '2 channel box relay',
extend: [onOff({endpoints: {l1: 1, l2: 2}})],
extend: [
deviceEndpoints({endpoints: {'l1': 1, 'l2': 2}}),
onOff({endpointNames: ['l1', 'l2']}),
],
},
];

Expand Down
22 changes: 17 additions & 5 deletions src/devices/ewelink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Definition, Fz} from '../lib/types';
import * as exposes from '../lib/exposes';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';
const e = exposes.presets;

const fzLocal = {
Expand Down Expand Up @@ -90,7 +90,10 @@ const definitions: Definition[] = [
model: 'ZB-SW02',
vendor: 'eWeLink',
description: 'Smart light switch/2 gang relay',
extend: [onOff({endpoints: {left: 1, right: 2}, configureReporting: false})],
extend: [
deviceEndpoints({endpoints: {'left': 1, 'right': 2}}),
onOff({endpointNames: ['left', 'right'], configureReporting: false}),
],
onEvent: async (type, data, device) => {
device.skipDefaultResponse = true;
},
Expand All @@ -100,7 +103,10 @@ const definitions: Definition[] = [
model: 'ZB-SW03',
vendor: 'eWeLink',
description: 'Smart light switch - 3 gang',
extend: [onOff({endpoints: {left: 1, center: 2, right: 3}, configureReporting: false})],
extend: [
deviceEndpoints({endpoints: {'left': 1, 'center': 2, 'right': 3}}),
onOff({endpointNames: ['left', 'center', 'right'], configureReporting: false}),
],
onEvent: async (type, data, device) => {
device.skipDefaultResponse = true;
},
Expand All @@ -110,7 +116,10 @@ const definitions: Definition[] = [
model: 'ZB-SW04',
vendor: 'eWeLink',
description: 'Smart light switch - 4 gang',
extend: [onOff({endpoints: {l1: 1, l2: 2, l3: 3, l4: 4}, configureReporting: false})],
extend: [
deviceEndpoints({endpoints: {'l1': 1, 'l2': 2, 'l3': 3, 'l4': 4}}),
onOff({endpointNames: ['l1', 'l2', 'l3', 'l4'], configureReporting: false}),
],
onEvent: async (type, data, device) => {
device.skipDefaultResponse = true;
},
Expand All @@ -120,7 +129,10 @@ const definitions: Definition[] = [
model: 'ZB-SW05',
vendor: 'eWeLink',
description: 'Smart light switch - 5 gang',
extend: [onOff({endpoints: {l1: 1, l2: 2, l3: 3, l4: 4, l5: 5}, configureReporting: false})],
extend: [
deviceEndpoints({endpoints: {'l1': 1, 'l2': 2, 'l3': 3, 'l4': 4, 'l5': 5}}),
onOff({endpointNames: ['l1', 'l2', 'l3', 'l4', 'l5'], configureReporting: false}),
],
onEvent: async (type, data, device) => {
device.skipDefaultResponse = true;
},
Expand Down
7 changes: 5 additions & 2 deletions src/devices/ezex.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {Definition} from '../lib/types';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';

const definitions: Definition[] = [
{
zigbeeModel: ['E220-KR3N0Z0-HA'],
model: 'ECW-100-A03',
vendor: 'eZEX',
description: 'Zigbee switch 3 gang',
extend: [onOff({endpoints: {top: 1, center: 2, bottom: 3}})],
extend: [
deviceEndpoints({endpoints: {'top': 1, 'center': 2, 'bottom': 3}}),
onOff({endpointNames: ['top', 'center', 'bottom']}),
],
},
];

Expand Down
17 changes: 13 additions & 4 deletions src/devices/feibit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as reporting from '../lib/reporting';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';

const e = exposes.presets;

Expand All @@ -13,7 +13,10 @@ const definitions: Definition[] = [
model: 'TZSW22FW-L4',
vendor: 'Feibit',
description: 'Smart light switch - 2 gang',
extend: [onOff({endpoints: {top: 16, bottom: 17}})],
extend: [
deviceEndpoints({endpoints: {'top': 16, 'bottom': 17}}),
onOff({endpointNames: ['top', 'bottom']}),
],
},
{
zigbeeModel: ['FB56+ZSW1GKJ2.3'],
Expand Down Expand Up @@ -125,14 +128,20 @@ const definitions: Definition[] = [
model: 'SLS301ZB_2',
vendor: 'Feibit',
description: 'Smart light switch - 2 gang',
extend: [onOff({endpoints: {left: 16, right: 17}})],
extend: [
deviceEndpoints({endpoints: {'left': 16, 'right': 17}}),
onOff({endpointNames: ['left', 'right']}),
],
},
{
zigbeeModel: ['FB56+ZSW1IKJ2.2', 'FB56+ZSW1IKJ1.1'],
model: 'SLS301ZB_3',
vendor: 'Feibit',
description: 'Smart light switch - 3 gang',
extend: [onOff({endpoints: {left: 16, center: 17, right: 18}})],
extend: [
deviceEndpoints({endpoints: {'left': 16, 'center': 17, 'right': 18}}),
onOff({endpointNames: ['left', 'center', 'right']}),
],
},
{
zigbeeModel: ['FB56+ZSN08KJ2.2'],
Expand Down
7 changes: 5 additions & 2 deletions src/devices/gewiss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as reporting from '../lib/reporting';
import {onOff} from '../lib/modernExtend';
import {deviceEndpoints, onOff} from '../lib/modernExtend';
const e = exposes.presets;

const definitions: Definition[] = [
Expand All @@ -19,7 +19,10 @@ const definitions: Definition[] = [
model: 'GWA1522',
description: 'Switch actuator 2 channels with input',
vendor: 'Gewiss',
extend: [onOff({endpoints: {l1: 1, l2: 2}})],
extend: [
deviceEndpoints({endpoints: {'l1': 1, 'l2': 2}}),
onOff({endpointNames: ['l1', 'l2']}),
],
},
{
zigbeeModel: ['GWA1531_Shutter'],
Expand Down

0 comments on commit 1d33581

Please sign in to comment.