Happy Birthday to me

October 12, 2015 ā€¢ David Holmes

So they've forgotten your birthday again have they?

Let's use SwitchThat One to make sure it doesn't happen next year! We're going to arrange to be woken by your Sonos playing Happy Birthday. You'll need to set up a playlist with your favourite songs, starting with the aforementioned one.

We're going to try this a couple of different ways. The first way we'll use a Google Calendar, and then the second way we'll do the same thing with Interactions.

If you've not done so already, set up a new Google Calendar for One actions, and register its URL with One using the SettingsĀ»Calendar screen. You can find more details in the documentation.

Now for the Interaction, which is as simple as:

devices['my sonos'].volume(25).play_favourite('Happy Birthday') | devices['sonos'].pause

This will set the volume and start playing Happy Birthday, and then at the end of the event pause your player again. Put this in your calendar for next year and set it to repeat yearly.

As an alternative, we'll write it as an Advanced Interaction...

We'll set the 'If this' to trigger at 6am on the 24th September:

Now.format("%m-%d %H:%M") becomes "09-24 06:00"

and then for the 'Then That':

devices['my sonos'].volume(25).play_favourite('Happy Birthday')

To pause the player we'll use another Interaction:

Now.format("%m-%d %H:%M") becomes "09-24 06:30"

and then for the 'Then That' part

devices['my sonos'].pause

If we want to have a well deserved lie in at the weekend, we could refine the 'If this' to be:

(Now.day_of_week < 6 and Now.format("%m-%d %H:%M") becomes "09-24 06:00")


(Now.day_of_week >= 6 and Now.format("%m-%d %H:%M") becomes "09-24 09:30")

day_of_week starts from 1 with Monday, so 6 is Saturday and 7 is Sunday. Hence we set the alarm for 6am on weekdays, and have a well deserved lie in to 9:30 at the weekend!