New Plugin: Announcements [ALPHA]

Posted on
Wed Jun 21, 2017 9:09 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

New Plugin: Announcements [ALPHA]

Announcements Plugin
The purpose of the announcements plugin is to create custom strings for use with audio announcements. It's compatible with Indigo 7 only. For example, you can use it to combine custom text, device states and variable values to create real-time custom announcements for use with your favorite audio interface. This is somewhat of a more advanced plugin to set up but once you get the hang of it, it's not too bad. But if you're not familiar with Indigo substitutions and Python format specifiers, you may want to proceed with caution.

Here is an example to understand what the plugin does. Using an Announcements Device, you create a formatting string that looks something like this:
Code: Select all
%%d:24058256:intro%%. It's <<now, dt:%A>> at <<now, ct:%-I:%M%p>>. The current temperature is <<%%d:1149686816:temp%%, n:0>> degrees.

The plugin then converts this formatting string into something that looks like this:
Code: Select all
Good evening. It's Tuesday at 9:27PM. The current temperature is 42 degrees.

It may look a bit complicated, but it's really pretty simple once you understand what's going on. The plugin supports Indigo substitutions for device states and variable values. That accounts for the bits that look like %%d:24058256:intro%% or %%d:1149686816:temp%%. However, there are instances where a device state is a float (i.e., 42.1) where you would rather have an integer (i.e., 42). That's where the format specifier comes in. By turning this:
Code: Select all
%%d:1149686816:temp%%

into this:
Code: Select all
<<%%d:1149686816:temp%%, n:0>>

42.1 becomes 42 (n:2 would become 42.10, n:10 would become 42.1000000000, and so on).

There are currently three types of format specifiers:
- current time (ct:),
- datetime (dt:) and
- numeric (n:2).

Once the strings are converted, they're saved to Announcement device states that can then be referred to by your audio interface (the plugin is audio interface agnostic.)

If this all sounds a little tough, I've added a simple tool to create the Indigo substitution string, and the format specifiers (datetime, numeric, etc.) are based on standard Python format specifiers (there are examples in the configuration dialog). Once you use the Substitution Generator to create the Indigo Substitution, you can copy and paste it into the announcement string. Lastly, once you've created your announcement string, click the Save button under the text fields to add it to the list of saved announcements. If you exit the configuration dialog without clicking Save, your changes will be lost.
Screen Shot 2017-06-21 at 9.41.02 PM.png
Screen Shot 2017-06-21 at 9.41.02 PM.png (126.37 KiB) Viewed 7210 times

There is a second optional device type called Salutations. This is a "time-aware" device for creating custom Intros and Outros that can be added to announcement strings (for example, the 'Good evening' bit above). You control the messages and the time of day for each message (presently, there are four of them -- morning, afternoon, evening, and night). This device should be pretty self explanatory. Just refer to the custom state of the Salutations device in your Announcements string.
Screen Shot 2017-06-21 at 9.41.15 PM.png
Screen Shot 2017-06-21 at 9.41.15 PM.png (97.44 KiB) Viewed 7210 times

This is an introductory alpha version which means that it may change dramatically in the future so use with caution. To get tips for how to complete various fields you can also hover over a control to get help bubbles with further details. If all that didn't scare you away, you can download the Alpha here:

https://github.com/DaveL17/Announcements

Advanced Users:
The announcement dictionary format:
Code: Select all
{announcements_device_id: {                     # Indigo dev id of the custom device (int)
    announcement_id: {                          # Unique number, can be any int as long as it's unique (int)
        "Announcement": "",                     # Announcements plugin formatting string
         "nextRefresh": "YYYY-MM-DD HH:MM:SS",  # No microseconds
         "Name": "",                            # Announcement name: must be Indigo state name compatible (not start with a number, etc.)
         "Refresh": ""                          # Refresh interval in minutes
        }
    }
}

{1710896037: {
    4526314416: {
        'Announcement': u"I'm good enough, and I'm smart enough, and doggone it; people like me.",
        'nextRefresh': '2017-06-23 07:12:24',
        'Name': u'Stuart Smalley',
        'Refresh': u'10'
        }
    },
 1990702686: {
    4610683824: {
        'Announcement': u'It is <<now, ct:%A>>; <<now, ct:%-H:%M%p>>.',
        'nextRefresh': '2017-06-23 07:12:24',
        'Name': u'Current Datetime',
        'Refresh': u'1'
        },
     4526314416: {
        'Announcement': u"%%d:24058256:intro%%. It's <<%%v:1289138982%%, dt:%A>> at <<now, ct:%-I:%M%p>>. The current temperature is <<%%d:1149686816:temp%%, n:0>> degrees.",
        'nextRefresh': '2017-06-23 07:12:24',
        'Name': u'Current Weather',
        'Refresh': u'1'
        }
    }
}
Attachments
Screen Shot 2017-06-21 at 10.04.28 PM.png
Screen Shot 2017-06-21 at 10.04.28 PM.png (27.96 KiB) Viewed 7210 times
Screen Shot 2017-06-21 at 10.02.52 PM.png
Screen Shot 2017-06-21 at 10.02.52 PM.png (23.82 KiB) Viewed 7210 times
Screen Shot 2017-06-21 at 10.01.10 PM.png
Screen Shot 2017-06-21 at 10.01.10 PM.png (134.96 KiB) Viewed 7210 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Jun 21, 2017 9:13 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

