For demo purposes and to be able to check if the messages are coming from the IoT cloud without looking at the screen all the time I created super simple Node-RED flow that receives messages from IBM’s IoT cloud and log them in the debug tab of the Node-RED UI and in parallel it parses JSON format of the messages to obtain value of the „temp“ property which is then passed to OS X say command.
It can be easily modified to pick another property value just by modifying „JSON and parse“ node.
You can import the flow using „Import -> From Clipboard“ menu item of Node-RED and by pasting the following text and modify your broker details:
[{"id":"7649d216.89b62c","type":"mqtt-broker","broker":"kbrhh.messaging.internetofthings.ibmcloud.com","port":"1883","clientid":"a:kbrhh:viewer2"},{"id":"482fa4c4.b7d05c","type":"debug","name":"Show message","active":true,"console":"false","complete":"true","x":343,"y":62,"z":"948d5198.6b72b","wires":[]},{"id":"a07e3b0c.5f81c8","type":"mqtt in","name":"Receiver","topic":"iot-2/type/sensor-type/id/+/evt/event1/fmt/json","broker":"7649d216.89b62c","x":93,"y":129,"z":"948d5198.6b72b","wires":[["482fa4c4.b7d05c","e9a50fa3.165af"]]},{"id":"e9a50fa3.165af","type":"function","name":"JSONify and parse","func":"msg = JSON.parse(msg.payload)\ntemp = msg.d.temp\ntemp = Math.round(temp * 10)/10;\nreturn {\"payload\": \"Temerature is \" + temp + \" degrees of Celsius\" }","outputs":1,"x":344,"y":199,"z":"948d5198.6b72b","wires":[["4de9ed0c.b21614"]]},{"id":"4de9ed0c.b21614","type":"exec","command":"/usr/bin/say","append":"","useSpawn":"","name":"Say","x":578,"y":258,"z":"948d5198.6b72b","wires":[[],[],[]]}]
You can also change the voice by modifying say command from:
/usr/bin/say
to:
/usr/bin/say -v <voice name>
You can list available voices by entering command
/usr/bin/say -v ?
into terminal.
The flow requires Node-RED installed on a OS X machine.