Messages app plugin

Plugins that users have built. NOTE: plugins that were developed for Indigo versions older than 2022.1 will have to be updated to work with Indigo 2022.1 (Python 3 - see this blog post for details). If the plugin listed here is not in the Plugin Store (which will show updated plugins) then you will need to ask on the appropriate thread below if it has been updated and where you get get the update.
gazally
Posts: 27
Joined: Mon Jan 18, 2016 7:13 pm
Location: Bigfoot country

Messages app plugin

Post by gazally »

Here's my first plugin, which lets Indigo send and receive messages with the OS X Messages app. I wrote it because I wanted to make turning the water on and off at our vacation house super simple for my non-techie family members. And I wanted to learn Python and it seemed like a good little project.

The basic idea is that you set up a device to send and receive messages. Received messages can be retrieved from the device state, and there are plugin actions to mark a message as read and to send outgoing messages.

For both instructions and the download, see: https://github.com/gazally/indigo-messages

The plugin relies on an Applescript handler to collect messages and pass them onto Indigo so installation is a tad more complicated than usual, but I've put instructions in the github README for how to do it. It seems likely that Applescript handler support is not very high priority for the Messages development team at Apple because the El Capitan version, the only one I've tried it on, has a couple of bugs. I don't have a solution for either one of them, but they're not hard to work around either. See the end of the README for details.
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Messages app plugin

Post by jay (support) »

Nice, thanks for the contribution!

It occurs to me that if you're running Yosemite or better you probably can send TXT messages as well since continuity would just pass it over to your iPhone (if you have one that is). Hmmmm...
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Messages app plugin

Post by jay (support) »

And, yes, it does seem like the trend at Apple over the past several years is to allow AppleScript to languish. This is no small part of the reasoning why we've moved away from it to Python as our scripting language.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
Bollar
Posts: 528
Joined: Sun Aug 11, 2013 3:14 pm

Re: Messages app plugin

Post by Bollar »

This is awesome!

I have been waiting so long for this.
Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts
jalves
Posts: 783
Joined: Sun Jun 16, 2013 11:35 am

Re: Messages app plugin

Post by jalves »

This looks like it could be very useful. I'm going to have to try it out. Thanks for the development effort!
Running Indigo 2024.2.1 on a 24" iMac M4), OS X 26.0
Jeff
kadluvu
Posts: 6
Joined: Fri Mar 18, 2016 3:24 pm
Location: Portland, OR

Re: Messages app plugin

Post by kadluvu »

