iMessage Plugin  

Developer: Glenn's Plugins     Like this plugin? Show your appreciation!
Category: Notification & Messaging
Github: Github Repo
Assistance: Get help!   
Plugin ID: com.GlennNZ.indigoplugin.iMessage
Latest release: v0.7.27 released on Jan. 25, 2024
Requires: Indigo v2023.2.0 or higher
(Check the Releases tab below for older releases that may have different requirements)
  Download latest release

Indigo iMessage Plugin

What it can do:

  • Parse and send iMessages from within Indigo
  • Send Animated GIFs/pdf files etc from within Indigo
  • Works with Mojave, untested on below versions - but shouldn't be issue
  • Indigo 7.1 and above
  • Beta currently: - Additionally with 0.2.2 Natural Language processing and ability to interface with all or selected Indigo Devices - Uses Wit.Ai NLP - See 0.2.2 for details

For Mojave will need to change System Permissions to access imsg database file

Basics

  • Mojave tested
  • Indigo 7.2
  • Need to be signed into Messages/iMsg on Indigo Mac with ideally separate indigo account
  • Will very likely need to give Indigo and IndigoPluginHost.app and IndigoServer.app Full Disk Access in the Security and Privacy settings

/Library/Application Support/Perceptive Automation/Indigo 7 (or 7.2)

IndigoPluginHost.app

IndigoServer.app

Both located there to drag and drop into Security & Privacy Full Disk Access

