Hey Guys,
Question:
for the past 3 day's i'm trying to figure out how to get a mqtt base64 img to a telegram channel so i get a picture if someone rights the bell
i think i'm pretty far although i also think it can be more efficiënt.
this is my flow as of now:
The MQTT message gets encoded by the base64 then gets written on disk by "write"
it gets pickup when someone rings the doorbell by the "load image" and send picture contains:
msg.payload.chatId=-100170xx49x220
msg.payload.type= 'photo';
msg.payload.caption= "Caption"
msg.payload.content= msg.payload
return msg;
i copied that from another user here on the forum and edited my chatid
this is the flow:
[
{
"id": "52910ba9d857f29e",
"type": "base64",
"z": "09d4dd0351a92c23",
"name": "",
"action": "",
"property": "payload",
"x": 340,
"y": 780,
"wires": [
[
"9291282e83a46ed7",
"c1340dd4b1952e22"
]
]
},
{
"id": "c1340dd4b1952e22",
"type": "image viewer",
"z": "09d4dd0351a92c23",
"name": "",
"width": 160,
"data": "payload",
"dataType": "msg",
"active": true,
"x": 750,
"y": 620,
"wires": [
[]
]
},
{
"id": "9291282e83a46ed7",
"type": "jimp-image",
"z": "09d4dd0351a92c23",
"name": "",
"data": "payload",
"dataType": "msg",
"ret": "img",
"parameter1": "/data/node-red-256.png",
"parameter1Type": "str",
"parameter2": "",
"parameter2Type": "msg",
"parameter3": "",
"parameter3Type": "msg",
"parameter4": "",
"parameter4Type": "msg",
"parameter5": "",
"parameter5Type": "msg",
"parameter6": "",
"parameter6Type": "msg",
"parameter7": "",
"parameter7Type": "msg",
"parameter8": "",
"parameter8Type": "msg",
"sendProperty": "payload",
"sendPropertyType": "msg",
"parameterCount": 1,
"jimpFunction": "write",
"selectedJimpFunction": {
"name": "write",
"fn": "write",
"description": "Write to file. NOTE: You can specify an alternative file extension type to change the type. Currently support types are jpg, png, bmp.",
"parameters": [
{
"name": "filename",
"type": "str",
"required": true,
"hint": "Name of the file",
"defaultType": "str"
}
]
},
"x": 610,
"y": 820,
"wires": [
[]
]
},
{
"id": "12902d544a65b520",
"type": "switch",
"z": "09d4dd0351a92c23",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ON",
"vt": "str"
},
{
"t": "eq",
"v": "OFF",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 250,
"y": 960,
"wires": [
[
"110674a7fb87820a",
"0303f5f02dc57c56",
"82ef1ec6644c5519",
"a0158dde9de70598"
],
[]
]
},
{
"id": "a41a7223779bc470",
"type": "telegram sender",
"z": "09d4dd0351a92c23",
"name": "",
"bot": "9199505571c7bbde",
"haserroroutput": false,
"outputs": 1,
"x": 840,
"y": 860,
"wires": [
[
"692390b113e4e004"
]
]
},
{
"id": "a0158dde9de70598",
"type": "file in",
"z": "09d4dd0351a92c23",
"name": "load image",
"filename": "/data/node-red-256.png",
"format": "",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 470,
"y": 960,
"wires": [
[
"bf924d9bde8ac67c"
]
]
},
{
"id": "3fd182b208be2475",
"type": "sonos-universal",
"z": "09d4dd0351a92c23",
"confignode": "ad4f73545a13e1ce",
"command": "group.play.notification",
"state": "http://patatje.net/dingdong.mp3",
"stateType": "str",
"avoidCheckPlayerAvailability": false,
"name": "Overloop Ding Dong",
"x": 380,
"y": 860,
"wires": [
[]
]
},
{
"id": "0303f5f02dc57c56",
"type": "sonos-universal",
"z": "09d4dd0351a92c23",
"confignode": "3bbcc44335742592",
"command": "group.play.notification",
"state": "http://patatje.net/dingdong.mp3",
"stateType": "str",
"avoidCheckPlayerAvailability": false,
"name": "Keuken Ding Dong",
"x": 630,
"y": 880,
"wires": [
[]
]
},
{
"id": "82ef1ec6644c5519",
"type": "api-current-state",
"z": "09d4dd0351a92c23",
"name": "AppleTV Woonkamer is playing",
"server": "51041573183f2685",
"version": 3,
"outputs": 2,
"halt_if": "Playing",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "media_player.woonkamer_tv",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 230,
"y": 1080,
"wires": [
[
"886c43c6cbf703ee"
],
[]
]
},
{
"id": "886c43c6cbf703ee",
"type": "api-call-service",
"z": "09d4dd0351a92c23",
"name": "Pause AppleTV",
"server": "51041573183f2685",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "media_play_pause",
"areaId": [
"woonkamer"
],
"deviceId": [
"d25c0aee46e67579ff3bb3cbbc5c3f6f"
],
"entityId": [
"media_player.woonkamer_tv"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 320,
"y": 1120,
"wires": [
[]
]
},
{
"id": "692390b113e4e004",
"type": "debug",
"z": "09d4dd0351a92c23",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 950,
"y": 780,
"wires": []
},
{
"id": "bf924d9bde8ac67c",
"type": "function",
"z": "09d4dd0351a92c23",
"name": "send picture",
"func": "msg.payload.chatId=-00000\nmsg.payload.type= 'photo';\nmsg.payload.caption= \"Caption\"\nmsg.payload.content= msg.payload\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 670,
"y": 960,
"wires": [
[
"a41a7223779bc470"
]
]
},
{
"id": "3899e466c719ea88",
"type": "comment",
"z": "09d4dd0351a92c23",
"name": "Ring creates a new snapshot every 3 seconds",
"info": "",
"x": 230,
"y": 700,
"wires": []
},
{
"id": "ae69b7afd5e1b59f",
"type": "comment",
"z": "09d4dd0351a92c23",
"name": "Write image to file",
"info": "Write image to file",
"x": 590,
"y": 760,
"wires": []
},
{
"id": "ea0e5854176486bf",
"type": "comment",
"z": "09d4dd0351a92c23",
"name": "Pickup writed file",
"info": "",
"x": 480,
"y": 1020,
"wires": []
},
{
"id": "9199505571c7bbde",
"type": "telegram bot",
"botname": "@Pic0Bot",
"usernames": "xxx",
"chatids": "-xx",
"baseapiurl": "",
"updatemode": "polling",
"pollinterval": "300",
"usesocks": false,
"sockshost": "",
"socksport": "6667",
"socksusername": "anonymous",
"sockspassword": "",
"bothost": "",
"botpath": "",
"localbotport": "8443",
"publicbotport": "8443",
"privatekey": "",
"certificate": "",
"useselfsignedcertificate": false,
"sslterminated": false,
"verboselogging": false
},
{
"id": "ad4f73545a13e1ce",
"type": "sonos-config",
"name": "Overloop Sonos",
"serialnum": "",
"ipaddress": "10.0.1.10"
},
{
"id": "3bbcc44335742592",
"type": "sonos-config",
"name": "Keuken",
"serialnum": "",
"ipaddress": "10.0.1.8"
},
{
"id": "51041573183f2685",
"type": "server",
"name": "Home Assistant",
"version": 2,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30"
}
]
i wonder what i'm doing wrong but i also wonder why i cant directly send the base64 to telegram without having to save it first.
i hope anyone can help!