Notifications via imessage

Hi there,

maybe one of you guys can help me :smiley:
so shortly my setup, im running HA as a VM and have a physical iMAC next to it.
i have installed the Terminal Add-on.
created ssh keys and exchanged them with my mac. so far so good :slight_smile:

on my Mac i have a script called SendMessage.sh which well… sends the message :wink:
#!/bin/sh
recipient="${1}"
message="${*:2}"
cat<<EOF | osascript - “${recipient}” “${message}”
on run {targetBuddyPhone, targetMessage}
tell application “Messages”
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
EOF

when i run in terminal:
ssh -o ‘StrictHostKeyChecking=no’ [email protected] “/Users/your_username/Documents/SendMessage.sh [email protected] ‘Test from Home Assistant’”

i get a notification on my phone, so basically works as expected.

so now i wanted to use it in an notification and basically use “Target” and “Message” Values to be a little more flexible.
so on my HA i created the script “imessage.sh”, made it executeble with following content:
#!bash
ssh -o ‘StrictHostKeyChecking=no’ [email protected] “/Users/your_username/Documents/SendMessage.sh $1 ‘$2’”

i then created a shell command:
shell_command:
imessage: >
bash /config/scripts/imessage.sh {{ target }} “{{ message }}”

i created a long lived access token and stored it in my !secret as
imessage_rest: “Bearer XXXXXXXXXXXXXXXXXXXXX”

and created the notification:
notify:

in the automation then i have:

service: notify.imessage
data:
message: argh
target: [email protected]

When running the notification i unfortunately only get this log:

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:115
Integration: Shell Command (documentation, issues)
First occurred: 10:56:31 (3 occurrences)
Last logged: 11:21:52

Error running command: bash /config/scripts/imessage.sh {{ target }} "{{ message }}", return code: 255

maybe someone with a little deeper knowledge can point me in the wrong direction as i cant seem to figure it out :-/

thanks so much and regards,
Gerry

sorry for posting this way, but i was only allowed to post 2 links (i guess code is also considered a link?)

figured it out, im stupid… SSH permissions…

I am getting the same error code. how did you fix this if you don’t mind my asking?