Sonos

Scripts

tts.py.example

This script creates a rule that will trigger when a StringItem is updated and speak the string as TTS.

greeting.py.example

This script speaks a random greeting every minute on your Sonos speaker system. To use this, you should set up astro.py as described in Mode (Time of Day). It also assumes that you’ve set up an openHAB ContactItems to represent the presence of people to be greeted. Each of the Items should belong to the group G_Presence_Family. Finally, make sure that you add the contents of the configuration.py.example file into your own configuration.py file.

Packages and Modules

playSound

This module provides functions for playing sounds.

community.sonos.playSound.playsound(fileName, ttsPrio=1, **keywords)

Play a sound mp3 file function. First argument is positional and mandatory. Remaining arguments are optionally keyword arguments.

Examples

playsound("Hello.mp3")
playsound("Hello.mp3", PRIO['HIGH'], room='Kitchen', volume=42)
Parameters
  • fileName (str) – Sound file name to play (files need to be put in the folder /conf/sounds/)

  • ttsPrio (str) – (optional) priority as defined by PRIO (defaults to PRIO[‘MODERATE’])

  • **keywordsroom (room to play in defaults to All) and ttsVol (volume)

Returns

True, if sound was sent, else False

Return type

bool

speak

This module provides functions for use with TTS.

community.sonos.speak.tts(ttsSay, ttsPrio=1, **keywords)

Text To Speak function. First argument is positional and mandatory. Remaining arguments are optionally keyword arguments.

Examples

tts("Hello")
tts("Hello", PRIO['HIGH'], ttsRoom='Kitchen', ttsVol=42, ttsLang='en-GB', ttsVoice='Brian')
Parameters
  • ttsSay (str) – text to speak

  • ttsPrio (str) – (optional) priority as defined by PRIO (defaults to PRIO[‘MODERATE’])

  • **keywordsttsRoom (room to speak in), ttsVol (volume), ttsLang (language), ttsVoice (voice), ttsEngine (engine)

Returns

True, if sound was sent, else False

Return type

bool

community.sonos.speak.greeting()

To use this, you should set up astro.py as described here It will take care of updating the item V_TimeOfDay for you. You can customize and/or translate these greetings in your configuration file.