Hey
I use HAOS in a local mode : disconnected from internet.
I would like to read some jokes picked up from a local file on my Rpi.
What i have done :
So i downloaded a JSON file with 10 jokes and stored it on my Raspberry.
See Json content
{
"error": false,
"amount": 10,
"jokes": [
{
"category": "Misc",
"type": "twopart",
"setup": "Comment reconnaître un ministre qui ment?",
"delivery": "Ses lèvres bougent",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 237,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Pourquoi est-ce que les anges sont sourds?",
"delivery": "Parce que Jésus-Christ.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 203,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Que disait Eve pour faire avancer le bâteau?",
"delivery": "Ramadan",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 315,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Tu sais ce que c'est un suppositoire?",
"delivery": "C'est une invention qui restera dans les annales.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 319,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Quand 2 poissons s'énervent..",
"delivery": "Est-ce qu'on peut dire que le thon monte?",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 298,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Pourquoi les bots ne parlent pas avec les humains?",
"delivery": "Par peur de leur ressembler.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 272,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Qu'est-ce qu'un cadeau qui s'en va?",
"delivery": "Une surprise party.",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 153,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Que font 2 brosses à dents le 14 Juillet?",
"delivery": "Un feu dentifrice!",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 262,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Chéri, je me sens grosse et laide... S'il te plait, fais-moi un compliment...",
"delivery": "Tu as une bonne vue!",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 248,
"lang": "fr"
},
{
"category": "Misc",
"type": "twopart",
"setup": "Pourquoi il n'y a pas de ballon à question pour un champion?",
"delivery": "Parce que Julien Lepers",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"safe": true,
"id": 15,
"lang": "fr"
}
]
}
I manage to read this file and find back those jokes : 2 lines (question =setup & answer =delivery)
NodeRed nodes
[
{
"id": "15c33a53cd75773b",
"type": "file in",
"z": "20d5c36c60b1a5e6",
"name": "",
"filename": "/config/Jokes/blagues.json",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "utf8",
"allProps": false,
"x": 320,
"y": 640,
"wires": [
[
"5cc6e99793bc4d7d"
]
]
},
{
"id": "d39b1e46968ef8db",
"type": "debug",
"z": "20d5c36c60b1a5e6",
"name": "DEbug content Json file",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1150,
"y": 620,
"wires": []
},
{
"id": "81890602d5baede6",
"type": "inject",
"z": "20d5c36c60b1a5e6",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 80,
"y": 600,
"wires": [
[
"15c33a53cd75773b"
]
]
},
{
"id": "5cc6e99793bc4d7d",
"type": "json",
"z": "20d5c36c60b1a5e6",
"name": "Json String to Json Objet",
"property": "payload",
"action": "",
"pretty": false,
"x": 610,
"y": 640,
"wires": [
[
"d39b1e46968ef8db",
"5d3a22fa8158d720"
]
]
},
{
"id": "5d3a22fa8158d720",
"type": "function",
"z": "20d5c36c60b1a5e6",
"name": "GetJoke",
"func": "\nvar tts = payload.jokes[0].setup\n\nmsg.payload= tts\nreturn msg;",
"outputs": 1,
"noerr": 1,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 740,
"wires": [
[
"35606b2bf84f5634"
]
]
},
{
"id": "35606b2bf84f5634",
"type": "http request",
"z": "20d5c36c60b1a5e6",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://homeassistant.local:12101/api/text-to-speech",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"credentials": {
"user": "",
"password": ""
},
"x": 1030,
"y": 740,
"wires": [
[]
]
}
]
My problem :
For the moment, i cannot grab those data to send it to Rhasspy
I want to share it with you if anyone is interested and could help me
thanks a lot
Fab