This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Add a way to cummunicate with a Telegram Bot

1356712

Comments

  • I just returned from my vacation and tried the app.

    Just a huge thumbs up, jorden! You did a hell of a job! Works like a charm! B)
  • Think about the possibilities, unbelievable.
    Top App!!!!
  • VonkenboerVonkenboer Member
    edited August 2016
    BTW, for future development some suggestions:
     1 - A way to send symbols
    When trying to send symbols, like ♺ or ℹ, it returns a normal character (z, 9).
     2 - A way to add CR (carriage return)
    I tried to get more lines in one message (ending with %0A), which doesn't work.

    Edit: point 2 is working. My mistake.

    I do some further testing. If I notice something I will report it to you. Looking good so far!
  • Is there a way to use stickers? Can the bot reply with stickers?
  • spoelly said:
    Is there a way to use stickers? Can the bot reply with stickers?
    As far I tested, It doesn't work (yet). I should not know how to handle pictures in a flow.

    A nice suggestion though. It should be nice, in the future, to receive pictures/snapshots/video-file from a IP-Cam or sending a sticker. But I think this will be a lot of additional programming  by jorden..... :)
  • It's a nice to have feature, we will see what jorden thinks about it
  • Just a nice example to use for Homey debugging reasons:

  • spoellyspoelly Member
    edited August 2016
    Nice one!
  • VonkenboerVonkenboer Member
    edited August 2016
    Thanks spoelly. This way I found out that a trigger will not be triggered when you 'save' a variable with the same content.

    For example, when sending a message from Telegram and store it to a string in the Better Logic App variable and use this variable to trigger something, it will not work when the previous Telegram message is the same.
    The work around I use is resetting the variable string with a space. The drawback is it will be triggered twice, so you need extra condition to block the second trigger...

    BTW, does anybody knows how to insert the content of a Homey variable to string?
  • "BTW, does anybody knows how to insert the content of a Homey variable to string?"

    I would like to use that 2. No clue how that should work yet.
  • VonkenboerVonkenboer Member
    edited August 2016
    spoelly said:
    "BTW, does anybody knows how to insert the content of a Homey variable to string?"

    I would like to use that 2. No clue how that should work yet.
    FYI, I got help from the community: https://forum.athom.com/discussion/comment/29086/#Comment_29086


  • Yeah stickers is not going to work well because you would have to define them in a Homey flow.

    A picture from my Synology app to Telegram is something that I have been thinking of, but would have to figure out how to make the Synology app connect to the Telegram app somehow. It is possible but I just haven't done it yet so it requires some testing.
  • Probably Athom will be implement IP-cams in the near future?
    I suggest we'll have to wait for a while before we overload you with requests, which costing you valuable time and effort to get it working, jorden!

  • Jorden, just a question/suggestion.

    Is it an idea to make add a, sort of, command structure to your App, like a cooperate Telephone switchmenu?

    I will try to explain what I mean with examples....
    Lets say,  you have a 'root' menu with:
    - say
    - ledcolor
    - lights
    - roomba
    - cam
    - * (back to root menu)
    - ? (present options to choose from)
    When you sending a message in Telegram to your Homey it will respond which submenu is chosen and what options to choose from.

    Example:
    Telegram: say
    Homey: Please tell me what to say...
    Telegram: Hello World
    Homey: I just said 'Hello World'. Please enter next thing to say.
    Telegram: *
    Homey: I'm just found my roots!
    Telegram: ?
    Homey: <say> <ledcolor> <lights> <roomba> <*> <?>
    Telegram: ledcolor
    Homey: Hand me the color!
    Telegram: ?
    Homey: <red> <white> <blue> <orange> <rrr.ggg.bbb>

    Well, I think you get my intention....

    It should be nice to setup something like that in your app. Like editing the structure, options, and executing commands.

    Please tell me if think you thinking about it, otherwise I have to program this in my own flows, which can be done. I just tested it and it works very nice for controlling the homey.

    Please let me know what you think about it.
  • That's actually a brilliant idea, @Vonkenboer !

    I'd even like to take it a little further, and see what I can do it. You could make different commands in the bot, for example:
    /say "This is a spoken text on Homey"
    or
    /lights off
    or
    /lights purple
    or
    /lights random
    or
    /cam 1 snapshot

    The app would need permisions to all involved apps (for example, Hue and Synology) but this is quite a good idea!
  • VonkenboerVonkenboer Member
    edited August 2016
    I'm glad you like it. :)

    Another addition could be to add numbers to the structure and option, similar as imposed by you, to activate it in one command. For example , to switch of light, 3 14 90 (lights --> device #14 --> Dim to 90%).

    I came up with this idea while playing around with your app and trying to figure out a way to give commands without remembering all the commands and functions and use the minimum at character input. The commands you use often are easy to remember, but others, not used a lot, are been forgotten.

    The Telephone switching menu is developed just to do that and is based on many years of experience and improvement. So why not copy the, well thought-out, system and paste it into the present technology....  ;)
  • Nice one @Vonkenboer! Like to have that 2
  • jordenjorden Member
    edited August 2016
    Yeah, that telephone menu-style thing could work, except that I receive every chat as a single message so I'd have to remember which 'menu' you are in somehow... but I'll think about it. Ofcourse you can always have a 'help' command.
    Great potential!
  • jorden said:

    /say "This is a spoken text on Homey"
    or
    /lights off
    .....
    The app would need permisions to all involved apps (for example, Hue and Synology) but this is quite a good idea!
    Just one note: beware of using the universal Telegram bot reply features, like used in the most bots used for public means. I don't want the Homey to be controlled by the rest of the world.... ;)

  • jordenjorden Member
    edited August 2016
    I just started on this... made a 'say' command already :)

    Now expanding with other options, for example:
    /snap

    Will show you available options for taking a snapshot. For example, it will show:
    "Available options: /snap <id>"
    "Replace <id> with:"
    "Camera 1: test12345"
    "Camera 2: test54321"

    and so on:)
  • jorden said:
    Yeah, that telephone menu-style thing could work, except that I receive every chat as a single message so I'd have to remember which 'menu' you are in somehow... but I'll think about it. Ofcourse you can always have a 'help' command.
    Great potential!
    The app only can be used, especially when using your own bot, by one person. Did you make it user-id dependent? Then it shouldn't be a problem storing the actual menu status.

    Maybe you can try it by storing the menu structure number, say 3 14, as 90314 into a variable, where the first digit is always 9 (taken this number as example for shortcut to root) and then two digits for every submenu. Now you can easy figure out what submenu you are at by subtracting/dividing it?

    Just a thought... But you're probably far more capable of figuring this out!

  • jorden said:
    I just started on this... made a 'say' command already :)

    Now expanding with other options, for example:
    /snap

    Will show you available options for taking a snapshot. For example, it will show:
    "Available options: /snap <id>"
    "Replace <id> with:"
    "Camera 1: test12345"
    "Camera 2: test54321"

    and so on:)
    FYI, you can use a %0A as carriage return for presenting the options in one message.

    On my Fibaro HC2 I made a table to store the options to, and when filled I send every table-row by adding %0A at the end and loop al messages, which ended up with multiple rows in one message.
  • I use \n, works as well :)
  • Okay! Didn't work on my Fibaro HC though.... Nice to know. :)
  • jordenjorden Member
    edited August 2016
    I have continued work on this and have seen that there are a lot of possibilities. I am keeping it basic for now, but once I get some stuff working I will continue to extend the functionality.

    I currently have made it so far that you can get a list of available devices in your synology surveillance center app (if installed in Homey). You can then choose one the devices to get a snapshot from.

    I got it working that I receive the photo, base64 encoded, in the Telegram-Homey-app. However, struggling to get that to the chat API of Telegram. Because it is base64 encoded string, I first need to pull some magic to convert it somehow, so Telegram believes it is an image. Currently either getting Error 400: Bad Request: there is no photo in the request or Error 413
  • Can it be that this is because all communication to Telegram has to be encrypted?
  • No, encryption happens automatically because you talk to a https server
  • PeaoPeao Member
    Can you access the /manger/speech-input from the App/Api? That way you could easy run flows with telegramm.
  • VonkenboerVonkenboer Member
    edited August 2016
    jorden said:
    No, encryption happens automatically because you talk to a https server
    When I changed my bot avatar I noticed it would only accept the picture as a file. Could you try to send it as file, not as picture?

    Just a thought.

    EDIT: https://core.telegram.org/api/errors

  • Peao said:
    Can you access the /manger/speech-input from the App/Api? That way you could easy run flows with telegramm.
    No, I have discussed that with Emile awhile ago and it is not allowed because it is a bit of a security hazard.
Sign In or Register to comment.