The Home Assistant Side is a lot more particular about how you do things. On my system I am running HASSIO patched up to date.
You will need a few Add-On’s to create and test everything. For me getting part to talk properly to every other part was 4 weeks of banging my head on the wall and learning more about Docker than I ever wanted to in my life.
Add-On’s I used to do this:
Home Assistant Add-on: File editor
Home Assistant Community Add-on: Advanced SSH & Web Terminal
I have protected mode disabled when doing this, so be careful!
1 Create the script file with the file editor.
Create the file in the same directory as your config yaml files. I called mine mm-what.sh where what was the picture file I wanted to send.
#! /bin/bash
curl -i --insecure -X POST --data-urlencode 'payload={"attachments": [ { "fallback": "test", "color": "#ff8000", "text": "Picture below.", "author_name": "Home Assistant Monitor", "author_icon": "https://mattermost.com/wp-contect-uploads/2022/02/icon_WS.png", "text": "http://10.10.10.75:8123/local/tmp/porch.jpg", "title": "Porch Motion Detected!" } ] }' https://mattermost.yoururl.com/hooks/<<< your webhook key >>>>
https://mattermost.yoururl.com/hooks/<<< your webhook key >>>> is the URL you copied from MatterMost. This is a work in progress for a lot of what is being sent right now was put there for testing. Alter to fit your tastes. Still being working on is the sending of the actual picture to MatterMost not just the URL where it is found.
In the file editor create the service name needed to send the MatterMost message. This is done in the configuration.yaml file. My section looks like:
shell_command:
mm_webhook: './mm-porch.sh'
The first two are not relavent to the mm_webhook is the wervice name that the Automation will call. the file that will be called is ./mm-porch.sh which is stored in the same directory as your configure.yaml file.
I did create the automation in the GUI here is the resulting Yaml file:
alias: Porch Activity
description: ""
trigger:
- type: occupied
platform: device
device_id: 6b8ebb2b5e0e51c4cfdbba7b8b947e69
entity_id: af89c381870919e289cafeddb922d96b
domain: binary_sensor
condition: []
action:
- service: camera.snapshot
data:
filename: www/tmp/porch.jpg
enabled: true
target:
entity_id: camera.porch
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: notify.mobile_app_sm_x200
data:
message: Porch Activity
title: Activity At The Front Door
enabled: true
- service: shell_command.mm_webhook
data: {}
mode: single
This file does the following:
- Wait for motion to be detected on the porch.
- Take a snapshot of what caused the motion sensor to trigger and store it in the www/tmp/porch.jpg file. Note you will need to create the tmp directory under your /homeassistant/www directory. NOTE in the file name do not put a leading /.
- Send a test message to my HA app running on my Android phone.
- Send a message to matter most using the service call.