OT - Running AppleScript from a Mail Rule
James Sentman
james at sentman.com
Wed Aug 12 20:06:53 EDT 2020
I have had almost no luck getting Apple mail to run scripts reliably with any of the more recent versions. And beyond that I’m sure that it’s a security issue on the remote machine that is causing it to fail. We need to figure out what the background helper is for Apple Events over the network and make sure that it is listed in the system preferences, Security and Privacy, Automation tab for controlling XTension. I don’t know off the top of my head what that is called nor how you’d find it to drag it into that window and give it permission...
The ignoring application responses block you have it in basically makes it completely immune to reporting any errors. You’ll never get any feedback from the script it will just not work. If this is the way you need to do this then you need to remove that block and let it actually generate an error rather than ignore it and then we can use that error info to try to make some better sense of it all.
So all that being said it might be better to pursue a totally different way of turning on the unit in XTension. I predict that it will be a lot easier to get it working via the JSON/HTML server connection. Have a look at how to control a unit via that here: http://www.machomeautomation.com/doku.php/supported_hardware/json <http://www.machomeautomation.com/doku.php/supported_hardware/json>
So if you create a unit and assign it to the JSON server interface you create you can control it from your applescript something like:
do shell script “curl http://1.2.3.4:2111/yourtoken/theunitadress/on <http://1.2.3.4:2111/yourtoken/theunitadress/on>”
replacing the address, port, token and address with the ones you actually give to the various parts :)
That will not require any further messing around with Apple Event security or anything else and will let you get a very quick connection from the email script (assuming it really does run) and the unit in XTension on the remote machine.
> On Aug 12, 2020, at 1:49 PM, Sean Lavigne <sean at houselavigne.us> wrote:
>
> I’m having trouble triggering an AppleScript from within an Apple Mail rule.
>
> I’ve recently moved XTension to a new (old) dedicated Mac. When XTension and Apple Mail were on the same Mac, I had a Mail rule that would run an AppleScript letting XTension know when a tornado warning email was received. I generally get these emails about a minute or two before the weather radios sound off. These worked great when Apple Mail and XTension were on the same Mac.
>
> Now, Apple Mail is on a Catalina Mac and XTension is on a Mojave Mac. I’ve edited my AppleScript to reach the remote machine:
>
> ignoring application responses
> tell application "XTension" of machine "eppc://username:password...@192.168.1.6 <eppc://username:password...@192.168.1.6>"
> turnon "v Warning - Tornado Warning"
> end tell
> end ignoring
>
> The script runs fine when I run it in AppleScript, but never seems to get triggered from Apple Mail. I’ve written the rule to look for a specific sender and “Severe Thunderstorm Warning” in the message content. When I run the rule on such an email the AppleScript does not trigger.
>
> If I edit the rule to include an additional action, like forwarding the email to another of my inboxes, that part of the rule does work, so it’s just that the AppleScript action isn’t running or is being suppressed for seem reason.
>
> Any ideas what could be going on?
>
Thanks,
James
James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200812/8e044384/attachment.html>
More information about the XTensionList
mailing list