My objective will be pretty simple. I get a lot of text messages sent to me via sending an e-mail notification. It works great, but EVERY message has a unique number from ATT (Sending an e-mail to phone [email protected]. I'm hoping this plugin will enable me to send notifications and have them all nested as from my AppleID.

~ Easy setup and now my messages are nested! Very nice.
Seeker
Posts: 441
Joined: Mon Aug 05, 2013 5:08 am

Re: Messages app plugin

Post by Seeker »

Thank you for this plugin. i just installed it and setup a test action and it seems to work great!
gazally
Posts: 27
Joined: Mon Jan 18, 2016 7:13 pm
Location: Bigfoot country

Re: Messages app plugin

Post by gazally »

I just put a ridiculously minor update up, to fix a bug that was leading to duplicate lines in my daily chatlog report. If anyone might find it helpful, here's the script I'm using to get a daily email containing all of Indigo's communications using the Messages plugin. It requires the SQL Logger plugin and I have it on a schedule running just before midnight:

Code: Select all

import sqlite3

def format_lines(rows):
    results = []
    rows = sorted(rows, key=lambda tup:tup[1])
    for r in rows:
        date, time, name, msg, resp, st1, st2 = r
        if st2 == "New":
            results.append("{0} {1}> {2}".format(time, name, msg))
        else:
            results.append("{0} Indigo> {1}".format(time, resp))
    return results

logpath = indigo.server.getInstallFolderPath() + "/Logs"
db = logpath + "/indigo_history.sqlite"
conn = sqlite3.connect(db)
c = conn.cursor()

chatlog = []
for dev in indigo.devices.iter("me.gazally.indigoplugin.Messages"):
    chatlog.extend(c.execute("SELECT date(ts, 'localtime'), time(ts, 'localtime'), name, message, response, responsestatus, status FROM device_history_" + str(dev.id) + " WHERE date(ts, 'localtime')=date('now', 'localtime') AND (status='New' OR responsestatus='Sending')"))

conn.close()
if chatlog:
    indigo.server.sendEmailTo("[email protected]", "Indigo daily chatlog", "\n".join(format_lines(chatlog)))

petematheson
Posts: 847
Joined: Sun Sep 14, 2014 9:51 am
Location: Southampton, UK

Re: Messages app plugin

Post by petematheson »

Nice work on this one! Following for future updates but all seems to be working well so far on El Capitan :D
Seeker
Posts: 441
Joined: Mon Aug 05, 2013 5:08 am

Re: Messages app plugin

Post by Seeker »

Can you explain the 'mark as read' deal? The plugin works great, but the messages don't show up as new.
User avatar
Different Computers
Posts: 2730
Joined: Sat Jan 02, 2016 10:07 am
Location: East Coast
Contact:

Re: Messages app plugin

Post by Different Computers »

Very cool!

FYI Matt, Continuity would only work in the oddest use case for this plugin: when you're at home near your server.

Continuity won't work if you're out of the house, unless you left your phone at home!
Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana, Yamaha RX Receiver.
gazally
Posts: 27
Joined: Mon Jan 18, 2016 7:13 pm
Location: Bigfoot country

Re: Messages app plugin

Post by gazally »

My Indigo installation has its own iCloud account. Maybe Matt's has its own iPhone :P

Seeker, I'm not really sure what your question is. When a message arrives the device state should go to New and stay there until you use the Mark as Read action. If additional messages arrive after the first one, they will wait for you to use Mark as Read before overwriting the first one.

The reason for "Mark as Read" is to make the message device states stick around so that you can use them in actions attached to a trigger without the risk that a new message will arrive and cause the device states to be overwritten before the actions have had a chance to read them. Because if a plugin or device used in one of your actions is busy when a trigger fires, Indigo will queue that action up as work to be done later and possibly do all kinds of other stuff before that action actually happens. This is mostly a concern with my Chatbot plugin, which could potentially be running some time-consuming Python script in response to the last message when the new one arrives.
petematheson
Posts: 847
Joined: Sun Sep 14, 2014 9:51 am
Location: Southampton, UK

Re: Messages app plugin

Post by petematheson »

I'm constantly getting the 'Wait' prompt after a few messages at random times. Once it does it, the rest of the messages just queue up behind until I manually log on and click through all the wait messages. Any ideas how to stop this?
It's not the front window thing as I always click a few windows in front of messages just to be sure.
Seeker
Posts: 441
Joined: Mon Aug 05, 2013 5:08 am

Re: Messages app plugin

Post by Seeker »

gazally wrote: Seeker, I'm not really sure what your question is. When a message arrives the device state should go to New and stay there until you use the Mark as Read action. If additional messages arrive after the first one, they will wait for you to use Mark as Read before overwriting the first one.

The reason for "Mark as Read" is to make the message device states stick around so that you can use them in actions attached to a trigger without the risk that a new message will arrive and cause the device states to be overwritten before the actions have had a chance to read them. Because if a plugin or device used in one of your actions is busy when a trigger fires, Indigo will queue that action up as work to be done later and possibly do all kinds of other stuff before that action actually happens. This is mostly a concern with my Chatbot plugin, which could potentially be running some time-consuming Python script in response to the last message when the new one arrives.
My issue is that the messages sent by the plugin ARRIVE as read. They are never not read.
gazally
Posts: 27
Joined: Mon Jan 18, 2016 7:13 pm
Location: Bigfoot country

Re: Messages app plugin

Post by gazally »

Seeker, are you sure you don't have a Mark as Read action hiding in a trigger somewhere? I notice I omitted a debugLog message in that action, which I'll remedy, but that's the only place in the code where message status gets sent to Read.

Pete, I haven't encountered a Wait prompt. Is it coming from Messages or Indigo?
Post Reply

Return to “User Plugins”