matterbridge-iotas 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +1 -1
  3. package/dist/src/constants.d.ts +0 -35
  4. package/dist/src/constants.js +0 -36
  5. package/dist/src/constants.js.map +0 -1
  6. package/dist/src/deviceFactory.d.ts +0 -19
  7. package/dist/src/deviceFactory.js +0 -66
  8. package/dist/src/deviceFactory.js.map +0 -1
  9. package/dist/src/devices/helpers.d.ts +0 -52
  10. package/dist/src/devices/helpers.js +0 -135
  11. package/dist/src/devices/helpers.js.map +0 -1
  12. package/dist/src/devices/index.d.ts +0 -6
  13. package/dist/src/devices/index.js +0 -6
  14. package/dist/src/devices/index.js.map +0 -1
  15. package/dist/src/devices/lights.d.ts +0 -4
  16. package/dist/src/devices/lights.js +0 -35
  17. package/dist/src/devices/lights.js.map +0 -1
  18. package/dist/src/devices/lock.d.ts +0 -3
  19. package/dist/src/devices/lock.js +0 -44
  20. package/dist/src/devices/lock.js.map +0 -1
  21. package/dist/src/devices/outlet.d.ts +0 -3
  22. package/dist/src/devices/outlet.js +0 -6
  23. package/dist/src/devices/outlet.js.map +0 -1
  24. package/dist/src/devices/sensors.d.ts +0 -5
  25. package/dist/src/devices/sensors.js +0 -44
  26. package/dist/src/devices/sensors.js.map +0 -1
  27. package/dist/src/devices/thermostat.d.ts +0 -9
  28. package/dist/src/devices/thermostat.js +0 -101
  29. package/dist/src/devices/thermostat.js.map +0 -1
  30. package/dist/src/devices/types.d.ts +0 -26
  31. package/dist/src/devices/types.js +0 -5
  32. package/dist/src/devices/types.js.map +0 -1
  33. package/dist/src/module.d.ts +0 -40
  34. package/dist/src/module.js +0 -137
  35. package/dist/src/module.js.map +0 -1
  36. package/dist/test/deviceFactory.test.d.ts +0 -1
  37. package/dist/test/deviceFactory.test.js +0 -168
  38. package/dist/test/deviceFactory.test.js.map +0 -1
  39. package/dist/test/devices/helpers.d.ts +0 -18
  40. package/dist/test/devices/helpers.js +0 -70
  41. package/dist/test/devices/helpers.js.map +0 -1
  42. package/dist/test/devices/lights.test.d.ts +0 -1
  43. package/dist/test/devices/lights.test.js +0 -46
  44. package/dist/test/devices/lights.test.js.map +0 -1
  45. package/dist/test/devices/lock.test.d.ts +0 -1
  46. package/dist/test/devices/lock.test.js +0 -43
  47. package/dist/test/devices/lock.test.js.map +0 -1
  48. package/dist/test/devices/outlet.test.d.ts +0 -1
  49. package/dist/test/devices/outlet.test.js +0 -18
  50. package/dist/test/devices/outlet.test.js.map +0 -1
  51. package/dist/test/devices/sensors.test.d.ts +0 -1
  52. package/dist/test/devices/sensors.test.js +0 -44
  53. package/dist/test/devices/sensors.test.js.map +0 -1
  54. package/dist/test/devices/thermostat.test.d.ts +0 -1
  55. package/dist/test/devices/thermostat.test.js +0 -64
  56. package/dist/test/devices/thermostat.test.js.map +0 -1
  57. package/dist/test/module.test.d.ts +0 -1
  58. package/dist/test/module.test.js +0 -88
  59. package/dist/test/module.test.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.2](https://github.com/mezaugusto/matterbridge-iotas/compare/v1.0.1...v1.0.2) (2026-04-12)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * :bug: dimmable lights not showing ([#6](https://github.com/mezaugusto/matterbridge-iotas/issues/6)) ([d15f5a7](https://github.com/mezaugusto/matterbridge-iotas/commit/d15f5a7cf67fac017d75d9a623dc6c4c68423775))
9
+
10
+ ## [1.0.2](https://github.com/mezaugusto/matterbridge-iotas/compare/v1.0.1...v1.0.2) (2026-04-12)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * :bug: dimmable lights not showing ([#6](https://github.com/mezaugusto/matterbridge-iotas/issues/6)) ([d15f5a7](https://github.com/mezaugusto/matterbridge-iotas/commit/d15f5a7cf67fac017d75d9a623dc6c4c68423775))
16
+
3
17
  ## [1.0.1](https://github.com/mezaugusto/matterbridge-iotas/compare/v1.0.0...v1.0.1) (2026-04-12)
4
18
 
5
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-iotas",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Matterbridge plugin for IOTAS smart home devices",
5
5
  "author": "Augusto Meza <mezaugusto@proton.me>",
6
6
  "license": "Apache-2.0",
@@ -1,35 +0,0 @@
1
- /**
2
- * Constants for IOTAS device categories, event types, and feature categories.
3
- * Provides both runtime values and compile-time safety.
4
- */
5
- /** IOTAS device categories that map to Matter device types. */
6
- export declare const DeviceCategory: {
7
- readonly Dimmer: "dimmer";
8
- readonly Switch: "switch";
9
- readonly MotionSwitch: "motion_switch";
10
- readonly Lock: "lock";
11
- readonly Thermostat: "thermostat";
12
- readonly Door: "door";
13
- };
14
- export type DeviceCategory = (typeof DeviceCategory)[keyof typeof DeviceCategory];
15
- /** Runtime type guard for validating device categories from external payloads. */
16
- export declare function isDeviceCategory(value: string): value is DeviceCategory;
17
- /** IOTAS event type names used to locate features by their event type. */
18
- export declare const EventType: {
19
- readonly OnOff: "OnOff";
20
- readonly Level: "Level";
21
- };
22
- export type EventTypeName = (typeof EventType)[keyof typeof EventType];
23
- /** IOTAS feature type categories used to locate features by their category. */
24
- export declare const FeatureType: {
25
- readonly Lock: "lock";
26
- readonly Battery: "battery";
27
- readonly CurrentTemperature: "current_temperature";
28
- readonly ThermostatMode: "thermostat_mode";
29
- readonly HeatSetPoint: "heat_set_point";
30
- readonly CoolSetPoint: "cool_set_point";
31
- readonly Humidity: "humidity";
32
- readonly Motion: "motion";
33
- readonly DoorState: "door_state";
34
- };
35
- export type FeatureCategory = (typeof FeatureType)[keyof typeof FeatureType];
@@ -1,36 +0,0 @@
1
- /**
2
- * Constants for IOTAS device categories, event types, and feature categories.
3
- * Provides both runtime values and compile-time safety.
4
- */
5
- /** IOTAS device categories that map to Matter device types. */
6
- export const DeviceCategory = {
7
- Dimmer: 'dimmer',
8
- Switch: 'switch',
9
- MotionSwitch: 'motion_switch',
10
- Lock: 'lock',
11
- Thermostat: 'thermostat',
12
- Door: 'door',
13
- };
14
- const deviceCategoryValues = new Set(Object.values(DeviceCategory));
15
- /** Runtime type guard for validating device categories from external payloads. */
16
- export function isDeviceCategory(value) {
17
- return deviceCategoryValues.has(value);
18
- }
19
- /** IOTAS event type names used to locate features by their event type. */
20
- export const EventType = {
21
- OnOff: 'OnOff',
22
- Level: 'Level',
23
- };
24
- /** IOTAS feature type categories used to locate features by their category. */
25
- export const FeatureType = {
26
- Lock: 'lock',
27
- Battery: 'battery',
28
- CurrentTemperature: 'current_temperature',
29
- ThermostatMode: 'thermostat_mode',
30
- HeatSetPoint: 'heat_set_point',
31
- CoolSetPoint: 'cool_set_point',
32
- Humidity: 'humidity',
33
- Motion: 'motion',
34
- DoorState: 'door_state',
35
- };
36
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,eAAe;IAC7B,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;CACJ,CAAC;AAGX,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;AAE5E,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CACN,CAAC;AAGX,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,kBAAkB,EAAE,qBAAqB;IACzC,cAAc,EAAE,iBAAiB;IACjC,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,gBAAgB;IAC9B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,YAAY;CACf,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Device Factory - Router that maps IOTAS device categories to factory functions.
3
- *
4
- * Individual device factories live in src/devices/.
5
- * This module provides createEndpointForDevice (the router) and re-exports everything.
6
- */
7
- import type { Device } from 'iotas-ts';
8
- import type { DeviceFactoryContext, EndpointResult } from './devices/types.js';
9
- import { createDimmableLight, createOnOffLight } from './devices/lights.js';
10
- import { createOnOffOutlet } from './devices/outlet.js';
11
- import { createDoorLock } from './devices/lock.js';
12
- import { createThermostat } from './devices/thermostat.js';
13
- import { createHumiditySensor, createOccupancySensor, createContactSensor } from './devices/sensors.js';
14
- export type { DeviceFactoryContext, EndpointResult } from './devices/index.js';
15
- export { createDimmableLight, createOnOffLight, createOnOffOutlet, createDoorLock, createThermostat, createHumiditySensor, createOccupancySensor, createContactSensor, };
16
- /**
17
- * Main factory function - creates appropriate endpoint based on device category.
18
- */
19
- export declare function createEndpointForDevice(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
@@ -1,66 +0,0 @@
1
- /**
2
- * Device Factory - Router that maps IOTAS device categories to factory functions.
3
- *
4
- * Individual device factories live in src/devices/.
5
- * This module provides createEndpointForDevice (the router) and re-exports everything.
6
- */
7
- import { DeviceCategory, EventType, FeatureType, isDeviceCategory } from './constants.js';
8
- import { createDimmableLight, createOnOffLight } from './devices/lights.js';
9
- import { createOnOffOutlet } from './devices/outlet.js';
10
- import { createDoorLock } from './devices/lock.js';
11
- import { createThermostat } from './devices/thermostat.js';
12
- import { createHumiditySensor, createOccupancySensor, createContactSensor } from './devices/sensors.js';
13
- export { createDimmableLight, createOnOffLight, createOnOffOutlet, createDoorLock, createThermostat, createHumiditySensor, createOccupancySensor, createContactSensor, };
14
- function handleSwitch(device, ctx) {
15
- const isLight = device.features.some((f) => f.isLight);
16
- return isLight ? createOnOffLight(device, ctx) : createOnOffOutlet(device, ctx);
17
- }
18
- function handleDimmer(device, ctx) {
19
- const hasLevel = device.features.some((f) => f.eventTypeName === EventType.Level);
20
- if (hasLevel) {
21
- return createDimmableLight(device, ctx);
22
- }
23
- return handleSwitch(device, ctx);
24
- }
25
- const categoryHandlers = new Map([
26
- [DeviceCategory.Dimmer, handleDimmer],
27
- [DeviceCategory.Switch, handleSwitch],
28
- [DeviceCategory.MotionSwitch, handleSwitch],
29
- [DeviceCategory.Lock, createDoorLock],
30
- [DeviceCategory.Thermostat, createThermostat],
31
- [DeviceCategory.Door, createContactSensor],
32
- ]);
33
- /**
34
- * Feature-based fallbacks for unknown categories.
35
- *
36
- * Precedence is defined by array order (first match wins):
37
- * 1) humidity
38
- * 2) motion
39
- */
40
- const featureFallbacks = [
41
- { category: FeatureType.Humidity, handler: createHumiditySensor },
42
- { category: FeatureType.Motion, handler: createOccupancySensor },
43
- ];
44
- /**
45
- * Main factory function - creates appropriate endpoint based on device category.
46
- */
47
- export function createEndpointForDevice(device, ctx) {
48
- if (!device.paired) {
49
- ctx.log.debug(`Skipping unpaired device: ${device.name}`);
50
- return null;
51
- }
52
- if (isDeviceCategory(device.category)) {
53
- const handler = categoryHandlers.get(device.category);
54
- if (handler) {
55
- return handler(device, ctx);
56
- }
57
- }
58
- for (const { category, handler: fallbackHandler } of featureFallbacks) {
59
- if (device.features.some((f) => f.featureTypeCategory === category)) {
60
- return fallbackHandler(device, ctx);
61
- }
62
- }
63
- ctx.log.warn(`Unsupported device category: ${device.category} for device ${device.name}`);
64
- return null;
65
- }
66
- //# sourceMappingURL=deviceFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devi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I,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,KAAK,QAAQ,CAAC,EAAE,CAAC;YACpE,OAAO,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,MAAM,CAAC,QAAQ,eAAe,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1F,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Shared helpers for device factories.
3
- */
4
- import { bridgedNode, MatterbridgeEndpoint } from 'matterbridge';
5
- import type { DeviceTypeDefinition } from 'matterbridge';
6
- import type { Device } from 'iotas-ts';
7
- import type { EventTypeName, FeatureCategory } from '../constants.js';
8
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
9
- export { bridgedNode };
10
- export declare function makeDeviceId(device: Device): string;
11
- export declare function getSerialNumber(device: Device): string;
12
- export declare function getManufacturerInfo(device: Device): {
13
- manufacturer: string;
14
- model: string;
15
- };
16
- export declare function findFeature(device: Device, category: FeatureCategory): import("iotas-ts").Feature | undefined;
17
- export declare function findFeatureByEventType(device: Device, eventTypeName: EventTypeName): import("iotas-ts").Feature | undefined;
18
- /** Find a feature by category or return null with a warning log. */
19
- export declare function requireFeature(device: Device, category: FeatureCategory, ctx: DeviceFactoryContext, label: string): import("iotas-ts").Feature | null;
20
- /** Find a feature by event type or return null with a warning log. */
21
- export declare function requireFeatureByEventType(device: Device, eventTypeName: EventTypeName, ctx: DeviceFactoryContext, label: string): import("iotas-ts").Feature | null;
22
- /**
23
- * Create a MatterbridgeEndpoint pre-configured with identify + bridged device basic info.
24
- */
25
- export declare function createBridgedEndpoint(deviceTypes: [DeviceTypeDefinition, ...DeviceTypeDefinition[]], device: Device, ctx: DeviceFactoryContext): MatterbridgeEndpoint;
26
- /** Convert IOTAS level (0..1) to Matter level (0..254). */
27
- export declare function toMatterLevel(iotasLevel: number): number;
28
- /** Convert Matter level (0..254) to IOTAS level (0..1). */
29
- export declare function fromMatterLevel(matterLevel: number): number;
30
- /** Convert IOTAS humidity (0..1) to Matter centipercent (0..10000). */
31
- export declare function toMatterHumidity(iotasHumidity: number): number;
32
- /** Convert Fahrenheit to degrees Celsius. */
33
- export declare function toCelsius(fahrenheit: number): number;
34
- /** Convert Fahrenheit to Matter centidegrees Celsius (raw attribute value, 1/100 °C). */
35
- export declare function toMatterCentiCelsius(fahrenheit: number): number;
36
- /** Convert Matter centidegrees Celsius back to Fahrenheit. */
37
- export declare function fromMatterCentiCelsius(centiCelsius: number): number;
38
- /**
39
- * Add standard on/off command handlers to an endpoint.
40
- */
41
- export declare function addOnOffHandlers(endpoint: MatterbridgeEndpoint, featureId: number, ctx: DeviceFactoryContext): void;
42
- /**
43
- * Build an EndpointResult for a device that tracks multiple IOTAS features.
44
- * Feature IDs are derived from the map keys; updateAttribute dispatches via lookup.
45
- */
46
- export declare function multiFeatureResult(endpoint: MatterbridgeEndpoint, handlers: Map<number, (value: number) => void>): EndpointResult;
47
- export declare function singleFeatureResult(endpoint: MatterbridgeEndpoint, featureId: number, onUpdate: (value: number) => void): EndpointResult;
48
- /**
49
- * Create a simple on/off device (light or outlet) — shared logic for
50
- * createOnOffLight and createOnOffOutlet.
51
- */
52
- export declare function createSimpleOnOffDevice(deviceType: DeviceTypeDefinition, device: Device, ctx: DeviceFactoryContext, label: string): EndpointResult | null;
@@ -1,135 +0,0 @@
1
- /**
2
- * Shared helpers for device factories.
3
- */
4
- import { bridgedNode, MatterbridgeEndpoint } from 'matterbridge';
5
- import { OnOff } from 'matterbridge/matter/clusters';
6
- import { Temperature } from 'iotas-ts';
7
- import { EventType } from '../constants.js';
8
- import { VENDOR_ID } from './types.js';
9
- export { bridgedNode };
10
- export function makeDeviceId(device) {
11
- return `iotas-${device.id}`;
12
- }
13
- export function getSerialNumber(device) {
14
- if (device.serialNumber && device.serialNumber.length > 1) {
15
- return device.serialNumber;
16
- }
17
- return `IOTAS-${device.id}`;
18
- }
19
- export function getManufacturerInfo(device) {
20
- return {
21
- manufacturer: device.physicalDeviceDescription?.manufacturer ?? 'IOTAS',
22
- model: device.physicalDeviceDescription?.model ?? device.category,
23
- };
24
- }
25
- export function findFeature(device, category) {
26
- return device.features.find((f) => f.featureTypeCategory === category);
27
- }
28
- export function findFeatureByEventType(device, eventTypeName) {
29
- return device.features.find((f) => f.eventTypeName === eventTypeName);
30
- }
31
- /** Find a feature by category or return null with a warning log. */
32
- export function requireFeature(device, category, ctx, label) {
33
- const feature = findFeature(device, category);
34
- if (!feature) {
35
- ctx.log.warn(`Device ${device.name} missing ${category} feature for ${label}`);
36
- }
37
- return feature ?? null;
38
- }
39
- /** Find a feature by event type or return null with a warning log. */
40
- export function requireFeatureByEventType(device, eventTypeName, ctx, label) {
41
- const feature = findFeatureByEventType(device, eventTypeName);
42
- if (!feature) {
43
- ctx.log.warn(`Device ${device.name} missing ${eventTypeName} feature for ${label}`);
44
- }
45
- return feature ?? null;
46
- }
47
- /**
48
- * Create a MatterbridgeEndpoint pre-configured with identify + bridged device basic info.
49
- */
50
- export function createBridgedEndpoint(deviceTypes, device, ctx) {
51
- const { manufacturer, model } = getManufacturerInfo(device);
52
- return new MatterbridgeEndpoint(deviceTypes, { id: makeDeviceId(device) }, ctx.debug)
53
- .createDefaultIdentifyClusterServer()
54
- .createDefaultBridgedDeviceBasicInformationClusterServer(device.name, getSerialNumber(device), VENDOR_ID, manufacturer, model);
55
- }
56
- /** Convert IOTAS level (0..1) to Matter level (0..254). */
57
- export function toMatterLevel(iotasLevel) {
58
- return Math.round(iotasLevel * 254);
59
- }
60
- /** Convert Matter level (0..254) to IOTAS level (0..1). */
61
- export function fromMatterLevel(matterLevel) {
62
- return matterLevel / 254;
63
- }
64
- /** Convert IOTAS humidity (0..1) to Matter centipercent (0..10000). */
65
- export function toMatterHumidity(iotasHumidity) {
66
- return Math.round(iotasHumidity * 10000);
67
- }
68
- /** Convert Fahrenheit to degrees Celsius. */
69
- export function toCelsius(fahrenheit) {
70
- return Temperature.toCelsius(fahrenheit);
71
- }
72
- /** Convert Fahrenheit to Matter centidegrees Celsius (raw attribute value, 1/100 °C). */
73
- export function toMatterCentiCelsius(fahrenheit) {
74
- return Math.round(Temperature.toCelsius(fahrenheit) * 100);
75
- }
76
- /** Convert Matter centidegrees Celsius back to Fahrenheit. */
77
- export function fromMatterCentiCelsius(centiCelsius) {
78
- return Temperature.toFahrenheit(centiCelsius / 100);
79
- }
80
- /**
81
- * Add standard on/off command handlers to an endpoint.
82
- */
83
- export function addOnOffHandlers(endpoint, featureId, ctx) {
84
- endpoint.addCommandHandler('on', () => {
85
- ctx.onFeatureUpdate(featureId, 1);
86
- endpoint.setAttribute(OnOff.Cluster.id, 'onOff', true);
87
- });
88
- endpoint.addCommandHandler('off', () => {
89
- ctx.onFeatureUpdate(featureId, 0);
90
- endpoint.setAttribute(OnOff.Cluster.id, 'onOff', false);
91
- });
92
- }
93
- /**
94
- * Build an EndpointResult for a device that tracks multiple IOTAS features.
95
- * Feature IDs are derived from the map keys; updateAttribute dispatches via lookup.
96
- */
97
- export function multiFeatureResult(endpoint, handlers) {
98
- return {
99
- endpoint,
100
- featureIds: [...handlers.keys()],
101
- updateAttribute(featureId, value) {
102
- handlers.get(featureId)?.(value);
103
- },
104
- };
105
- }
106
- export function singleFeatureResult(endpoint, featureId, onUpdate) {
107
- return {
108
- endpoint,
109
- featureIds: [featureId],
110
- updateAttribute(fid, value) {
111
- if (fid === featureId) {
112
- onUpdate(value);
113
- }
114
- },
115
- };
116
- }
117
- /**
118
- * Create a simple on/off device (light or outlet) — shared logic for
119
- * createOnOffLight and createOnOffOutlet.
120
- */
121
- export function createSimpleOnOffDevice(deviceType, device, ctx, label) {
122
- const onOffFeature = requireFeatureByEventType(device, EventType.OnOff, ctx, label);
123
- if (!onOffFeature) {
124
- return null;
125
- }
126
- const isOn = (onOffFeature.value ?? 0) === 1;
127
- const endpoint = createBridgedEndpoint([deviceType, bridgedNode], device, ctx)
128
- .createDefaultOnOffClusterServer(isOn)
129
- .addRequiredClusterServers();
130
- addOnOffHandlers(endpoint, onOffFeature.id, ctx);
131
- return singleFeatureResult(endpoint, onOffFeature.id, (value) => {
132
- endpoint.setAttribute(OnOff.Cluster.id, 'onOff', value === 1);
133
- });
134
- }
135
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/devices/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,SAAS,MAAM,CAAC,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,MAAM,CAAC,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,yBAAyB,EAAE,YAAY,IAAI,OAAO;QACvE,KAAK,EAAE,MAAM,CAAC,yBAAyB,EAAE,KAAK,IAAI,MAAM,CAAC,QAAQ;KAClE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,QAAyB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CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC;SAC3E,+BAA+B,CAAC,IAAI,CAAC;SACrC,yBAAyB,EAAE,CAAC;IAE/B,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9D,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +0,0 @@
1
- export type { DeviceFactoryContext, EndpointResult } from './types.js';
2
- export { createDimmableLight, createOnOffLight } from './lights.js';
3
- export { createOnOffOutlet } from './outlet.js';
4
- export { createDoorLock } from './lock.js';
5
- export { createThermostat } from './thermostat.js';
6
- export { createHumiditySensor, createOccupancySensor, createContactSensor } from './sensors.js';
@@ -1,6 +0,0 @@
1
- export { createDimmableLight, createOnOffLight } from './lights.js';
2
- export { createOnOffOutlet } from './outlet.js';
3
- export { createDoorLock } from './lock.js';
4
- export { createThermostat } from './thermostat.js';
5
- export { createHumiditySensor, createOccupancySensor, createContactSensor } from './sensors.js';
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/devices/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Device } from 'iotas-ts';
2
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
3
- export declare function createDimmableLight(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
4
- export declare function createOnOffLight(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
@@ -1,35 +0,0 @@
1
- import { dimmableLight, onOffLight } from 'matterbridge';
2
- import { LevelControl, OnOff } from 'matterbridge/matter/clusters';
3
- import { addOnOffHandlers, bridgedNode, createBridgedEndpoint, createSimpleOnOffDevice, fromMatterLevel, multiFeatureResult, requireFeatureByEventType, toMatterLevel, } from './helpers.js';
4
- import { EventType } from '../constants.js';
5
- export function createDimmableLight(device, ctx) {
6
- const onOffFeature = requireFeatureByEventType(device, EventType.OnOff, ctx, 'dimmable light');
7
- const levelFeature = requireFeatureByEventType(device, EventType.Level, ctx, 'dimmable light');
8
- if (!onOffFeature || !levelFeature) {
9
- return null;
10
- }
11
- const isOn = (onOffFeature.value ?? 0) === 1;
12
- const level = toMatterLevel(levelFeature.value ?? 0);
13
- const endpoint = createBridgedEndpoint([dimmableLight, bridgedNode], device, ctx)
14
- .createDefaultOnOffClusterServer(isOn)
15
- .createDefaultLevelControlClusterServer(level)
16
- .addRequiredClusterServers();
17
- addOnOffHandlers(endpoint, onOffFeature.id, ctx);
18
- endpoint.addCommandHandler('moveToLevel', ({ request }) => {
19
- const matterLevel = request.level;
20
- const iotasLevel = fromMatterLevel(matterLevel);
21
- ctx.onFeatureUpdate(levelFeature.id, iotasLevel);
22
- endpoint.setAttribute(LevelControl.Cluster.id, 'currentLevel', matterLevel);
23
- });
24
- return multiFeatureResult(endpoint, new Map([
25
- [onOffFeature.id, (value) => endpoint.setAttribute(OnOff.Cluster.id, 'onOff', value === 1)],
26
- [
27
- levelFeature.id,
28
- (value) => endpoint.setAttribute(LevelControl.Cluster.id, 'currentLevel', toMatterLevel(value)),
29
- ],
30
- ]));
31
- }
32
- export function createOnOffLight(device, ctx) {
33
- return createSimpleOnOffDevice(onOffLight, device, ctx, 'light');
34
- }
35
- //# sourceMappingURL=lights.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lights.js","sourceRoot":"","sources":["../../../src/devices/lights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,GAAyB;IAC3E,MAAM,YAAY,GAAG,yBAAyB,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC/F,MAAM,YAAY,GAAG,yBAAyB,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAE/F,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC;SAC9E,+BAA+B,CAAC,IAAI,CAAC;SACrC,sCAAsC,CAAC,KAAK,CAAC;SAC7C,yBAAyB,EAAE,CAAC;IAE/B,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAEjD,QAAQ,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACxD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QAClC,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;QAChD,GAAG,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACjD,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,OAAO,kBAAkB,CACvB,QAAQ,EACR,IAAI,GAAG,CAAC;QACN,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC;QAC3F;YACE,YAAY,CAAC,EAAE;YACf,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;SAChG;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,GAAyB;IACxE,OAAO,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Device } from 'iotas-ts';
2
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
3
- export declare function createDoorLock(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
@@ -1,44 +0,0 @@
1
- import { doorLockDevice } from 'matterbridge';
2
- import { DoorLock, PowerSource } from 'matterbridge/matter/clusters';
3
- import { bridgedNode, createBridgedEndpoint, findFeature, multiFeatureResult, requireFeature } from './helpers.js';
4
- import { FeatureType } from '../constants.js';
5
- export function createDoorLock(device, ctx) {
6
- const lockFeature = requireFeature(device, FeatureType.Lock, ctx, 'door lock');
7
- if (!lockFeature) {
8
- return null;
9
- }
10
- const isLocked = (lockFeature.value ?? 0) === 1;
11
- const lockState = isLocked ? DoorLock.LockState.Locked : DoorLock.LockState.Unlocked;
12
- const endpoint = createBridgedEndpoint([doorLockDevice, bridgedNode], device, ctx)
13
- .createDefaultDoorLockClusterServer(lockState)
14
- .addRequiredClusterServers();
15
- endpoint.addCommandHandler('lockDoor', () => {
16
- ctx.onFeatureUpdate(lockFeature.id, 1);
17
- endpoint.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked);
18
- });
19
- endpoint.addCommandHandler('unlockDoor', () => {
20
- ctx.onFeatureUpdate(lockFeature.id, 0);
21
- endpoint.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Unlocked);
22
- });
23
- const handlers = new Map([
24
- [
25
- lockFeature.id,
26
- (value) => {
27
- endpoint.setAttribute(DoorLock.Cluster.id, 'lockState', value === 1 ? DoorLock.LockState.Locked : DoorLock.LockState.Unlocked);
28
- },
29
- ],
30
- ]);
31
- const batteryFeature = findFeature(device, FeatureType.Battery);
32
- if (batteryFeature) {
33
- const batteryPercent = Math.min(Math.round(batteryFeature.value ?? 0), 100);
34
- const matterPercent = batteryPercent * 2; // Matter uses 0-200 (0.5% steps)
35
- endpoint.createDefaultPowerSourceReplaceableBatteryClusterServer(matterPercent, batteryPercent < 20 ? PowerSource.BatChargeLevel.Critical : PowerSource.BatChargeLevel.Ok, batteryPercent * 30, 'CR123A', 1, PowerSource.BatReplaceability.UserReplaceable);
36
- handlers.set(batteryFeature.id, (value) => {
37
- const percent = Math.min(Math.round(value), 100);
38
- endpoint.setAttribute(PowerSource.Cluster.id, 'batPercentRemaining', percent * 2);
39
- endpoint.setAttribute(PowerSource.Cluster.id, 'batChargeLevel', percent < 20 ? PowerSource.BatChargeLevel.Critical : PowerSource.BatChargeLevel.Ok);
40
- });
41
- }
42
- return multiFeatureResult(endpoint, handlers);
43
- }
44
- //# sourceMappingURL=lock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../src/devices/lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAKrE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,GAAyB;IACtE,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAE/E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC;IAErF,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC;SAC/E,kCAAkC,CAAC,SAAS,CAAC;SAC7C,yBAAyB,EAAE,CAAC;IAE/B,QAAQ,CAAC,iBAAiB,CAAC,UAAU,E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,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,EACzF,cAAc,GAAG,EAAE,EACnB,QAAQ,EACR,CAAC,EACD,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAC9C,CAAC;QACF,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YACjD,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;YAClF,QAAQ,CAAC,YAAY,CACnB,WAAW,CAAC,OAAO,CAAC,EAAE,EACtB,gBAAgB,EAChB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CACnF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Device } from 'iotas-ts';
2
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
3
- export declare function createOnOffOutlet(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
@@ -1,6 +0,0 @@
1
- import { onOffOutlet } from 'matterbridge';
2
- import { createSimpleOnOffDevice } from './helpers.js';
3
- export function createOnOffOutlet(device, ctx) {
4
- return createSimpleOnOffDevice(onOffOutlet, device, ctx, 'outlet');
5
- }
6
- //# sourceMappingURL=outlet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outlet.js","sourceRoot":"","sources":["../../../src/devices/outlet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,GAAyB;IACzE,OAAO,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { Device } from 'iotas-ts';
2
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
3
- export declare function createHumiditySensor(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
4
- export declare function createOccupancySensor(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
5
- export declare function createContactSensor(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;
@@ -1,44 +0,0 @@
1
- import { contactSensor, humiditySensor, occupancySensor } from 'matterbridge';
2
- import { BooleanState, OccupancySensing, RelativeHumidityMeasurement } from 'matterbridge/matter/clusters';
3
- import { bridgedNode, createBridgedEndpoint, requireFeature, singleFeatureResult, toMatterHumidity, } from './helpers.js';
4
- import { FeatureType } from '../constants.js';
5
- export function createHumiditySensor(device, ctx) {
6
- const humidityFeature = requireFeature(device, FeatureType.Humidity, ctx, 'humidity sensor');
7
- if (!humidityFeature) {
8
- return null;
9
- }
10
- const humidity = toMatterHumidity(humidityFeature.value ?? 0);
11
- const endpoint = createBridgedEndpoint([humiditySensor, bridgedNode], device, ctx)
12
- .createDefaultRelativeHumidityMeasurementClusterServer(humidity)
13
- .addRequiredClusterServers();
14
- return singleFeatureResult(endpoint, humidityFeature.id, (value) => {
15
- endpoint.setAttribute(RelativeHumidityMeasurement.Cluster.id, 'measuredValue', toMatterHumidity(value));
16
- });
17
- }
18
- export function createOccupancySensor(device, ctx) {
19
- const motionFeature = requireFeature(device, FeatureType.Motion, ctx, 'occupancy sensor');
20
- if (!motionFeature) {
21
- return null;
22
- }
23
- const occupied = (motionFeature.value ?? 0) === 1;
24
- const endpoint = createBridgedEndpoint([occupancySensor, bridgedNode], device, ctx)
25
- .createDefaultOccupancySensingClusterServer(occupied)
26
- .addRequiredClusterServers();
27
- return singleFeatureResult(endpoint, motionFeature.id, (value) => {
28
- endpoint.setAttribute(OccupancySensing.Cluster.id, 'occupancy', { occupied: value === 1 });
29
- });
30
- }
31
- export function createContactSensor(device, ctx) {
32
- const doorFeature = requireFeature(device, FeatureType.DoorState, ctx, 'contact sensor');
33
- if (!doorFeature) {
34
- return null;
35
- }
36
- const contactState = (doorFeature.value ?? 0) === 1;
37
- const endpoint = createBridgedEndpoint([contactSensor, bridgedNode], device, ctx)
38
- .createDefaultBooleanStateClusterServer(contactState)
39
- .addRequiredClusterServers();
40
- return singleFeatureResult(endpoint, doorFeature.id, (value) => {
41
- endpoint.setAttribute(BooleanState.Cluster.id, 'stateValue', value === 1);
42
- });
43
- }
44
- //# sourceMappingURL=sensors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sensors.js","sourceRoot":"","sources":["../../../src/devices/sensors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAK3G,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,GAAyB;IAC5E,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAE7F,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,eAAe,CAAC,K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MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEzF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC;SAC9E,sCAAsC,CAAC,YAAY,CAAC;SACpD,yBAAyB,EAAE,CAAC;IAE/B,OAAO,mBAAmB,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7D,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,9 +0,0 @@
1
- import { Thermostat } from 'matterbridge/matter/clusters';
2
- import type { Device } from 'iotas-ts';
3
- import type { DeviceFactoryContext, EndpointResult } from './types.js';
4
- /**
5
- * Map IOTAS thermostat mode values to Matter SystemMode.
6
- * IOTAS modes: 0=Off, 1=Heat, 2=Cool, 3=Emergency Heat, 4=Auto
7
- */
8
- export declare function iotasModeToSystemMode(iotasMode: number): Thermostat.SystemMode;
9
- export declare function createThermostat(device: Device, ctx: DeviceFactoryContext): EndpointResult | null;