UNPKG

domoticz-api-linker

Version:

Domoticz API Javascript Bridge Connector

26 lines (25 loc) 869 B
import { DOMOTICZ_COMMAND_PARAM } from '../enums/DomoticzCommandParam'; class NotificationManager { domoticzApi; constructor(domoticzApi) { this.domoticzApi = domoticzApi; } /** * Send a notification through Domoticz Notification API * @param {string} subject * @param {string} message * @param {notificationType[]} subSystems */ async send(subject, message, subSystems) { const options = { param: DOMOTICZ_COMMAND_PARAM.SEND_NOTIFICATION, subject, body: message }; if ((subSystems != null) && subSystems.length > 0) { options.subsystem = subSystems.reduce((str, item) => str + ((str !== '') ? ';' : '') + item.toString(), ''); } return await this.domoticzApi.command(options); } } export { NotificationManager };