I’m trying to send a message from HA to Mattermost. I have a shell script, a perl script and a curl command that can do this from the command line.
The perl script or the shell script would be the preferred method. However, I don’t see how to parameterize the message text. For example I would like to execute this command:
./notify.pl “This is a message” “@user”
But all I can ever get to work is:
./notify.pl
The alternative is to use a REST notifier. I’ve tried various variations of this theme:
notify:
platform: rest
name: NotifyMe
method: POST
headers:
Content-Type: application/json
resource: https://mm.example.com/hooks/nceur8
data:{text: “This is a test”, message: “this is a message” }
message_param_name: text
But when I run this notifier, the Mattermost logs indicate that the message body is null.
The curl command that works from the command line looks like this:
curl -i -X POST -H ‘Content-Type: application/json’ -d ‘{“text”: “Hello, this is some text\nThis is more text” }’ https://mm.example.com/hooks/nceur8
I’ve been working on it for my instance as well and it’s fairly simple once we dig into Mattermost’s documentation.
Below is what I’m using it seems to get the job done thus far. I’m sure we’d need to test more to get more robust notifications but at least for now we have text.
Yes, the generated key is just a personal access token. If I understand your question correctly, yes, this creates a service that I can call in an automation to send a message to someone via Mattermost.
Got it. How to you choose which channel to send notification to within HA automation? I have matter showing as notification option to call, but I do not get anything in my Home Assistant channel when triggering a test event.
This is my automation.
alias: Motion Notify test
description: ""
trigger:
- platform: state
entity_id:
- group.motion
to: "on"
condition: []
action:
- service: notify.mattermost
data:
message: test motion
title: test motion2
mode: single
Working on this also. I am assuming the -notify is put into the configuration.yaml. Is the synology_chat just a second chat service which if I am only using mattermost I don’t need it?
I did try my install with notify in confuguration.yaml, and a automation as follows. When the automation runs no errors in HA, but also no errors in Mattermost.
alias: Motion Matter Most
description: ""
trigger:
- type: occupied
platform: device
device_id: 6b8ebb2b5e0e51c4cfdbba7b8b947e69
entity_id: c4d66ef79d80c4305c475140a8b6cf6f
domain: binary_sensor
condition: []
action:
- service: notify.mattermost
data:
message: test motion
title: test motion2
mode: single
notify:
- platform: rest
name: mattermost
resource: https://mattermost.my-own.url/hooks/-----secret key-----
method: POST_JSON
message_param_name: text
guessing i am missing something, just not sure where too look.