Get Amazon Alexa to play different Flash Briefings

The Alexa mobile app limits you to only one Flash Briefing configuration. However, with the OH Echo Control binding, you can configure multiple briefings. This post not only will detail how to activate multiple configurations of flash briefings, but also how to set them up, and set up rules for multiple schedules.

If you already have the capability to launch a daily briefing using OH, read on. Otherwise, you first should start with the Amazon Echo Control Binding documentation

The first step is to set up flashbriefings.things, flashbriefings.items, and flashbriefings.sitemap using the example in the binding documentation.

First we will create an example flashbriefing things (edit with your account number) assuming we will have three briefings:

Bridge amazonechocontrol:account:xxxxxxxxxx "Amazon Account" @ "Accounts" [discoverSmartHome=3]
{
    Thing flashbriefingprofile flashbriefing1 "Flash Briefing news one" @ "Flash Briefings" 
    Thing flashbriefingprofile flashbriefing2 "Flash Briefing news two" @ "Flash Briefings"
    Thing flashbriefingprofile flashbriefing3 "Flash Briefing news three" @ "Flash Briefings"
}

Next, lets create the flashbriefings items:

Switch FlashBriefing_News_One_Save   "Save (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing1:save"} 
Switch FlashBriefing_News_One_Active "Active" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing1:active"}
String FlashBriefing_News_One_Play   "Play (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing1:playOnDevice"}

Switch FlashBriefing_News_Two_Save   "Save (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing2:save"} 
Switch FlashBriefing_News_Two_Active "Active" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing2:active"}
String FlashBriefing_News_Two_Play   "Play (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing2:playOnDevice"} 

Switch FlashBriefing_News_Three_Save   "Save (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing3:save"} 
Switch FlashBriefing_News_Three_Active "Active" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing3:active"}
String FlashBriefing_News_Three_Play   "Play (Write only)" { channel="amazonechocontrol:flashbriefingprofile:xxxxxxxxxx:flashbriefing3:playOnDevice"} 

The next part is not very clear in the documentation: how to save each flash briefing configuration in OH.

You need to use your Alexa App. In the Alexa App, go to “More”, then “Settings”, then scroll down until you find “News”. Under News, you can configure which broadcasts to include in your flash briefing. Enable the broadcast(s) you prefer. This will be for your first flash briefing configuration.

Then in OH, create a toggle switch using the item called “Switch FlashBriefing_News_One_Save” On your UI/page, toggle the item to ON. Once OH saves your configuration, it will automatically revert back to OFF. Go back to the Alexa App and change the flash briefing to reflect your second configuration, then in OH repeat the same procedure, this time for the second briefing item, “Switch FlashBriefing_News_Two_Save”. Finally, do the Alexa and OH procedures above once more for briefing three.

Now let’s create rules for scheduling the three briefings we just saved to OH.

Before OH can play a flash briefing, it first has to activate the right configuration, and then Alexa needs a little time to queue that up. For this reason, it will take two schedule steps for each of the three briefings.

Step one might look like this:

rule "prep morning briefing"
when
    Time cron "0 55 9 ? * MON,TUE,WED,THU,FRI *"
then   
if(Today.state == "Saturday") return;   
if(Today.state == "Sunday") return;
FlashBriefing_News_One_Active.sendCommand(ON)
logInfo("echoplus.rules", "Activated profile 1 for upcoming morning news at 10:05.")
end

In the above example, we prepare briefing one at 9:55 A.M., Mon-Fri.

Step two might look like this:

rule "get morning briefing"
when
    Time cron "0 5 10 ? * MON,TUE,WED,THU,FRI *"
then
if(Today.state == "Saturday") {
    logInfo("echoplus.rules", "Skipping the news on Saturday")
    return;
    }
if(Today.state == "Sunday") {
    logInfo("echoplus.rules", "Skipping the news on Sunday")
    return;
    }
FlashBriefing_News_One_Play.sendCommand('ECHOSERIALNUMBER')
logInfo("echoplus.rules", "Played the news at 10:05 a.m.")
end

In the above example, we played briefing one at 10:05 A.M., Mon-Fri. Set up rules similarly for briefings two and three based on your needs.

2 Likes