I should add that the plugin saves the announcement format specifiers to a special file that will be created in the current user's home directory in a folder called "Announcements Plugin". It saves needed information in a file called announcements.txt which looks like this:

Code: Select all
{24058256: {}, 1990702686: {4610683824: {'Announcement': u"%%d:24058256:intro%%. It's <<%%v:1289138982%%, dt:%A>> at <<now, ct:%-I:%M%p>>. The current temperature is <<%%d:1149686816:temp%%, n:0>> degrees.", 'nextRefresh': '2017-06-21 22:13:33', 'Name': u'Current Weather', 'Refresh': u'1'}}}


If this file gets deleted or somehow corrupted, your announcements will be lost.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 22, 2017 12:38 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: New Plugin: Announcements [ALPHA]

Blimey, you've been having fun haven't you?!

I guess this will be useful for email/push notifications as well as voice.

Would a refreshNow() action be useful so we can force an announcement to update before utilising it, such as if we're announcing based on deviceStateChanged triggers?


Sent from my iPhone using Tapatalk Pro

Posted on
Thu Jun 22, 2017 5:47 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

howartp wrote:
Blimey, you've been having fun haven't you?!

I guess this will be useful for email/push notifications as well as voice.

Would a refreshNow() action be useful so we can force an announcement to update before utilising it, such as if we're announcing based on deviceStateChanged triggers?


Sent from my iPhone using Tapatalk Pro

That's a very good idea. I'll throw an action item in there. Thanks for the thought!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 22, 2017 5:49 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

I should note that the plugin is compatible with Indigo 7 only. I added a note to the description in the first post.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 22, 2017 8:59 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: New Plugin: Announcements [ALPHA]

Nice plugin! Are you using a template/substitution engine or did you roll your own?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jun 22, 2017 10:02 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

jay (support) wrote:
Nice plugin! Are you using a template/substitution engine or did you roll your own?

Thanks Jay. Kind of a mix, really. I take the Indigo substitutions and run them through self.substitute() which gives me this (for example): <<42.1, n:0>>. Then I run the substitution string through re.sub to parse the value and the formatter (42.1), (n:0). Lastly, I run these two groups through a string format() like this (after grabbing what I need from the formatter): u"{0:{1}f}.format(match1, match2) or 42.

I don't think I need to explain the 42. :wink:

p.s.: No lie: one of my current projects at work has a job code of 101010. I could hardly stand it.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 22, 2017 10:29 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: New Plugin: Announcements [ALPHA]

DaveL17 wrote:
No lie: one of my current projects at work has a job code of 101010. I could hardly stand it.


LOL! I reread those about every 10 years or so. I was extremely lucky to attend the WWDC (can't remember the year, sometime in the late 90's) when he was the keynote speaker. Takeaway: "it's the axial tilt, stupid!"

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jun 22, 2017 10:38 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: New Plugin: Announcements [ALPHA]

I just thought you were getting excited about 101010 cos it was a nice binary number.

Hadn't realised it was 42 till I googled Jay's strange response!


Sent from my iPhone using Tapatalk Pro

Posted on
Thu Jun 22, 2017 10:42 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

Well, it is you know.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Jun 22, 2017 12:21 pm
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: New Plugin: Announcements [ALPHA]

Fantastic plugin, can't wait to try it and didn't even realize this was possible form a plugin-level. I have been thinking about this recently and was going to nag Matt and Jay about it as a feature request. Very, very cool!

Terry

Posted on
Thu Jun 22, 2017 12:40 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

New Plugin: Announcements [ALPHA]

Thanks Terry - please let me know how you get on and if you see anything hinky.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Jun 25, 2017 5:50 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

The Announcements Plugin [ALPHA] has been updated.

Update v0.3.2:
  • Adds Action to update single announcement on demand.
  • Fixed bug in announcement refresh interval.

https://github.com/DaveL17/Announcements

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Sep 12, 2017 5:53 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: New Plugin: Announcements [ALPHA]

The Announcements Plugin [ALPHA] has been updated.

v0.3.3:
  • Moves the Refresh Announcements Action to the devices actions list. (Select Action Group --> Device Actions --> Announcements Controls)
  • Improves time banding for salutation selection.
  • Adds remote plugin debugging.

You can download it here.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Sep 26, 2017 2:05 pm
superholz offline
Posts: 52
Joined: Jun 10, 2015
Location: The Netherlands

Re: New Plugin: Announcements [ALPHA]

Hi, I would like to try your plugin. Unfortunately after installing and while loading the plugin I get an error:

Reloading plugin "Announcements 0.3.3"
Starting plugin "Announcements 0.3.3" (pid 57016)
Announcements Error Error in plugin execution InitializeMain:

Traceback (most recent call last):
File "plugin.py", line 10, in <module>
ImportError: No module named pydevd

Stopping plugin "Announcements 0.3.3" (pid 57016)
Stopped plugin "Announcements 0.3.3"



does it mean I have to install an extra library?

Who is online

Users browsing this forum: No registered users and 1 guest