Skip to content

Commit

Permalink
add brighness device type (#70)
Browse files Browse the repository at this point in the history
* add brighness device type

as discussed in #63

I allowed everything ending with `brightness` as role. By looking in the role documentation the only conflicting role *should* be `level.brightness` which *should* be save, because of the `write: false` flag check. Oppinions?

I did so in order to be in line with `humidity` and `temperature` sensor devices which of course is not a hard requirement but nice to have.

Also, if we merge #69, `SharedPatterns.battery` should be added here as well.

* Rename 'brightness' to 'illuminance'

---------

Co-authored-by: Bluefox <[email protected]>
  • Loading branch information
Garfonso and GermanBluefox authored Nov 30, 2024
1 parent ced049b commit 814dc2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions DEVICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ What is not important for detection:
## Devices
In [brackets] is given the class name of device.
### Content
* [Illuminance [Illuminance]](#illuminance)
* [Air conditioner [airCondition]](#air-conditioner-aircondition)
* [Blinds controlled only by buttons [blindButtons]](#blinds-controlled-only-by-buttons-blindbuttons)
* [Blinds or Shutter [blinds]](#blinds-or-shutter-blinds)
Expand Down Expand Up @@ -73,6 +74,16 @@ In [brackets] is given the class name of device.
* [Weather forecast [weatherForecast]](#weather-forecast-weatherforecast)
* [Window [window]](#window-window)
* [Window that could be in tilted state [windowTilt]](#window-that-could-be-in-tilted-state-windowtilt)
### Illuminance
| R | Name | Role | Unit | Type | Wr | Ind | Mult | Regex |
|---|----------|-------------------------------|------|---------|----|-----|------|--------------------------------------------------------------------------------|
| * | ACTUAL | value.brightness | % | number | - | | | ``/brightness$/`` |
| | UNREACH | indicator.maintenance.unreach | | boolean | | X | | ``/^indicator(\.maintenance)?\.unreach$/`` |
| | LOWBAT | indicator.maintenance.lowbat | | boolean | | X | | ``/^indicator(\.maintenance)?\.lowbat$|^indicator(\.maintenance)?\.battery$/`` |
| | MAINTAIN | indicator.maintenance | | boolean | | X | | ``/^indicator\.maintenance$/`` |
| | ERROR | indicator.error | | | | X | | ``/^indicator\.error$/`` |


### Air conditioner [airCondition]
| R | Name | Role | Unit | Type | Wr | Ind | Mult | Regex |
|---|----------------|-------------------------------|------|----------------|----|-----|------|--------------------------------------------|
Expand Down
19 changes: 19 additions & 0 deletions src/TypePatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2897,6 +2897,25 @@ export const patterns: { [key: string]: InternalPatternControl } = {
],
type: Types.humidity,
},
illuminance: {
states: [
{
role: /brightness$/,
indicator: false,
write: false,
type: StateType.Number,
name: 'ACTUAL',
required: true,
defaultRole: 'value.brightness',
defaultUnit: '%',
},
SharedPatterns.unreach,
SharedPatterns.lowbat,
SharedPatterns.maintain,
SharedPatterns.error,
],
type: Types.illuminance,
},
image: {
states: [
{
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum Types {
gate = 'gate',
hue = 'hue',
humidity = 'humidity',
illuminance = 'illuminance',
image = 'image',
info = 'info',
instance = 'instance',
Expand Down

0 comments on commit 814dc2d

Please sign in to comment.