Skip to content

Commit

Permalink
implemented push updates for relative rotary (see #416)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 committed Aug 29, 2023
1 parent 932a322 commit 5fbdce8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ In den Adapter-Settings muss die IP der Hue Bridge sowie ein Username konfigurie

### __WORK IN PROGRESS__
* (foxriver76) fixed problem on auto-deletion of groups
* (foxriver76) implemented Hue Tap Dial (closes #368)
* (foxriver76) implemented Hue Tap Dial (closes #368, closes #416)

### 3.9.6 (2023-08-16)
* (foxriver76) do not set invalid states on unknown group updates
Expand Down
8 changes: 6 additions & 2 deletions build/main.js

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

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type ZigbeeConnectivityStatus = 'connected' | 'connectivity_issue';
type StreamingStatus = 'active' | 'inactive';
type ScenceStatus = { active: 'static' | 'inactive' };
type ButtonEventType = 'short_release' | 'initial_press' | 'repeat' | 'long_release';
type RelativeRotaryAction = 'start' | 'repeat';
type RelativeRotaryDirection = 'clock_wise' | 'counter_clock_wise';

interface BridgeUpdate {
dimming?: { brightness: number };
Expand All @@ -53,7 +55,8 @@ interface BridgeUpdate {
| 'device_power'
| 'entertainment_configuration'
| 'scene'
| 'button';
| 'button'
| 'relative_rotary';
/** if type is motion */
motion?: { motion: boolean; motion_report: { changed: string; motion: boolean }; motion_valid: boolean };
/** if type entertainment_configuration */
Expand Down Expand Up @@ -82,6 +85,18 @@ interface BridgeUpdate {
button_report?: { event: ButtonEventType; updated: string };
last_event: ButtonEventType;
};
/** For type relative_rotary */
relative_rotary?: {
last_event: {
action: RelativeRotaryAction;
rotation: { direction: RelativeRotaryDirection; duration: number; steps: number };
};
rotary_report: {
action: RelativeRotaryAction;
rotation: { direction: RelativeRotaryDirection; duration: number; steps: number };
updated: string;
};
};
}

/** IDs currently blocked from polling */
Expand Down Expand Up @@ -1125,7 +1140,9 @@ class Hue extends utils.Adapter {
return;
}

if (['motion', 'temperature', 'light_level', 'device_power', 'button'].includes(update.type)) {
if (
['motion', 'temperature', 'light_level', 'device_power', 'button', 'relative_rotary'].includes(update.type)
) {
this.handleSensorUpdate(id, update);
return;
}
Expand Down Expand Up @@ -1176,6 +1193,15 @@ class Hue extends utils.Adapter {
true
);
}

if (update.relative_rotary?.rotary_report) {
this.setState(`${channelName}.lastupdated`, update.relative_rotary.rotary_report.updated, true);
this.setState(
`${channelName}.rotaryevent`,
update.relative_rotary.rotary_report.action === 'start' ? 1 : 2,
true
);
}
}

/**
Expand Down

0 comments on commit 5fbdce8

Please sign in to comment.