(sorry - don't believe any way around this - and probably needed for other plugins)

See here:

https://www.macworld.com/article/3311982/macs/the-difference-between-accessibility-and-full-disk-access.html

Installation

  • Download latest release and enable
  • Go to plugin Config screen to set allowed Buddies...
  • If hard to find out Buddy Handle (sometimes email, sometimes phone) enable Config checkbox 'Show Buddy Handle in Log'. Send indigo Mac and iMsg if all is functioning correctly, the Plugin will highlight for you the correct Buddy Handle to use in the Plugin Config and the send iMessage boxes as required.
  • Any issues turn debug logging on and check 3 checkboxes - should supply useful information (including Buddy Handles as sometimes email sometimes phone numbers.)

Works

  • Connects to iMessage chat.db via sql and parse messages received via regular simple, read-only SQL command
  • At first run will backup the iMsg database to Users/Documents file - just in case... (haven't had any issues)
  • Checks every few seconds - so far no problems in my testing
  • Need to set allowed Buddies in Plugin Config otherwise any received iMsg will be ignored
  • No Indigo devices needed - works solely through triggers and action

Setup Commands Recognised

  • Enables you to recognise any iMsg received from Buddy as something to act on
  • No formatting of message
  • Just simple whole text

Felt best to use Indigo itself for actions with Triggers being the message itself - means very familiar

Create Separate Indigo Triggers for iMsg Plugin for each command want recognised

Via individual Trigger for each iMessage text wish to action on

eg. this an Indigo Trigger

Type of trigger is IMessage Plugin Event, Command Received

Edit the command Received, then standard indigo conditions and actions performed.

Then can create any indigo action passed on the command received, including a iMsg reply to confirm.

eg. One Indigo Action from same Trigger

Example Commands (any text you wish can be a trigger) - All off - Gate Open - Lock House - Alarm on

New from 0.2.4

Add Specific Buddy Command Trigger:

Multiple Buddies can be selected and will only trigger if Buddy selected

Three current Plugin Actions

Send Imsg

  • Allow to send imsg text to any buddy you know
  • Tick box - to send reply to last buddy received message from enabling ongoing conversation
  • Allows variable and device state substitution
  • So can send message:
  • 'Glenn is located %%d:1490780461:address%% and has about %%d:1490780461:homeTimeText%% to travel to get home' & clever indigo will fill in the blanks

Send iMsgFile/iMsgImage

  • sends file/image/animated gif to buddy (again has tickbox for last buddy)
  • Allows sending Animated Gifs via BlueIris or other Security plugin.
  • Just need path to file location,or %%v:112312%% Variable substition and save to path
  • eg. The BlueIris lastAnimGif path variable which is updated by BlueIris plugin when AnimatedGif created.

Send iMsgMessgae and file

  • sends a message with an associated file/image/animated gif to buddy (again has tickbox for last buddy)
  • Allows sending Animated Gifs via BlueIris or other Security plugin.
  • Just need path to file location,or %%v:112312%% Variable substition and save to path
  • eg. The BlueIris lastAnimGif path variable which is updated by BlueIris plugin when AnimatedGif created.

Ask iMsg Question

  • Sends a question to Buddy - waits the timeout period for a positive or negative response
  • If timeout sends a timeout reply
  • If confirmation received - then runs the specified action group
  • Following are valid confirmation replies - anything else will be ignored, OR if matches trigger acted on whilst waiting.

valid = {"yes": True, "y": True, "ye": True, 'yeah':True, 'ok':True, "no": False, "n": False, 'nope':False, 'never':False}

Sorry only english currently - but easy to add as many confirmation 'Oui' 'Non' that anyone needs down the track.

  • Also allows - for specified reply (%%V:112123%%) substitution allowed

Additional

Messages accept indigo substitution for both variables and devices.

  • So can send message: 'Glenn is located %%d:1490780461:address%% and has about %%d:1490780461:homeTimeText%% to travel to get home'
  • with Number referring to FindFriends Device: Indigo will substitute both the address and the travel time in these places.

Beta Functions: From Version 0.2.2

As a mechanism of controlling all indigo devices and requesting information with minimal setup I have turned to a free service wit.ai

The aim of this internet service is to process any text messages you might send and enable the Plugin to reply, recognising what you want to do but also which device to apply this to.

e.g Aiming to bring to life.. the following with minimal setup.

  • Turn off pool Pump.
  • Dim the living room light to 20%
  • Set Living Room light to 100% brightness
  • What is the temperature in Maxs Room?
  • Tell me a joke?
  • What is the temperature of the pool?
  • Can you help with some advice?
  • How hot is the Living Room?
  • What is Glenn's Location?

It also enables speech->text via audioMessage, and a few fun extras perhaps I got carried away with.

Basically Wit.ai - recognises message: intent, currently options: device_action, insult, yes_no_decision, joke, dim_set, temperature, advice & entities such as device_name (which is Indigo Device), plus others such as number/sentiment/on_off etc. This parsed result is sent back to the plugin to action. (very quickly)

So if message is sent 'Please Indigo could you be a dear and turn on the living room light?'

The (Plugin after suitable wit.ai training/samples) should recognise intent: device_action, device_name:'Living Room light', and on_off = on

The plugin parses the reply and then Turns on living room light for example.

Within Wit.ai you can train any sentence structure to the correct intent and result. The aim is for the plugin to probably do this at Wit.ai app creation which is what currently happens, obviously others may speak in a different manner. :roll: and I can add any samples/sentence structures wished.

Consider this beta - BUT if disable wit.ai in PluginConfig - rest of plugin unchanged and none of this is run

Requirements:

Need your own Wit.Ai API Key (free) We each need our own as our devices are named something different So while the NLP logic may be the same the devices referred to will be different.

Setup:

New Plugin Config Settings

  1. Create Wit.AI Api - Log in to, with either github or facebook.

https://wit.ai

2/ Next Go to the already existing App called 'MyFirstApp' - Go to Settings, top Right - Find the 'Server Access Token' and copy this in the PluginConfig

Enable Use Wit.Ai Processing to use this service for processing of Messages received.

Checkbox:

Use all Indigo Devices (important)

  • This will send every indigo device name to Wit.Ai to be recognised as a device down the track.
  • This is fine if you have limited devices and the names make sense.
  • But if like me you have hundreds will names like (U) Computer Room Light, or PiBeacon_Pool Temperature
  • These names make sending a text message 'what is the PBeacon_Pool Temperature' will work but isn't much fun.
  • I have added the ability for WitAI to recognise synomyns for the same device
  • eg. device is PiBeacon_Pool Temperature, other names can be 'Pool Temp', 'Pool Temperature' or even 'Pool'

This is performed via the individual Device Notes: On the first line of the notes (the other lines are ignored) a :

witai|Pool|Pool Temp|Pool Temperature

  • Must start with witai and then Vertical bar Characters seperating names
  • Sorry the character is the | Vertical Bar Character

eg.

  • This will give different names which refer to the same device for all future commands

Coming back to the Checkbox - if this is unchecked only those devices so marked with witai| in device notes will be included.

Okay:

So ideally - give you funny named devices some better names, mark those you want to send, or send all

Then:

  1. Press the Button called 'Generate Wit.Ai App' [once we are dne only need to do this once]

This will send a whole lot of text based data to Wit.ai naming devices, and setting up you wit.ai device which the plugin uses You can access this online at wit.ai if needed but really only for finetuning.

This will take a while as can only send a few devices/samples at once; so will take at least 5 if not 10 minutes to be done. Once finished also takes a while at Wit.Ai end as well - before everything is recognised probably - probably at least 1/2 hou

If any issues or want to resend different devices following some playing - press the delete wit.ai App button and then recreate after a short pause.

Following this - You should be able to 'turn on INDIGODEVICE', 'turn off INDIGODEVICE', 'set INDIGODEVICE brightness to 50%', - 'What is the Temperature of INDIGODEVICE', - 'Tell me a joke' - 'What is IFRIENDEVICE location' - amongst others

I have also added AudioMessage Uploading - which works okay within limits of speech recognition. From within iMSG press and hole down microphone - say command and viola!

Fine Tuning:

  • Probably more to come I suspect.
  • From within Wit.ai - can go to Inbox and validate audio received for training
  • Can also can to device_name and add any extra synomyms for this device you wish - pays to do it in Indigo Notes though/so survices delete and recreate

Other changes:

  • Add send HTTP Image - takes http/web location downloads fine and sends it to buddy.

Changelog:

0.2.4

Changes to PluginConfig - hide the scary wit.ai stuff if not using Allow Wit.ai device to be updated with app - update button Update Images Documentation

0.2.3

Add Specific Buddy Command Received Trigger:

Potential bug fix as will Continue checking triggers even if one is triggered (might be multiple triggers same)

. . . . . . . . . . . . . . . . .

Python Script Control (if needed for full flexibility)

  • Via a Python script you can access the Plugin actions to send and reply to Imsgs.
  • So can via script create question and send via the following standard message.
    imessageID = 'com.GlennNZ.indigoplugin.iMessage'
    imsgPlugin = indigo.server.getPlugin(imessageID)
    imsgPlugin.executeAction('sendQuestion', props={'message':'The question you wish to ask', 'buddyId':'example@email.com', 'lastBuddy':False, 'timeout':600,'confirmedimsg':'All done.','actiongroup':ActionGroupIDtoRunwhenConfirmed})
    return;

Props to send: - message: the question to ask - buddyId: the buddy handle - lastBuddy: just the last buddy msg received from - timeout : timeout in seconds - confirmedimsg: message if confirmation is received - actiongroup: the ID number of the action group to run if confirmed.

Here is an example script that list devices on (via allowed list, and notallowed list), saves this list to a variable and then sends message listing devices on, via the plugin waits for confirmation, before running the confirmation AG to turn off all listed in variable.

on_name = []
on_id = []

def AskQuestionGlenn(question, AGtoRun, replyifsuccess) :

    imessageID = 'com.GlennNZ.indigoplugin.iMessage'
    imsgPlugin = indigo.server.getPlugin(imessageID)
    imsgPlugin.executeAction('sendQuestion', props={'message':question, 'buddyId':'example@.com', 'lastBuddy':False, 'timeout':600,'confirmedimsg':replyifsuccess,'actiongroup':AGtoRun})
    return;

def CheckModulesRunning() :
    acceptable_modules = ["Smart Switch (DSC24)","RGBW LED Bulb (ZW098)","Smart Energy Switch (DSC24-2E)","Dimmer Switch (FGD211)","Smart Energy Illuminator (DSC08101)",                     "Relay Power Switch","Smart Energy Switch (DSC06106)", "Double Relay Switch (FGS221)", "Hue Bulb (Original, Downlight, Spotlight, LightStrip Plus)" ]

    notallowedid = [1049034630, 879903489, 1732408457, 1618015973,1595081762,660021281,1509636685,90390894,1047676499,614856779,1373207126,1332040796,1797065670]

    dev_list = indigo.devices.iter()
    for x in dev_list:
        if hasattr(x, "displayStateValRaw") and x.displayStateValRaw not in ["off", 0] and x.model in acceptable_modules and x.id not in notallowedid :
            on_name.append(x.name)
            on_id.append(x.id)
    return;

CheckModulesRunning();

numberon = len(on_id)

if numberon == 0 :
    indigo.server.log("Checking Running devices - None found on.")

if numberon > 0 :
    indigo.server.log("Checking Running devices - Modules running - iMsg sent")
    Question = "Attention\n I have noticed that you are both away and \nThe following lights/devices are on \n"
    ListModules = " , ".join(on_name)
    idsoff = indigo.variables[1410863016] # "MsgOnDevices"
    indigo.variable.updateValue(idsoff, unicode(on_id))
    Statement = Question + ListModules + "\n Would you like me to turn them off?"
    AskQuestionGlenn(Statement, 95680424, "They have all been turned off");

and for completeness here is the Action Group that is called when above is run

onid = indigo.variables[1410863016] # "MsgOnDevices"

onidstring = onid.value
onidstring = onidstring.replace("[","")
onidstring = onidstring.replace("]","")  # Covert indigo string variable back to list
onidstring = onidstring.replace(" ","")

if len(onidstring) > 1:
    onidlist = onidstring.split(",")
else:
    onidlist = onidstring


if len(onidlist) >= 1 :
    indigo.server.log("iMsg: Turning off All Devices ")
    indigo.server.log(unicode(onidstring))
    for i in range(len(onidlist)):
        indigo.device.turnOff(int(onidlist[i]))
elif len(onidlist) < 1 :
    indigo.server.log("iMsg: No Devices On ")  
Release details
Released on: Jan. 25, 2024
Requires: Indigo v2023.2.0+
Changes in this release

0.7.27

Indigo 2023.2. API 3.4 Only

Let Indigo manage aiohttp dependency and install as needed

Add increase error logging if incorrect buddy handle message fails to go (as per issue https://github.com/Ghawken/iMessagePlugin/issues/14)

0.7.27

Harden up runConcurrentThread with try/except block Stop plugin if sql connection fails Change error messaging

0.7.20

Add requirements for Indigo API 3.4 Library install

0.7.16

Add error checking for missing Library

0.7.15

Dont reload model api call

0.7.14

Allow curly brackets { in reply

0.7.13

With Sonoma apple decided the iMsg database would store the message data in a Apple NSString Archived object. Taking up oodles more room. It appears the plain text is quickly converted and then becomes NULL. Update plugin to decode message.attributedbody using typedstream and decoded contents of NSString formatting.

Release details
Released on: Jan. 17, 2024
Requires: Indigo v2023.2.0+
Changes in this release

0.7.26

Indigo 2023.2. API 3.4 Only

Let Indigo manage aiohttp dependency and install as needed

Add increase error logging if incorrect buddy handle message fails to go (as per issue https://github.com/Ghawken/iMessagePlugin/issues/14)

0.7.20

Add requirements for Indigo API 3.4 Library install

0.7.16

Add error checking for missing Library

0.7.15

Dont reload model api call

0.7.14

Allow curly brackets { in reply

0.7.13

With Sonoma apple decided the iMsg database would store the message data in a Apple NSString Archived object. Taking up oodles more room. It appears the plain text is quickly converted and then becomes NULL. Update plugin to decode message.attributedbody using typedstream and decoded contents of NSString formatting.

Release details
Released on: Nov. 18, 2023
Requires: Indigo v2022.1.0+
Changes in this release

0.7.12

Compatibility fix for Sonoma and likely Ventura.

Apple it is wisdom moved message.text to NULL and instead converted it to a NSString object without a Apple Archived object within the SQL Database. This version checks for > Ventura and decodes the message back to text for processing once again. Working well on Sonoma for me currently.

Also adds: 0.6 - 0.7.12 changes:

Essentially adding support for Chat-GPT, not for device control (although new chatGPT features does make that possible), rather for chat completion, advice, etc.

0.7.10 Move model to gpt-3.5-16k Increase token count to 8000 TODO user selectable both above when time

0.7.9 Model back to gpt-3.5 & remove some while loops trying to track down occasional 'hang' - [Fixed it would seem]

0.7.8 Change model to gpt-4 when rolls out for all.

0.7.7 Update openai library to 0.27.4

0.7.6 Add chatGPT only Buddy - these individuals can only converse with chatGPT. They won't have any trigger or command options If device control enabled will allow device Control, but increasingly not sure this is a great idea for this plugin

0.7.5 Handle and specifically message regarding timeout, ratelimt openai errors

0.7.4 OpenAI reports that the system prompt is largely ignored with user prompt having more 'attention' Because of this duplicate some setup into a new user prompt

0.7.3 Fix for debugextra logging string conversion issue (also in 0.7.2) Better checking for token usage and deletion of prompts before gets to limit

Add 2nd Pluginconfig Personal info: Aim of this is to educate chatGPT as to who the various users/buddies are.

Should be Buddy Handle followed by | and then description written in first person. buddyhandle|I am user Glenn.I am.. |buddyhandle2|I am user Glenns co-worker.

Probably would better be a setup file, as really need to type somewhere else and paste in...

0.7.1

Fix for quotes

New 0.7.0

Add support for ChatGPT 3.5 turbo API usage.(Beta) This can be used to control indigo devices (so marked for control), like wit.ai - however it probably needs a bit of maturing before that works 100%

Currently though the chatbot, chat, information, advice function via chatGPT works very well and enables easy access to chatGPT replies for whatever usage. Like chatGPT warning - accuracy here depends on the subject, but for natural language processing it is great.

Release details
Released on: May 16, 2022
Requires: Indigo v2022.1.0+
Changes in this release

0.6.2

Python 3 Release for Indigo 2022.1 Compatibility fixes for wit.ai (if anyone using!)

Release details
Released on: Nov. 16, 2020
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.4.7

Changelog:

0.4.7 Add compatibility for Big Sur released. Backward compatibility mainatined.

Still needs Full disk access & potentially Matts fix here for error 'Error "Not authorized to send Apple events to Messages"' https://forums.indigodomo.com/viewtopic.php?f=297&t=23619#p189420 - Involves creating a script file targetting Message App, save and then run from within Indigo - OSX should prompt a window 'allow access' click yes, and plugin send messages should now also work, forever more

0.4.6 Returns Variable of AudioFile received as *.caf file

0,4,5

Bug fix didn’t correctly check plugin Config setting save variable

0.4.4

Add AudioPath Variable - Converts messenger CAF file to Mp3 [presume caf file not that much use] - Saves path to converted file in variable [if save variables selected in main PluginConfig]

Add PluginConfig setting to save incoming messages to Indigo Variable - variable named after buddy handle NB: Will save all messages, commands, garbage, etc. whatever received.

Release details
Released on: Feb. 9, 2019
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.4.2

Wit.Ai Processing

Changelog:

Remove update code in time for Indigo 7.3

Fix to make plugin compatible with Mac OSX Sierra and below given change in Apple Datetimes, that occured with High Sierra. (Sierra and below will likely also need permissions given to Library Folder ~/Library/Messages)

Release details
Released on: Jan. 21, 2019
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.4.1

Wit.Ai Processing

Changelog:

Fix to make plugin compatible with Mac OSX Sierra and below given change in Apple Datetimes, that occured with High Sierra. (Sierra and below will likely also need permissions given to Library Folder ~/Library/Messages)

Release details
Released on: Dec. 14, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.4.0

Wit.Ai Processing

Changelog:

0.4.0

Updates to Plugin Config to show current status of requests/Updates/Delete/Generate Correctly shows new App Access_token/App_ID Some bug fixes to deal with app creation errors Rename Wit.Ai App to username+Indigo-iMessage (to allow multiple wit.ai apps for multiple Indigo installs, with one wit.ai access code only) (side-effect - makes development easier!) As Plugin accesses app via Access_code only and not name, new name will only happen with deletion/creation of current app. 0.4.0 - Bug fix for this. Log Current Status in Menu - updates - useful for bug checking Beta: Device_Status intent - can ask "What is the status of {device_name}?" Automatically Updates wit.ai App when new version Plugin Installed

Release details
Released on: Dec. 10, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.3.1

Wit.Ai Processing Optional

Changelog:

  • Add message triggering for text within message

eg. If checkbox enabled for particularly trigger

'who is home' will be triggered anytime - that text is within sentence sent from 'who is home' to 'Indigo please inform me who is home'

Release details
Released on: Dec. 9, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.3.0

Wit.Ai Processing Optional

Changelog:

  • Fixes for wit.ai App creation access tokens
  • Bug fixes
  • Thread Update code so no UI Timeout errors

Natural Language Functions: From Version 0.2.2

As a mechanism of controlling all indigo devices and requesting information with minimal setup I have turned to a free service wit.ai

Release details
Released on: Nov. 15, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

0.2.5

Wit.Ai Processing Optional

Natural Language Functions: From Version 0.2.2

As a mechanism of controlling all indigo devices and requesting information with minimal setup I have turned to a free service wit.ai

The aim of this internet service is to process any text messages you might send and enable the Plugin to reply, recognising what you want to do but also which device to apply this to.

e.g Aiming to bring to life.. the following with minimal setup.

  • Turn off pool Pump.
  • Dim the living room light to 20%
  • Set Living Room light to 100% brightness
  • What is the temperature in Maxs Room?
  • Tell me a joke?
  • What is the temperature of the pool?
  • Can you help with some advice?
  • How hot is the Living Room?
  • What is Glenn's Location?

It also enables speech->text via audioMessage, and a few fun extras perhaps I got carried away with.

Basically Wit.ai - recognises message: intent, currently options: device_action, insult, yes_no_decision, joke, dim_set, temperature, advice & entities such as device_name (which is Indigo Device), plus others such as number/sentiment/on_off etc. This parsed result is sent back to the plugin to action. (very quickly)

So if message is sent 'Please Indigo could you be a dear and turn on the living room light?'

The (Plugin after suitable wit.ai training/samples) should recognise intent: device_action, device_name:'Living Room light', and on_off = on

The plugin parses the reply and then Turns on living room light for example.

Within Wit.ai you can train any sentence structure to the correct intent and result. The aim is for the plugin to probably do this at Wit.ai app creation which is what currently happens, obviously others may speak in a different manner. :roll: and I can add any samples/sentence structures wished.

Consider this beta - BUT if disable wit.ai in PluginConfig - rest of plugin unchanged and none of this is run

Requirements:

Need your own Wit.Ai API Key (free) We each need our own as our devices are named something different So while the NLP logic may be the same the devices referred to will be different.

Setup:

New Plugin Config Settings

  1. Create Wit.AI Api - Log in to, with either github or facebook.

https://wit.ai

2/ Next Go to the already existing App called 'MyFirstApp' - Go to Settings, top Right - Find the 'Server Access Token' and copy this in the PluginConfig

Enable Use Wit.Ai Processing to use this service for processing of Messages received.

Checkbox:

Use all Indigo Devices (important)

  • This will send every indigo device name to Wit.Ai to be recognised as a device down the track.
  • This is fine if you have limited devices and the names make sense.
  • But if like me you have hundreds will names like (U) Computer Room Light, or PiBeacon_Pool Temperature
  • These names make sending a text message 'what is the PBeacon_Pool Temperature' will work but isn't much fun.
  • I have added the ability for WitAI to recognise synomyns for the same device
  • eg. device is PiBeacon_Pool Temperature, other names can be 'Pool Temp', 'Pool Temperature' or even 'Pool'

This is performed via the individual Device Notes: On the first line of the notes (the other lines are ignored) a :

witai|Pool|Pool Temp|Pool Temperature

  • Must start with witai and then Vertical bar Characters seperating names
  • Sorry the character is the | Vertical Bar Character

eg.

  • This will give different names which refer to the same device for all future commands

Coming back to the Checkbox - if this is unchecked only those devices so marked with witai| in device notes will be included.

Okay:

So ideally - give you funny named devices some better names, mark those you want to send, or send all

Then:

  1. Press the Button called 'Generate Wit.Ai App' [once we are dne only need to do this once]

This will send a whole lot of text based data to Wit.ai naming devices, and setting up you wit.ai device which the plugin uses You can access this online at wit.ai if needed but really only for finetuning.

This will take a while as can only send a few devices/samples at once; so will take at least 5 if not 10 minutes to be done. Once finished also takes a while at Wit.Ai end as well - before everything is recognised probably - probably at least 1/2 hour

If any issues or want to resend different devices following some playing - press the delete wit.ai App button and then recreate after a short pause.

Following this - You should be able to 'turn on INDIGODEVICE', 'turn off INDIGODEVICE', 'set INDIGODEVICE brightness to 50%', - 'What is the Temperature of INDIGODEVICE', - 'Tell me a joke' - 'What is IFRIENDEVICE location' - amongst others

I have also added AudioMessage Uploading - which works okay within limits of speech recognition. From within iMSG press and hole down microphone - say command and viola!

Fine Tuning:

  • Probably more to come I suspect.
  • From within Wit.ai - can go to Inbox and validate audio received for training
  • Can also can to device_name and add any extra synomyms for this device you wish - pays to do it in Indigo Notes though/so survices delete and recreate

Other changes:

  • Add send HTTP Image - takes http/web location downloads fine and sends it to buddy.

Changelog:

0.2.5

Bug fix for SpecificBuddy Command Add update code check for first run of new version

0.2.4

Changes to PluginConfig - hide the scary wit.ai stuff if not using Allow Wit.ai device to be updated with app - update button Update Images Documentation

0.2.3

Add Specific Buddy Command Received Trigger:

Potential bug fix as will Continue checking triggers even if one is triggered (might be multiple triggers same)

Release details
Released on: Nov. 12, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.1.4

0.1.4

Bug fix of hidden Buddy List

Release details
Released on: Nov. 7, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.1.3

0.1.3

Add debugexceptions option - to also show exception message if errors Some log changing Add menu item - Log Status - to show plugin status in case of error

0.1.2

Add PluginStore Update Checking (via github) Enable UpdateChecking code Add Catch for Full Disk Access issues with error message directing to RTM :)

Release details
Released on: Nov. 6, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.1.1

Changes 0.1.1

  • Add Action to send msg and File combined (as requested)
  • Auto hide Buddy Handle field if using 'use last buddy'
  • Bug fix for resetting last command - wasn't correctly resetting last command after 120seconds
  • Typo fix

Changes 0.1.0

  • Major change to parsing of received messages - better support for multiple incoming messages from multiple buddies at same time. (Multiples streams of conversation)
  • Correctly ignores duplicate messages
  • Multiple messaging buddies occuring at same time dealt with correctly
  • Confirmation Question replies Y/N etc. can occur after other messages sent, provided within timeout set eg. after question received, can send other iMsg commands, get more information before replying Yes/No equivalent
  • If same message from same buddy sent within 120 seconds also ignored
  • Ignores everything except last message within 5 seconds - if wrong resend quickly and will act on that most recent message
  • As requested Buddies selectable as list following entering into pluginConfig allowed Bud
Release details
Released on: Nov. 5, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.1.0

Changes: - Major change to parsing of received messages - better support for multiple incoming messages from multiple buddies at same time. (Multiples streams of conversation) - Correctly ignores duplicate messages - Multiple messaging buddies occuring at same time dealt with correctly - Confirmation Question replies Y/N etc. can occur after other messages sent, provided within timeout set eg. after question received, can send other iMsg commands, get more information before replying Yes/No equivalent

  • If same message from same buddy sent within 120 seconds also ignored
  • Ignores everything except last message within 5 seconds - if wrong resend quickly and will act on that most recent message
  • As requested Buddies selectable as list following entering into pluginConfig allowed Bud
Release details
Released on: Nov. 1, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.0.6

Changes:

  • Better reporting of errors if Buddy details incorrect or file information incorrect/less red!
  • Add 'Show Buddy Handle in Log' Checkbox in Plugin Config Setting - as below:

  • If any issues working out what is the correct Buddy Handle (can be email or phone number and needs to be exact) Enable 'Show Buddy Handle in Log' and send the Indigo iMessage computer a message. This will highlight in error red in the log the correct Buddy Handle. This should be used for that buddy both in the allowed buddies screen and also when sending any iMessage/Question/File etc.
Release details
Released on: Nov. 1, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

Release 0.0.5

Changes:

Politer error reporting if buddy information or file information is incorrect.

Release details
Released on: Oct. 31, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

What it can do:

  • Parse and send iMessages from within Indigo
  • Send Animated GIFs/pdf files etc from within Indigo
  • Works with Mojave, untested on below versions - but shouldn't be issue
  • Indigo 7.1 and above
  • Beta currently

For Mojave will need to change System Permissions to access imsg database file

Basics

  • Mojave tested
  • Indigo 7.2
  • Need to be signed into Messages/iMsg on Indigo Mac with ideally separate indigo account
  • Will very likely need to give Indigo and IndigoPluginHost.app and IndigoServer.app Full Disk Access in the Security and Privacy settings

(sorry - don't believe any way around this - and probably needed for other plugins)

See here:

https://www.macworld.com/article/3311982/macs/the-difference-between-accessibility-and-full-disk-access.html

Installation

  • Download latest release and enable
  • Go to plugin Config screen to set allowed Buddies...
  • Any issues turn debug logging on and check 3 checkboxes - should supply useful information (including Buddy Handles as sometimes email sometimes phone numbers.)

Works

  • Connects to iMessage chat.db via sql and parse messages received via regular simple, read-only SQL command
  • At first run will backup the iMsg database to Users/Documents file - just in case... (haven't had any issues)
  • Checks every few seconds - so far no problems in my testing
  • Need to set allowed Buddies in Plugin Config otherwise any received iMsg will be ignored
  • No Indigo devices needed - works solely through triggers and action

Setup Commands Recognised

  • Enables you to recognise any iMsg received from Buddy as something to act on
  • No formatting of message
  • Just simple whole text

Felt best to use Indigo itself for actions with Triggers being the message itself - means very familiar

Create Separate Indigo Triggers for iMsg Plugin for each command want recognised

Via individual Trigger for each iMessage text wish to action on

eg. this an Indigo Trigger

Type of trigger is IMessage Plugin Event, Command Received

Edit the command Received, then standard indigo conditions and actions performed.

Then can create any indigo action passed on the command received, including a iMsg reply to confirm.

eg. One Indigo Action from same Trigger

Example Commands (any text you wish can be a trigger) - All off - Gate Open - Lock House - Alarm on

Three current Plugin Actions

Send Imsg

  • Allow to send imsg text to any buddy you know
  • Tick box - to send reply to last buddy received message from enabling ongoing conversation
  • Allows variable and device state substitution
  • So can send message:
  • 'Glenn is located %%d:1490780461:address%% and has about %%d:1490780461:homeTimeText%% to travel to get home' & clever indigo will fill in the blanks

Send iMsgFile

  • sends file/image/animated gif to buddy (again has tickbox for last buddy)
  • Allows sending Animated Gifs via BlueIris or other Security plugin.
  • Just need path to file location,or %%v:112312%% Variable substition and save to path
  • eg. The BlueIris lastAnimGif path variable which is updated by BlueIris plugin when AnimatedGif created.

Ask iMsg Question

  • Sends a question to Buddy - waits the timeout period for a positive or negative response
  • If timeout sends a timeout reply
  • If confirmation received - then runs the specified action group
  • Following are valid confirmation replies - anything else will be ignored, OR if matches trigger acted on whilst waiting.

valid = {"yes": True, "y": True, "ye": True, 'yeah':True, 'ok':True, "no": False, "n": False, 'nope':False, 'never':False}

Sorry only english currently - but easy to add as many confirmation 'Oui' 'Non' that anyone needs down the track.

  • Also allows - for specified reply (%%V:112123%%) substitution allowed

Additional

Messages accept indigo substitution for both variables and devices.

  • So can send message: 'Glenn is located %%d:1490780461:address%% and has about %%d:1490780461:homeTimeText%% to travel to get home'
  • with Number referring to FindFriends Device: Indigo will substitute both the address and the travel time in these places.

Python Script Control (if needed for full flexibility)

  • Via a Python script you can access the Plugin actions to send and reply to Imsgs.
  • So can via script create question and send via the following standard message.
    imessageID = 'com.GlennNZ.indigoplugin.iMessage'
    imsgPlugin = indigo.server.getPlugin(imessageID)
    imsgPlugin.executeAction('sendQuestion', props={'message':'The question you wish to ask', 'buddyId':'example@email.com', 'lastBuddy':False, 'timeout':600,'confirmedimsg':'All done.','actiongroup':ActionGroupIDtoRunwhenConfirmed})
    return;

Props to send: - message: the question to ask - buddyId: the buddy handle - lastBuddy: just the last buddy msg received from - timeout : timeout in seconds - confirmedimsg: message if confirmation is received - actiongroup: the ID number of the action group to run if confirmed.

Here is an example script that list devices on (via allowed list, and notallowed list), saves this list to a variable and then sends message listing devices on, via the plugin waits for confirmation, before running the confirmation AG to turn off all listed in variable.

on_name = []
on_id = []

def AskQuestionGlenn(question, AGtoRun, replyifsuccess) :

    imessageID = 'com.GlennNZ.indigoplugin.iMessage'
    imsgPlugin = indigo.server.getPlugin(imessageID)
    imsgPlugin.executeAction('sendQuestion', props={'message':question, 'buddyId':'example@.com', 'lastBuddy':False, 'timeout':600,'confirmedimsg':replyifsuccess,'actiongroup':AGtoRun})
    return;

def CheckModulesRunning() :
    acceptable_modules = ["Smart Switch (DSC24)","RGBW LED Bulb (ZW098)","Smart Energy Switch (DSC24-2E)","Dimmer Switch (FGD211)","Smart Energy Illuminator (DSC08101)",                     "Relay Power Switch","Smart Energy Switch (DSC06106)", "Double Relay Switch (FGS221)", "Hue Bulb (Original, Downlight, Spotlight, LightStrip Plus)" ]

    notallowedid = [1049034630, 879903489, 1732408457, 1618015973,1595081762,660021281,1509636685,90390894,1047676499,614856779,1373207126,1332040796,1797065670]

    dev_list = indigo.devices.iter()
    for x in dev_list:
        if hasattr(x, "displayStateValRaw") and x.displayStateValRaw not in ["off", 0] and x.model in acceptable_modules and x.id not in notallowedid :
            on_name.append(x.name)
            on_id.append(x.id)
    return;

CheckModulesRunning();

numberon = len(on_id)

if numberon == 0 :
    indigo.server.log("Checking Running devices - None found on.")

if numberon > 0 :
    indigo.server.log("Checking Running devices - Modules running - iMsg sent")
    Question = "Attention\n I have noticed that you are both away and \nThe following lights/devices are on \n"
    ListModules = " , ".join(on_name)
    idsoff = indigo.variables[1410863016] # "MsgOnDevices"
    indigo.variable.updateValue(idsoff, unicode(on_id))
    Statement = Question + ListModules + "\n Would you like me to turn them off?"
    AskQuestionGlenn(Statement, 95680424, "They have all been turned off");

and for completeness here is the Action Group that is called when above is run

onid = indigo.variables[1410863016] # "MsgOnDevices"

onidstring = onid.value
onidstring = onidstring.replace("[","")
onidstring = onidstring.replace("]","")  # Covert indigo string variable back to list
onidstring = onidstring.replace(" ","")

if len(onidstring) > 1:
    onidlist = onidstring.split(",")
else:
    onidlist = onidstring


if len(onidlist) >= 1 :
    indigo.server.log("iMsg: Turning off All Devices ")
    indigo.server.log(unicode(onidstring))
    for i in range(len(onidlist)):
        indigo.device.turnOff(int(onidlist[i]))
elif len(onidlist) < 1 :
    indigo.server.log("iMsg: No Devices On ")  
Release details
Released on: Oct. 29, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin 0.0.2

Action added - ask imsg Question.

Select - BuddyHandle or last Buddy Message/Question to Send Timeout for reply in seconds Action Group to run if confirmed Confirmation Message to send if confirmed/when AG run

Only one question, per buddy at a time [can have multiple buddy questions though]

If no confirmation from Buddy other messages will continue to be parsed.

eg.

Can ask question "Shall I turn all lights off?" Timeout for 5 minutes Buddy - can send other commands - Gate etc. which are run If No/Yes/Y/N/Nope/Yeah/ye send (anycase) will terminate that current Question for that Buddy

Release details
Released on: Oct. 28, 2018
Requires: Indigo v7.0.2 thru v2022.2
Changes in this release

Indigo iMessage Plugin

0.0.1 Beta

Parse and send iMsg Works with Mojave Beta currently Will need to change System Permissions to access imsg database file

Basics:

Mojave tested Indigo 7.2 Signed into iMsg with ideally separate indigo account Will very likely need to give Indigo and IndigoPluginHost.app and IndigoServer.app Full Disk Access in the Security and Privacy settings (sorry - don't believe any way around this)

So far

Connects to chat.db via sql and parse messages received Checks every few seconds - so far no problems in my testing Need to set allowed Buddies in Plugin Config No devices needed.

Setup Commands Recognised

Enables you to recognise any iMsg received from Buddy as something to act on No formatting of message Just simple whole text recognisation Felt best to use Indigo itself for actions with Triggers

Create Separate Triggers for iMsg Plugin for each command want recognised

Edit the Command Received Then can create any indigo action passed on the command recevied. eg. All off Gate Open Lock House Alarm on

Two current actions

Send Imsg and send iMsgFile

Allow to send imsg text to any buddy you know Tick box - to send reply to last buddy received message from enabling ongoing discussion Allows variable and device state substitution

send iMsgFile - sends file/image/animated gif to buddy (again has tickbox for last buddy)

todo

  • Have some logic triggers Yes / No and returns a condition response - enabling you to ask questions 'Do you want the Gate opened?' etc and waits for affirmative before triggering. Still thinking this through