Skip to content

Commit

Permalink
feat(sdk): add support for notification channel in NotifierOptions (#…
Browse files Browse the repository at this point in the history
…1625)

* feat(sdk): add support for notification channel in NotifierOptions

This change spins off from conversation at scryptedapp/homeassistant#1 and allows consumers of the `Notifier` interface to specify a channel for notifications to be sent to. Android platforms can use this to send notifications to a specific channel, allowing the user to have fine-grained control over the audio and priority of the notifications they receive.

* chore(sdk): place Android notification channel under the android object

* fix(automation-actions): remove channel from UI
  • Loading branch information
USA-RedDragon authored Oct 27, 2024
1 parent c1046d5 commit 7505e69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/diagnostics/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class DiagnosticsPlugin extends ScryptedDeviceBase implements Settings {
await device.sendNotification('Scrypted Diagnostics', {
body: 'Body',
subtitle: 'Subtitle',
android: {
channel: 'diagnostics',
}
}, mo);

this.warnStep(console, 'Check the device for the notification.');
Expand Down
4 changes: 4 additions & 0 deletions sdk/types/scrypted_python/scrypted_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,13 @@ class MediaStreamOptions(TypedDict):
tool: MediaStreamTool # The tool was used to write the container or will be used to read teh container. Ie, scrypted, the ffmpeg tools, gstreamer.
video: VideoStreamOptions

class AndroidNotificationOptions(TypedDict):
channel: str

class NotifierOptions(TypedDict):

actions: list[NotificationAction]
android: AndroidNotificationOptions
badge: str
body: str
bodyWithSubtitle: str
Expand Down
3 changes: 3 additions & 0 deletions sdk/types/src/types.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export interface NotifierOptions {
badge?: string;
bodyWithSubtitle?: string;
body?: string;
android?: {
channel?: string;
}
data?: any;
dir?: NotificationDirection;
lang?: string;
Expand Down

0 comments on commit 7505e69

Please sign in to comment.