Habe das mal bei mir angesehen
- Du hast im “Snapshot” Node eine Datei “Haustuer_1.jpg”
- In Telegram willst du eine Datei “Haustuer_2.jpg” senden. Die gibt es vermutlich nicht
- Du hast in deinen Nodes Pfadnamen mit doppeltem Slash “//”. Ich nutze kein HA OS, aber ich zweifle dass das richtig ist. Darum läuft es vermutlich auf Fehler
Unabhängig davon würde ich Dateinamen nicht statisch setzen. Wenn die Datei mal korrupt ist oder auf OS gesperrt wird geht es nie wieder. Ich würde den Dateinamen dynmaisch machen, z. B. mit Timestamp.
Catch ist ein Workaround den ich vermeiden würde wenn möglich. Fehler loggen und ggf. separate Notification. Wenn von Anfang an schon mit dem Scheitern gerechnet wird ist was falsch und du kannst es gleich sein lassen.
Beispiel angehängt mit Catch … würde funktionieren, aber nicht empfohlen. Die Catch-Node fließt in eine Funktion und erzeugt dann auch die Telegram Nachricht.
[
{
"id": "5eb6f3c911146727",
"type": "catch",
"z": "cb4c2d91f85165e6",
"name": "",
"scope": [
"d65a43a86a118ee0"
],
"uncaught": false,
"x": 310,
"y": 140,
"wires": [
[
"e3d5744fac1c3a7e"
]
]
},
{
"id": "5cea55caae7d9fab",
"type": "file",
"z": "cb4c2d91f85165e6",
"name": "",
"filename": "/data/errot.txt",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 850,
"y": 140,
"wires": [
[]
]
},
{
"id": "f91861846306c073",
"type": "change",
"z": "cb4c2d91f85165e6",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "error",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 140,
"wires": [
[
"5cea55caae7d9fab"
]
]
},
{
"id": "0c9a17037055b8dc",
"type": "inject",
"z": "cb4c2d91f85165e6",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 80,
"wires": [
[
"d65a43a86a118ee0"
]
]
},
{
"id": "d65a43a86a118ee0",
"type": "api-call-service",
"z": "cb4c2d91f85165e6",
"name": "Take Snapshot",
"server": "b99a7cfd90266689",
"version": 7,
"debugenabled": false,
"action": "camera.snapshot",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"camera.yi_hack_a2_7139f9_cam"
],
"labelId": [],
"data": "{\"filename\":\"/media//Haustuer_1.jpg\"}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "camera",
"service": "snapshot",
"output_location": "",
"output_location_type": "none",
"x": 340,
"y": 80,
"wires": [
[
"712033f55077cb28"
]
]
},
{
"id": "712033f55077cb28",
"type": "function",
"z": "cb4c2d91f85165e6",
"name": "prep msg",
"func": "msg.filename = '/media//Haustuer_2.jpg';\nmsg.payload = { \n data: {\n type: 'photo',\n file: '/media//Haustuer_2.jpg',\n chatId: -694956136,\n caption: 'Haustür hat geklingelt! v2' }\n};\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 620,
"y": 80,
"wires": [
[
"76914ade7abf5dee"
]
]
},
{
"id": "76914ade7abf5dee",
"type": "debug",
"z": "cb4c2d91f85165e6",
"name": "Do whatever needs to be done ... telegram",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 950,
"y": 80,
"wires": []
},
{
"id": "c746670d2312b8a1",
"type": "comment",
"z": "cb4c2d91f85165e6",
"name": "Log error for analysis",
"info": "",
"x": 880,
"y": 180,
"wires": []
},
{
"id": "f3c2bdfafe3b7aee",
"type": "comment",
"z": "cb4c2d91f85165e6",
"name": "Catch only Snapshot Node",
"info": "",
"x": 370,
"y": 180,
"wires": []
},
{
"id": "e3d5744fac1c3a7e",
"type": "junction",
"z": "cb4c2d91f85165e6",
"x": 480,
"y": 140,
"wires": [
[
"f91861846306c073",
"712033f55077cb28"
]
]
},
{
"id": "b99a7cfd90266689",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "numeric",
"statusMonth": "2-digit",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]
Fehler in der Datei “error.txt” dann kannst auch analysieren
{"message":"ValidationError: \"action\" is not allowed to be empty","source":{"id":"d65a43a86a118ee0","type":"api-call-service","name":"Take Snapshot","count":1},"stack":"ValidationError: \"action\" is not allowed to be empty"}
{"message":"HomeAssistantError: Service camera.snapshot not found.","source":{"id":"d65a43a86a118ee0","type":"api-call-service","name":"Take Snapshot","count":1},"stack":"HomeAssistantError: Service camera.snapshot not found.\n at getErrorData (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/errors/inputErrorHandler.js:43:13)\n at inputErrorHandler (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/errors/inputErrorHandler.js:63:38)\n at ActionController._InputOutputController_preOnInput (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/controllers/InputOutputController.js:69:51)"}
{"message":"HomeAssistantError: Service camera.snapshot not found.","source":{"id":"d65a43a86a118ee0","type":"api-call-service","name":"Take Snapshot","count":1},"stack":"HomeAssistantError: Service camera.snapshot not found.\n at getErrorData (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/errors/inputErrorHandler.js:43:13)\n at inputErrorHandler (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/errors/inputErrorHandler.js:63:38)\n at ActionController._InputOutputController_preOnInput (/data/node_modules/node-red-contrib-home-assistant-websocket/dist/common/controllers/InputOutputController.js:69:51)"}