NotificationBuilder

NotificationBuilder

Notification builder to create and send openHAB Cloud notifications.

Do NOT use directly, use actions.notificationBuilder instead.

Methods

addActionButton(label, action) → {NotificationBuilder}

Description:
  • Adds an action button to the notification.

    Please note that due to limitations in Android and iOS only three action buttons are supported. Action buttons are obviously not supported by log notifications.

Source:
Parameters:
Name Type Description
label string

the title of the action button

action string

the action using the syntax as described in openHAB Cloud Connector: Action Syntax

Returns:
Type
NotificationBuilder

addUserId(…emailAddress) → {NotificationBuilder}

Description:
  • Adds a user ID, which usually is the mail address of an openHAB Cloud user, to send the notification to.

    If no user ID is specified, a broadcast notification is sent.

Source:
Parameters:
Name Type Attributes Description
emailAddress string <repeatable>
Returns:
Type
NotificationBuilder

hide() → {NotificationBuilder}

Description:
  • Hides notifications with the specified reference ID or the specified tag.

    Reference ID has precedence over tag. If no reference ID or tag is set, an error is thrown when send is called.

Source:
Returns:
Type
NotificationBuilder

logOnly() → {NotificationBuilder}

Description:
  • Sets the type of the notification to log notification.

Source:
Returns:
Type
NotificationBuilder

send() → {string|null}

Description:
  • Sends the notification.

    If no reference ID is set, a random reference ID is generated. In case the openHAB Cloud Connector is not installed, a warning is logged and the notification is not sent.

Source:
Throws:

if hide was called and no reference ID or tag is set

Type
Error
Returns:

the reference ID of the notification or null log notifications and when hiding notifications

Type
string | null

withIcon(icon) → {NotificationBuilder}

Description:
Source:
Parameters:
Name Type Description
icon string
Returns:
Type
NotificationBuilder

withMediaAttachmentUrl(mediaAttachmentUrl) → {NotificationBuilder}

Description:
  • Sets the URL to a media attachment to be displayed with the notification.

    This URL must be reachable by the push notification client and the client needs to support media attachments. Media attachments are not supported by log notifications.

Source:
Parameters:
Name Type Description
mediaAttachmentUrl string

the media attachment URL as described in openHAB Cloud Connector

Returns:
Type
NotificationBuilder

withOnClickAction(action) → {NotificationBuilder}

Description:
  • Sets the action to be executed when the user clicks on the notification.

    The on click action is not supported by log notifications.

Source:
Parameters:
Name Type Description
action string

the action using the syntax as described in openHAB Cloud Connector: Action Syntax

Returns:
Type
NotificationBuilder

withReferenceId(referenceId) → {NotificationBuilder}

Description:
  • Sets the reference ID for the notification.

    The reference ID is a user-supplied identifier, that can be used to update or remove existing notifications with the same reference ID.

Source:
Parameters:
Name Type Description
referenceId string
Returns:
Type
NotificationBuilder

withTag(severity) → {NotificationBuilder}

Description:
  • Sets the tag for the notification.

    The tag is used for grouping notifications when displaying in the app and to hide/remove groups of notifications.

Source:
Parameters:
Name Type Description
severity string
Returns:
Type
NotificationBuilder

withTitle(title) → {NotificationBuilder}

Description:
  • Sets the title for the notification.

Source:
Parameters:
Name Type Description
title string
Returns:
Type
NotificationBuilder