Hi All,
i am new to node red barely using it for few days and still learning
Trying to send the image using telegram sender node ( The saved image file is located in Home Assistant server 1 and Node Red is running on separate standalone server 2 )
Current Setup
Server 1 Node red running telegram bot
Server 2 Running Home assistant and image is getting stored at location named /share in home assistant server
Code used in function node
msg.payload = {}
msg.payload.chatId = -12345678
msg.payload.type = "photo"
msg.payload.content = "/share/snapshot_Dahua - MediaProfile_Channel1_SubStream1.jpg"
return msg;
Requirment
Node red need to send the snapshot from the /share location on server 1 as telegram notification .
Current flow used by me and its is not working and errors as per debug
3/21/2021, node: Motion Detected
msg : string[28]
"msg.payload.content is empty"
if i add the content payload to the function i am getting this error
Caught exception in sender node:
'Error: ETELEGRAM: 400 Bad Request: URL host is empty'
when processing message:
{"_msgid":"8edb6561.8dc748","payload":{"chatId":-1234568,"type":"photo","content":"/share/snapshot_Dahua - MediaProfile_Channel1_SubStream1.jpg","options":{"chat_id":-123456789,"photo":"/share/snapshot_Dahua - MediaProfile_Channel1_SubStream1.jpg"}},"topic":""}
[{"id":"c2cf9273.a27e08","type":"tab","label":"Camera Motion Detection","disabled":false,"info":""},{"id":"6c99316a.409cb","type":"server-state-changed","z":"c2cf9273.a27e08","name":"Camera Cell Motion Detection","server":"f96cd7e5.e97f3","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"camera.dahua_mediaprofile_channel1_substream1","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":150,"y":220,"wires":[["e4e4a7f3.283d3"]]},{"id":"217e8e52.a70a12","type":"telegram sender","z":"c2cf9273.a27e08","name":"Motion Detected","bot":"b1c8e34b.bb945","haserroroutput":false,"outputs":1,"x":900,"y":80,"wires":[["9fdb2672.2d8be8"]]},{"id":"a9b344a3.324088","type":"function","z":"c2cf9273.a27e08","name":"","func":"msg.payload = {\n\tchatId : ,\n\ttype : \"photo\",\n\tfile : \"/share/snapshot_Dahua - MediaProfile_Channel1_SubStream1.jpg\"\n\t};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":140,"wires":[["217e8e52.a70a12","2a2f3f72.94c028"]]},{"id":"add56cbe.ffaf6","type":"inject","z":"c2cf9273.a27e08","name":"Inject","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":150,"y":320,"wires":[["e4e4a7f3.283d3"]]},{"id":"e4e4a7f3.283d3","type":"api-call-service","z":"c2cf9273.a27e08","name":"Take Snap Shot","server":"f96cd7e5.e97f3","version":1,"debugenabled":false,"service_domain":"camera","service":"snapshot","entityId":"camera.dahua_mediaprofile_channel1_substream1","data":"{\"filename\":\"/share/snapshot_{{ entity_id.name }}.jpg\"}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":400,"y":220,"wires":[["c08b8e58.b5b838","a9b344a3.324088"]]},{"id":"2a2f3f72.94c028","type":"debug","z":"c2cf9273.a27e08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":220,"wires":[]},{"id":"c08b8e58.b5b838","type":"debug","z":"c2cf9273.a27e08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":300,"wires":[]},{"id":"9fdb2672.2d8be8","type":"debug","z":"c2cf9273.a27e08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1150,"y":120,"wires":[]},{"id":"f96cd7e5.e97f3","type":"server","name":"","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"b1c8e34b.bb925","type":"telegram bot","botname":"","usernames":"","chatids":"-","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}]