iobroker-community-adapters / ioBroker.doorbird

Doorbird Adapter for ioBroker
MIT License
17 stars 13 forks source link

send doorbird photo via telegram seems to be a bit tricky #98

Closed pzystorm closed 11 months ago

pzystorm commented 11 months ago

Describe the bug
on the main page (https://github.com/iobroker-community-adapters/ioBroker.doorbird/) of this adapter there is following solution written:

onFile("doorbird.0", "TakeSnapshot_1.jpg", false, function (id, fileName, size, fileData, mimeType) {
    sendTo('telegram.0', {
        text: fileData,
        type: 'photo'
    });
});

It seems fileData contains only the filename and the telegram adapter does not find the file.

If i change the code to:

onFile("doorbird.0", "TakeSnapshot_1.jpg", false, function (id, fileName, size, fileData, mimeType) {
    sendTo('telegram.0', 'send' , {
        text: '/opt/iobroker/iobroker-data/files/doorbird.0/TakeSnapshot_1.jpg',
        type: 'photo'
    });
});

it works for me and the photo is send via telegram.

Can you advise, is this the correct solution? Is it really necessary to put the whole path hardcoded inside there or is there any getPath function?

Apollon77 commented 11 months ago

If you want to have the filedata then the third parameter in Javascrip adapter call onFile needs to be "true" and not false. In the current case "with false" no file data are provided at all

pzystorm commented 11 months ago

Then someone should change this on the page https://github.com/iobroker-community-adapters/ioBroker.doorbird/ as the code is from there :) Actually I dont know which one is the best solution for the sendTo telegram command: use the string fileName or use the binary fileData.

Schmakus commented 11 months ago

If you want to have the filedata then the third parameter in Javascrip adapter call onFile needs to be "true" and not false. In the current case "with false" no file data are provided at all

Ok, with "true" the original function will work?

Schmakus commented 11 months ago

Then someone should change this on the page https://github.com/iobroker-community-adapters/ioBroker.doorbird/ as the code is from there :)

Actually I dont know which one is the best solution for the sendTo telegram command: use the string fileName or use the binary fileData.

Could you check with true parameter and binary file?

pzystorm commented 11 months ago

yeah, cool, i have tried this:

onFile("doorbird.0", "TakeSnapshot_1.jpg", true, function (id, fileName, size, fileData, mimeType) {
    sendTo('telegram.0', "send" , {
        text: fileData,
        type: 'photo'
    });
});

works, too! then i leave it like this. thanks :)

Schmakus commented 11 months ago

I've updated the doc.