Sonos TTS

Plays a warning message in Dutch once a day on a SONOS play 5 when the batteries of a Roomnode are below a critical level. Voice is in Dutch ( change nl-nl to "en-us" for English Tested on a Raspberry.

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"aa25eafc.55da18","type":"mqtt in","name":"Zolder Batterij vervangen","topic":"Zolder/Batterij","broker":"ba386057.845d3","x":113,"y":242,"z":"ee170d4e.11e8f","wires":[["3865d42b.c79a2c"]]},{"id":"3865d42b.c79a2c","type":"switch","name":"","property":"payload","rules":[{"t":"eq","v":"1"}],"checkall":"true","outputs":1,"x":297,"y":244,"z":"ee170d4e.11e8f","wires":[["4d98e0c1.b2672"]]},{"id":"9efec520.610138","type":"change","action":"replace","property":"payload","from":"","to":"De batterijen van de sensor op de zolder dienen vervangen te worden","reg":false,"name":"Melding Batterijen ","x":645,"y":239,"z":"ee170d4e.11e8f","wires":[["75deeb95.8a2114"]]},{"id":"4d98e0c1.b2672","type":"delay","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"day","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":454,"y":241,"z":"ee170d4e.11e8f","wires":[["9efec520.610138"]]},{"id":"75deeb95.8a2114","type":"function","name":"SONOS Studie Speak Payload","func":"var text = msg.payload;\n\n/*\ninstall sonos Javascript -> https://www.npmjs.org/package/sonos\n\nExpand settings.js with sonos Context :   functionGlobalContext: {wpi: require('wiring-pi'), sonos:require('sonos')}\n\nSome functions (see https://www.npmjs.org/package/sonos)\n\nsonos.getCurrentState(function(err, track) {\nconsole.log(err, track);\n });\nsonos.currentTrack(function(err, track) {\n  console.log(err, track);\n});\nsonos.getMusicLibrary('playlists', {start: 0, total: 25}, function(err, result){\n  console.log([err, result]);\n  });\nsonos.play('caz_audio_01', function(err, playing) {\n  console.log([err, playing]);\n});\n*/\n// See SONOS program , INFO over Sonos voor IP numbers\nvar sonos = new context.global.sonos.Sonos('10.19.0.95');\n\n//Replace all spaces with a _ because Sonos doesn't support spaces\ntext = text.replace(/ /g,'_');\n\n//For supported languages see www.voicerss.org/api/documentation.aspx\n//This url just redirects to voices because of the specific url format for the sonos\nvar url = 'http://i872953.iris.fhict.nl/speech/nl-nl_' + encodeURIComponent(text) + '.mp3';\n\nsonos.play(url, function(err, playing) {\n  console.log([err, playing]);\n});","outputs":1,"x":913,"y":238,"z":"ee170d4e.11e8f","wires":[[]]}]

Flow Info

Created 10 years, 5 months ago
Updated 9 years, 1 month ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • change (x1)
  • delay (x1)
  • function (x1)
  • mqtt in (x1)
  • mqtt-broker (x1)
  • switch (x1)

Tags

  • Sonos
  • TTS
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option