diff --git a/DEVICES.md b/DEVICES.md index 0813ca2..e926826 100644 --- a/DEVICES.md +++ b/DEVICES.md @@ -108,7 +108,8 @@ In [brackets] is given the class name of device. | | TILT_STOP | button.stop.tilt | | boolean | W | E | | | `/^button\.stop\.tilt$/` | | | TILT_OPEN | button.open.tilt | | boolean | W | E | | | `/^button\.open\.tilt$/` | | | TILT_CLOSE | button.close.tilt | | boolean | W | E | | | `/^button\.close\.tilt$/` | -| | DIRECTION | indicator.direction | | | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | indicator.direction | | boolean | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | value.direction | | number | | | | | `/^(indicator|value)\.direction$/` | | | WORKING | indicator.working | | | | | X | | `/^indicator\.working$/` | | | UNREACH | indicator.maintenance.unreach | | boolean | | | X | | `/^indicator(\.maintenance)?\.unreach$/` | | | LOWBAT | indicator.maintenance.lowbat | | boolean | | | X | | `/^indicator(\.maintenance)?\.lowbat$|^indicator(\.maintenance)?\.battery$/` | @@ -130,7 +131,8 @@ In [brackets] is given the class name of device. | | TILT_STOP | button.stop.tilt | | boolean | W | E | | | `/^button\.stop\.tilt$/` | | | TILT_OPEN | button.open.tilt | | boolean | W | E | | | `/^button\.open\.tilt$/` | | | TILT_CLOSE | button.close.tilt | | boolean | W | E | | | `/^button\.close\.tilt$/` | -| | DIRECTION | indicator.direction | | | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | indicator.direction | | boolean | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | value.direction | | number | | | | | `/^(indicator|value)\.direction$/` | | | WORKING | indicator.working | | | | | X | | `/^indicator\.working$/` | | | UNREACH | indicator.maintenance.unreach | | boolean | | | X | | `/^indicator(\.maintenance)?\.unreach$/` | | | LOWBAT | indicator.maintenance.lowbat | | boolean | | | X | | `/^indicator(\.maintenance)?\.lowbat$|^indicator(\.maintenance)?\.battery$/` | @@ -292,7 +294,8 @@ In [brackets] is given the class name of device. | * | SET | switch.gate | | boolean | W | E | | | `/^switch(\.gate)?$/` | | | ACTUAL | value.blind | % | number | | E | | | `/^value(\.position)?|^value(\.gate)?$/` | | | STOP | button.stop | | boolean | W | E | | | `/^button\.stop$|^action\.stop$/` | -| | DIRECTION | indicator.direction | | | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | indicator.direction | | boolean | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | value.direction | | number | | | | | `/^(indicator|value)\.direction$/` | | | WORKING | indicator.working | | | | | X | | `/^indicator\.working$/` | | | UNREACH | indicator.maintenance.unreach | | boolean | | | X | | `/^indicator(\.maintenance)?\.unreach$/` | | | MAINTAIN | indicator.maintenance | | boolean | | | X | | `/^indicator\.maintenance$/` | @@ -435,7 +438,8 @@ In [brackets] is given the class name of device. | * | SET | switch.lock | | boolean | W | | | `/^switch\.lock$/` | | | ACTUAL | state | | boolean | - | | | `/^state$/` | | | OPEN | button | | boolean | W | | | | -| | DIRECTION | indicator.direction | | | | X | | `/^indicator\.direction$/` | +| | DIRECTION | indicator.direction | | boolean | | X | | `/^indicator\.direction$/` | +| | DIRECTION | value.direction | | number | | | | `/^(indicator|value)\.direction$/` | | | WORKING | indicator.working | | | | X | | `/^indicator\.working$/` | | | UNREACH | indicator.maintenance.unreach | | boolean | | X | | `/^indicator(\.maintenance)?\.unreach$/` | | | LOWBAT | indicator.maintenance.lowbat | | boolean | | X | | `/^indicator(\.maintenance)?\.lowbat$|^indicator(\.maintenance)?\.battery$/` | diff --git a/LICENSE b/LICENSE index c9bf15f..c91e65c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2024 Denis Haev +Copyright (c) 2018-2025 Denis Haev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2e5fcd6..23b5f26 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ if (controls) { --> ## Changelog +### **WORK IN PROGRESS** + +- (@GermanBluefox) Added detection of `level.direction` + ### 4.1.1 (2024-12-15) - (@Apollon77) Fixed default unit for Illuminance to "lux" - (@Apollon77) Added Low-Battery state for switch to be consistent with other devices @@ -106,7 +110,7 @@ if (controls) { - (@Garfonso) Added battery state - (@Garfonso) Added the transition time state - (@Garfonso) Allowed the mixed `device->state` and `device->channel->state` structures -- (@GermanBluefox) Used new eslint config library +- (@GermanBluefox) Used a new eslint config library - (@GermanBluefox) Types were slightly changed - (Apollon77) Removed File state type - (Apollon77) Adjusted Camera states to remove Binary state and replace by link @@ -256,6 +260,6 @@ if (controls) { ## License -Copyright (c) 2018-2024 Denis Haev +Copyright (c) 2018-2025 Denis Haev MIT License diff --git a/package-lock.json b/package-lock.json index 61cad90..997edc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@iobroker/types": "^7.0.6", "chai": "^4.5.0", "mocha": "^11.0.1", - "typescript": "~5.7.2" + "typescript": "~5.7.3" } }, "node_modules/@alcalzone/pak": { @@ -5387,9 +5387,9 @@ } }, "node_modules/typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 74b8780..feae170 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@iobroker/eslint-config": "^1.0.0", "chai": "^4.5.0", "mocha": "^11.0.1", - "typescript": "~5.7.2" + "typescript": "~5.7.3" }, "bugs": { "url": "https://github.com/ioBroker/ioBroker.type-detector/issues" diff --git a/src/TypePatterns.ts b/src/TypePatterns.ts index 11829de..f3b8b3c 100644 --- a/src/TypePatterns.ts +++ b/src/TypePatterns.ts @@ -32,6 +32,7 @@ const SharedPatterns: { maintain: InternalDetectorState; error: InternalDetectorState; direction: InternalDetectorState; + direction_enum: InternalDetectorState; reachable: InternalDetectorState; battery: InternalDetectorState; } = { @@ -83,11 +84,21 @@ const SharedPatterns: { direction: { role: /^indicator\.direction$/, indicator: true, + type: StateType.Boolean, notSingle: true, name: 'DIRECTION', required: false, defaultRole: 'indicator.direction', }, + direction_enum: { + role: /^(indicator|value)\.direction$/, // some old adapters implement `indicator.direction` even for number types. So try to detect it too + type: StateType.Number, + notSingle: true, + name: 'DIRECTION', + required: false, + defaultStates: { 0: 'None', 1: 'Up/Open', 2: 'Down/Close', 3: 'Unknown' }, + defaultRole: 'value.direction', + }, reachable: { role: /^indicator\.reachable$/, indicator: true, @@ -1937,6 +1948,7 @@ export const patterns: { [key: string]: InternalPatternControl } = { defaultRole: 'button.close.tilt', }, SharedPatterns.direction, + SharedPatterns.direction_enum, SharedPatterns.working, SharedPatterns.unreach, SharedPatterns.lowbat, @@ -2036,6 +2048,7 @@ export const patterns: { [key: string]: InternalPatternControl } = { defaultRole: 'button.close.tilt', }, SharedPatterns.direction, + SharedPatterns.direction_enum, SharedPatterns.working, SharedPatterns.unreach, SharedPatterns.lowbat, @@ -2080,6 +2093,7 @@ export const patterns: { [key: string]: InternalPatternControl } = { defaultRole: 'button.stop', }, SharedPatterns.direction, + SharedPatterns.direction_enum, SharedPatterns.working, SharedPatterns.unreach, SharedPatterns.maintain, @@ -2296,6 +2310,7 @@ export const patterns: { [key: string]: InternalPatternControl } = { defaultRole: 'button', }, SharedPatterns.direction, + SharedPatterns.direction_enum, SharedPatterns.working, SharedPatterns.unreach, SharedPatterns.lowbat, diff --git a/src/types.ts b/src/types.ts index 74584d2..63b5996 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ /** - * Copyright 2018-2023 bluefox + * Copyright 2018-2025 bluefox * * The MIT License (MIT) * @@ -86,13 +86,13 @@ export interface InternalDetectorState { min?: StateType; // type of attribute: number', 'string' or 'boolean'. This attribute must exist in common max?: StateType; // type of attribute: number', 'string' or 'boolean'. This attribute must exist in common required?: boolean; // if required to detect the pattern as valid - noSubscribe?: boolean; // no automatic subscription for this state (e.g., if write only) - searchInParent?: boolean; // if this pattern should be search in a device too and not only in channel + noSubscribe?: boolean; // no automatic subscription for this state (e.g., if write-only) + searchInParent?: boolean; // if this pattern should be searched in a device too and not only in channel enums?: (obj: ioBroker.Object, enums: string[]) => boolean; // function to execute custom category detection multiple?: boolean; // if more than one state may have this pattern in channel - noDeviceDetection?: boolean; // do not search indicators in parent device + noDeviceDetection?: boolean; // do not search indicators in a parent device notSingle?: boolean; // this state may belong to more than one tile simultaneously (e.g., volume tile and media with volume) - inverted?: boolean; // is state of indicator must be inverted + inverted?: boolean; // if the state of indicator must be inverted stateName?: RegExp; // regex for state names (IDs). Not suggested defaultStates?: { [key: string]: string }; // is for detection irrelevant, but will be used by iobroker.devices. defaultRole?: string; // is for detection irrelevant, but will be used by iobroker.devices - only states WITH defaultRole will show up in UI.