Skip to content

Commit

Permalink
Added detection of level.direction
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 13, 2025
1 parent 0ecb865 commit 6a9217f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 17 deletions.
12 changes: 8 additions & 4 deletions DEVICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | level.direction | | number | | | | | `/^(indicator|level)\.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$/` |
Expand All @@ -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 | level.direction | | number | | | | | `/^(indicator|level)\.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$/` |
Expand Down Expand Up @@ -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 | level.direction | | number | | | | | `/^(indicator|level)\.direction$/` |
| | WORKING | indicator.working | | | | | X | | `/^indicator\.working$/` |
| | UNREACH | indicator.maintenance.unreach | | boolean | | | X | | `/^indicator(\.maintenance)?\.unreach$/` |
| | MAINTAIN | indicator.maintenance | | boolean | | | X | | `/^indicator\.maintenance$/` |
Expand Down Expand Up @@ -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 | level.direction | | number | | | | `/^(indicator|level)\.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$/` |
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2024 Denis Haev <[email protected]>
Copyright (c) 2018-2025 Denis Haev <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -256,6 +260,6 @@ if (controls) {

## License

Copyright (c) 2018-2024 Denis Haev <[email protected]>
Copyright (c) 2018-2025 Denis Haev <[email protected]>

MIT License
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions src/TypePatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SharedPatterns: {
maintain: InternalDetectorState;
error: InternalDetectorState;
direction: InternalDetectorState;
direction_enum: InternalDetectorState;
reachable: InternalDetectorState;
battery: InternalDetectorState;
} = {
Expand Down Expand Up @@ -83,11 +84,20 @@ const SharedPatterns: {
direction: {
role: /^indicator\.direction$/,
indicator: true,
type: StateType.Boolean,
notSingle: true,
name: 'DIRECTION',
required: false,
defaultRole: 'indicator.direction',
},
direction_enum: {
role: /^(indicator|level)\.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,
defaultRole: 'level.direction',
},
reachable: {
role: /^indicator\.reachable$/,
indicator: true,
Expand Down Expand Up @@ -1937,6 +1947,7 @@ export const patterns: { [key: string]: InternalPatternControl } = {
defaultRole: 'button.close.tilt',
},
SharedPatterns.direction,
SharedPatterns.direction_enum,
SharedPatterns.working,
SharedPatterns.unreach,
SharedPatterns.lowbat,
Expand Down Expand Up @@ -2036,6 +2047,7 @@ export const patterns: { [key: string]: InternalPatternControl } = {
defaultRole: 'button.close.tilt',
},
SharedPatterns.direction,
SharedPatterns.direction_enum,
SharedPatterns.working,
SharedPatterns.unreach,
SharedPatterns.lowbat,
Expand Down Expand Up @@ -2080,6 +2092,7 @@ export const patterns: { [key: string]: InternalPatternControl } = {
defaultRole: 'button.stop',
},
SharedPatterns.direction,
SharedPatterns.direction_enum,
SharedPatterns.working,
SharedPatterns.unreach,
SharedPatterns.maintain,
Expand Down Expand Up @@ -2296,6 +2309,7 @@ export const patterns: { [key: string]: InternalPatternControl } = {
defaultRole: 'button',
},
SharedPatterns.direction,
SharedPatterns.direction_enum,
SharedPatterns.working,
SharedPatterns.unreach,
SharedPatterns.lowbat,
Expand Down
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018-2023 bluefox <[email protected]>
* Copyright 2018-2025 bluefox <[email protected]>
*
* The MIT License (MIT)
*
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6a9217f

Please sign in to comment.