Help with splitting payload (to get the values for the time)

This is what I have so far but it doesn't work as I want.

[{"id":"943ee548ae140c50","type":"change","z":"235f16ee6e459f2c","name":"TimeStamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":3400,"y":1420,"wires":[["c8db866e84b556ab"]]},{"id":"c8db866e84b556ab","type":"moment","z":"235f16ee6e459f2c","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss","locale":"en_AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":3590,"y":1420,"wires":[["46a337239c34a502"]]},{"id":"46a337239c34a502","type":"template","z":"235f16ee6e459f2c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The time is {{payload}}","output":"str","x":3780,"y":1420,"wires":[["91699b85b4e6a7d6"]]}]

When I put it through the text to speech it comes out a bit yucky.

I want it to be more like how you would say the time.

And - sorry but sod's law is here - if the second value (for the seconds) is 0 I want exactly said rather than zero.

I'm guessing I need to parse the payload out of the date/time formatter node and split it into hours minutes and seconds.

I'll do local digging too, but just of someone doesn't mind.

These two nodes seem to be doing it.

[{"id":"78a97b936514a7b7","type":"function","z":"b25fd092.bcc758","name":"function 40","func":"let x = msg.payload.split(\":\")\n\n//node.warn(x);\n\nmsg.hour = x[0];\nmsg.minute = x[1];\nmsg.second = x[2];\n\nif (msg.second == 0)\n{\n    msg.second = \"exactly\";\n} else\nmsg.second = \" and \" + x[2] + \" seconds\";\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2030,"y":310,"wires":[["c027723a8de504df","945027a34e67375e"]]},{"id":"945027a34e67375e","type":"template","z":"b25fd092.bcc758","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The time is {{hour}} {{minute}} {{second}}","output":"str","x":1920,"y":370,"wires":[["cd12799f4f8a921d"]]}]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.