MQTT Notifications via notify domain

Referring to existing MQTT Notifications, I am wondering why it is not implemented using the notify domain like every other notification platforms? The reason why is it is a pain in the back when I decided to change notification platform.

For example, I have all my notification platform setup as such…

- name: kenobi
  platform: telegram
  api_key: !secret telegram_api_key
  chat_id: !secret telegram_chat_id_kenobi

in my automation, I send notification using notify.kenobi service.

When I decided to change platform, let say to llamalab_automate, I just simply change it in the configuration without changing the name. For example…

- name: kenobi
  platform: llamalab_automate
  api_key: !secret llamalab_automate_api_key
  to: !secret llamalab_automate_to
  device: 'DEVICE_NAME'

But, if I decided to change to MQTT notifications, I cannot do that. I have to edit ALL my automation and scripts that are using notify.kenobi. It makes me wonder why can’t it be as simple as…

- name: kenobi
  platform: mqtt
  topic: zanzito/kenobi/notification/
  qos: 0
  retain: 0

Possible workaround for this is via rest notification but I am not sure how to it works. I tried this but failed.

- name: kenobi
  platform: rest
  resource: http://IP_ADDRESS:8123/api/services/mqtt/publish
  message_param_name: payload
  target_param_name: topic

Can anyone help?

Have you made any progress with utilization of either MQTT or ReST? I would like to get a basic integration to Slack; it provides a WebHook interface to which I can POST JSON; any suggestions?

My request has been fulfilled by this custom notifier by Zanzito; Announcing MQTT/Android bridging app: Zanzito. Beta testers wanted!

This is what worked for me:

notify:
  - platform: rest
    name: mqtt_notify
    resource: 'http://localhost:8123/api/services/mqtt/publish'
    method: POST_JSON
    message_param_name: payload
    data:
      topic: notify/homeassistant
      retain: false
2 Likes

@PeWu

May I know where can I refer to for further information about rest notification? The component page doesn’t help. I am thinking of using similar method to convert TTS or other services such as the custom component media_player.alexa_tts into notify service.

Apart from the rest notification component page, have a look at notification documentation – it explains what the variables mean (title, message, target). You can always read the component’s source code (118 lines of code).

thanks. i have tried this…

notify:
  - name: office
    platform: rest
    resource: 'https:/XXXXXX/api/services/media_player/alexa_tts'
    method: POST_JSON
    data:
      entity_id: 'media_player.office'
    headers: 
      x-ha-access: !secret http_password
      content-type: 'application/json'

and it works!

3 Likes