Page 1 of 1

iMessage Notification

Posted: Sunday 08 May 2016 7:29
by trixwood
iMessage

TRiXWooD Scripts viewtopic.php?f=23&t=12145&p=87422#p87422

Uses: Mac, OSX, Applescript
Screen Shot 2016-05-08 at 07.36.25.jpg
Screen Shot 2016-05-08 at 07.36.25.jpg (56.88 KiB) Viewed 7787 times
I have domoticz running on OSX and I use this for notification iMessage. I suggest you create a new appleid for your osx domoticz server. Login to it with the message app. Now you can use this account to send imessages (you can use your own account but it nicer not to)

notify.sh

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "[email protected]" "Subject: $1"
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "[email protected]" "$2"
Note that you have to change the path to your install folder. [email protected] is the buddy (not my terminology) or account/telephonenumber you want to send the message to. No idea how to make one message with a return into the message from the command line. But this will due... besides two beeps might be important!
Ofcourse you can always change it into one beep with

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "+31063356235" "Subject: $1 $2"
imessage.scpt

Code: Select all

on run argv
	tell application "Messages" to send (item 2 of argv) to buddy (item 1 of argv)
	tell application "Messages" to send (item 3 of argv) to buddy (item 1 of argv)
end run
Untitled.jpg
Untitled.jpg (52 KiB) Viewed 7789 times
If you are running on a pi and have an osx server next to it you can remote execute the applescripts :-) Anyway now you have imessage notification.

Signed TRiXWooD

Update

Ofcourse this is maybe better:

notify.sh

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "$1" "Subject: $2"
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "$1" "$3"
With: script://notify.sh "[email protected]" "#SUBJECT" "#MESSAGE"

For config sake... rum...

Re: iMessage Notification

Posted: Monday 16 May 2016 5:45
by HoLeeShiet
Nice! Is it possible to include screenshot of IP camera too?

Re: iMessage Notification

Posted: Monday 16 May 2016 22:32
by mvveelen
This is great. I only wish I could run everything on 1 device, my Synology NAS :geek:

Re: iMessage Notification

Posted: Tuesday 17 May 2016 6:16
by Egregius
There is no API explanation available for iMessage, so won't be so easy to implemented on something else.
But, Telegram is a great tool for text, photo and video notifications and is easy to use.
For high priority message I have a PHP function that sends message to my iPhone using the Find my iPhone service. They always make the sound, even when on silent or do not disturb. Ideal for messages like from smoke detectors.

Re: iMessage Notification

Posted: Tuesday 17 May 2016 7:15
by mvveelen
Well, the great advantage of iMessage (for me) is, that you can send a picture from the camera directly to your Apple Watch, so you can see immediately who is standing in front of your door :)

Re: iMessage Notification

Posted: Tuesday 17 May 2016 21:45
by robpow
Very cool!

I had to add 'of service...' to the iMessage command though to make it work:

Code: Select all

on run argv
	tell application "Messages" to send (item 2 of argv) to buddy (item 1 of argv) of service "E:<my iCloud email>"
end run

Re: iMessage Notification

Posted: Tuesday 17 May 2016 22:45
by robpow
Here are my scripts to send a snapshot from a Foscam IP camera to my phone and watch:

iMessage.sh

Code: Select all

#!/bin/bash
wget  http://192.168.0.101:8080/camsnapshot.jpg?idx=2 -O /tmp/cam.jpg
osascript ~/iMessage.scpt +990011223344 "Subject: Door open" "/tmp/cam.jpg"
iMessage.scpt

Code: Select all

on run argv
	set theAttachment to POSIX file (item 3 of argv)
	tell application "Messages" to send (item 2 of argv) to buddy (item 1 of argv) of service "E:<iCloud address>"
	tell application "Messages" to send file theAttachment to buddy (item 1 of argv) of service "E:<iCloud address>"
end run

Re: iMessage Notification

Posted: Tuesday 17 May 2016 22:47
by Flopp
Hide your number

Re: iMessage Notification

Posted: Tuesday 17 May 2016 22:53
by robpow
I wish I had that as a number... don't even think it's a valid phone number. :)

iMessage Notification

Posted: Tuesday 17 May 2016 23:04
by Flopp
robpow wrote:I wish I had that as a number... don't even think it's a valid phone number. :)
:)
I will test that script soon, looks REALLY nice

Re: iMessage Notification

Posted: Tuesday 11 July 2017 7:52
by elizzabeth01
trixwood wrote:iMessage

TRiXWooD Scripts viewtopic.php?f=23&t=12145&p=87422#p87422

Uses: Mac, OSX, Applescript

Screen Shot 2016-05-08 at 07.36.25.jpg

I have domoticz running on OSX and I use this for notification iMessage. I suggest you create a new appleid for your osx domoticz server. Login to it with the message app. Now you can use this account to send imessages (you can use your own account but it nicer not to)

notify.sh

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "[email protected]" "Subject: $1"
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "[email protected]" "$2"
Note that you have to change the path to your install folder. [email protected] is the buddy (not my terminology) or account/telephonenumber you want to send the message to. No idea how to make one message with a return into the message from the command line. But this will due... besides two beeps might be important!
Ofcourse you can always change it into one beep with

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "+31063356235" "Subject: $1 $2"
imessage.scpt

Code: Select all

on run argv
	tell application "Messages" to send (item 2 of argv) to buddy (item 1 of argv)
	tell application "Messages" to send (item 3 of argv) to buddy (item 1 of argv)
end run

Untitled.jpg

If you are running on a pi and have an osx server next to it you can remote execute the applescripts :-) Anyway now you have imessage notification.

Signed TRiXWooD

Update

Ofcourse this is maybe better:

notify.sh

Code: Select all

#!/bin/bash
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "$1" "Subject: $2"
osascript ~/Smarthome/domoticz/scripts/imessage.scpt "$1" "$3"
With: script://notify.sh "[email protected]" "#SUBJECT" "#MESSAGE"

For config sake... rum...
Just today i know we can also run and send imessage from our own server we just have to tweak our server with thsese scripts so let me tell you that we can also run imessage on our pc runing windows check it out on bloomtimes. Hope you like it and thank you very mch for this guide.

Re: iMessage Notification

Posted: Tuesday 10 October 2017 10:13
by theolsen
I'm sorry to open an old thread but there is not much conversation around iMessage on this forum.
i am running Domoticz on OSX.

I have created the iMessage.scpt and notify.sh and placed them both in my domoticz/scripts folder.

My imessage.scpt is like this:

Code: Select all

on run argv
        tell application "Messages" to send (item 2 of argv) to buddy (item 1 of argv) of service "[email protected]"
        tell application "Messages" to send (item 3 of argv) to buddy (item 1 of argv) of service "[email protected]"
end run
and notify.sh is like this:

Code: Select all

#!/bin/bash
osascript /Users/dave/domoticz/scripts/imessage.scpt "+44567334567” "Subject: $1 $2"

In the custom message area of notifications on a switch I have this for "On":

Code: Select all

script://notify.sh  "Hello" "World"


Nothing happens when the switch is turned on...Can somebody explain exactly how to get this set up?


Thanks in advance.

Re: iMessage Notification

Posted: Wednesday 11 October 2017 19:13
by theolsen
A moment of clarity and it is now sorted!