claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.39k stars 92 forks source link

Add custom parameters to Home Assistant notification #375

Closed MiguelAngelLV closed 9 months ago

MiguelAngelLV commented 10 months ago

Hi!

I am trying use home assistant notification with a Telegram services (yes, I know I can use telegram directly without HA, but with HA service I can configure all from HA without touch anything in Epic Games Free).

The problem is the notification generate invalid markdown code, so, telegram service fail.

The simple solution is add parameters to service and I could add mode=html and all would work fine.

{
      "type": "homeassistant",
      "instance": "https://homeassistant.example.com",
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
      "notifyservice": "mobile_app_smartphone_name",
      "notifydata": {
            "mode": "html"
        }
}
claabs commented 9 months ago

After looking at the Home Assistant docs, I don't quite understand your request. The HTML option isn't an HTML flag in the API; it seems to just be that the API accepts HTML.

Are you requesting that the notification message is formatted as HTML when with "mode": "html"? In that case, wouldn't that still be invalid Markdown for your Telegram service?

MiguelAngelLV commented 9 months ago

My request is pass "any param" to service so it allow use with any Home Assistant notifier, not only mobile notifier.

For example, for Telegram Notifier (https://www.home-assistant.io/integrations/telegram/#extra-data-attributes-support) there are parse_mode and the default value is markdown, but the text sended by epicgames-freegames is not a valid markdown, but, adding parse_mode: "html" the message it will work fine.

This too allow use another's notifiers as discords (https://www.home-assistant.io/integrations/discord/) for example with it own params.

claabs commented 9 months ago

Added the customData option to the Home Assistant config. It takes an object, so you can set

"customData": {
  "parse_mode": "html"
}

in the home assistant notifier config in your config.json. Let me know if that works for you.

MiguelAngelLV commented 9 months ago

I tested and it does not work :(

I think that HA remove custom parameters.

I will send you a PR for "universal" webhook notifier and it should be compatible with HA.

Thanks ;)