diff --git a/src/common/config/classes.ts b/src/common/config/classes.ts index e12a4c66..a605d172 100644 --- a/src/common/config/classes.ts +++ b/src/common/config/classes.ts @@ -433,6 +433,15 @@ export class HomeassistantConfig extends NotifierConfig { @IsString() notifyservice: string; + /** + * A key-value pair object to additionally pass into the service's `data` object + * @example { "parse_mode": "html" } + * @env HOMEASSISTANT_CUSTOM_DATA (stringified JSON) + */ + @IsObject() + @IsOptional() + customData: Record | undefined; + /** * @ignore */ @@ -1088,6 +1097,7 @@ export class AppConfig { HOMEASSISTANT_INSTANCE, HOMEASSISTANT_LONG_LIVED_ACCESS_TOKEN, HOMEASSISTANT_NOTIFYSERVICE, + HOMEASSISTANT_CUSTOM_DATA, } = process.env; if ( HOMEASSISTANT_INSTANCE && @@ -1098,6 +1108,9 @@ export class AppConfig { homeassistant.instance = HOMEASSISTANT_INSTANCE; homeassistant.token = HOMEASSISTANT_LONG_LIVED_ACCESS_TOKEN; homeassistant.notifyservice = HOMEASSISTANT_NOTIFYSERVICE; + homeassistant.customData = HOMEASSISTANT_CUSTOM_DATA + ? JSON.parse(HOMEASSISTANT_CUSTOM_DATA) + : undefined; if (!this.notifiers) { this.notifiers = []; } diff --git a/src/notifiers/homeassistant.ts b/src/notifiers/homeassistant.ts index 42bbee7c..034c2a33 100644 --- a/src/notifiers/homeassistant.ts +++ b/src/notifiers/homeassistant.ts @@ -25,6 +25,7 @@ export class HomeassistantNotifier extends NotifierService { data: { url, clickAction: url, + ...(this.config.customData ?? {}), }, }, {