Skip to content

Commit

Permalink
feat(add): S1-R-2 (#7915)
Browse files Browse the repository at this point in the history
* Add support for new ubisys S1-R (Series 2).

* review: set multiEndpointSkip in deviceEnpoints, use more friendly model name.

* use polling to read currentSumDeleviered attribute, to be more independent of the actual amount of device messages.

* Update src/devices/ubisys.ts

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
lgraf and Koenkk authored Sep 6, 2024
1 parent ad373af commit 0b51cc0
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/devices/ubisys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as constants from '../lib/constants';
import * as exposes from '../lib/exposes';
import * as legacy from '../lib/legacy';
import {logger} from '../lib/logger';
import {commandsColorCtrl, commandsLevelCtrl, commandsOnOff, deviceEndpoints, electricityMeter, identify, onOff} from '../lib/modernExtend';
import * as ota from '../lib/ota';
import * as reporting from '../lib/reporting';
import {DefinitionWithExtend, Fz, OnEventType, Tz, OnEventData, Zh, KeyValue, KeyValueAny} from '../lib/types';
Expand Down Expand Up @@ -38,6 +39,15 @@ const ubisysOnEventReadCurrentSummDelivered = async function (type: OnEventType,
}
};

const ubisysPollCurrentSummDelivered = async (type: OnEventType, data: OnEventData, device: Zh.Device, endpointId: number, options: KeyValue) => {
const endpoint = device.getEndpoint(endpointId);
const poll = async () => {
await endpoint.read('seMetering', ['currentSummDelivered']);
};

utils.onEventPoll(type, data, device, options, 'measurement', 60, poll);
};

const ubisys = {
fz: {
dimmer_setup: {
Expand Down Expand Up @@ -725,6 +735,54 @@ const definitions: DefinitionWithExtend[] = [
},
ota: ota.ubisys,
},
{
// S1-R Series 2 uses the same modelId as the regular S1-R, but the energy clusters are located in endpoint 1 (instead of 4, like the regular S1-R).
fingerprint: [
{
manufacturerName: 'ubisys',
modelID: 'S1-R (5601)',
endpoints: [{ID: 1, profileID: 260, deviceID: 266, inputClusters: [0, 3, 4, 5, 6, 1794, 2820], outputClusters: []}],
},
],
model: 'S1-R-2',
vendor: 'ubisys',
description: 'Power switch S1-R (Series 2)',
extend: [
deviceEndpoints({endpoints: {'1': 1, '2': 2, '3': 3, '232': 232}, multiEndpointSkip: ['state', 'power', 'energy']}),
identify(),
onOff({powerOnBehavior: false}),
electricityMeter({cluster: 'metering', configureReporting: false}),
commandsOnOff({endpointNames: ['2', '3']}),
commandsLevelCtrl({endpointNames: ['2', '3']}),
commandsColorCtrl({endpointNames: ['2', '3']}),
],
options: [exposes.options.measurement_poll_interval()],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['seMetering']);
await reporting.readMeteringMultiplierDivisor(endpoint);
await reporting.instantaneousDemand(endpoint);
},
onEvent: async (type, data, device, settings) => {
/*
* As per technical doc page 18 section 7.3.4
* https://www.ubisys.de/wp-content/uploads/ubisys-s1-technical-reference.pdf
*
* This cluster uses the binding table for managing command targets.
* When factory fresh, this cluster is bound to endpoint #1 to
* enable local control.
*
* We use addBinding to 'record' this default binding.
*/
if (type === 'deviceInterview') {
const ep1 = device.getEndpoint(1);
const ep2 = device.getEndpoint(2);
ep2.addBinding('genOnOff', ep1);
} else {
await ubisysPollCurrentSummDelivered(type, data, device, 1, settings);
}
},
},
{
zigbeeModel: ['S2 (5502)', 'S2-R (5602)'],
model: 'S2',
Expand Down

0 comments on commit 0b51cc0

Please sign in to comment.