I want to know if a can send a URL to mapas with a data template that contains the latitude and longitude off one of my device tracker, does telegram have option?
Probably you used the broadcast config instead of polling or webhooks.
Check this component page for more info.
Do you mean this?
@Domoticon
I am using polling. Is there anything which I have to add to the config?
Current config:
telegram_bot:
- platform: polling
api_key: <API_KEY>
allowed_chat_ids:
- <CHAT_ID>
I am also using duckdns.
I only use HA Telegram broadcast. For Telegram interaction I use Node-Red (link), Your polling config looks good to me, as far as I can tell.
I do not have experience setting up interaction with HA, but I read the component docs, linked in my previous answer.
So, if you use polling and a Telegram answer message starts with
/
then you probably need an event triggering to, ehh, trigger an eventā¦
Also, as far as the none Home Assistant part, you donāt need extra config to communicate with Telegram, no need for port forwarding, dynamic DNS config, etceteraā¦ If sending a message works, then sending back commands should be working also.
I donāt know if sending a message without / will work, I donāt think so, but Iām not sure about thatā¦
Can anyone, with more experience, please jump in?
Thank you for your help!
Its still not working. I am using the exact code like in the initial post from @Kallb123. I double checked my code and so far, I didnāt make a mistake.
I assume that there is something which blocks the message from telegram because of the error āIncoming message is not allowedā. So, telegram sends the message back to my HA and then it got lostā¦
2019-01-27 12:45:34 ERROR (dispatcher) [homeassistant.components.telegram_bot] Incoming message is not allowed ({āidā: āā, āchat_instanceā: ā<CHAT_ID>ā, āmessageā: {āmessage_idā: 335, ādateā: 1547658445, āchatā: {āidā: , ātypeā: āgroupā, ātitleā: āā, āall_members_are_administratorsā: True}, ātextā: āā, āentitiesā: [], ācaption_entitiesā: [], āphotoā: [], ānew_chat_membersā: [], ānew_chat_photoā: [], ādelete_chat_photoā: False, āgroup_chat_createdā: False, āsupergroup_chat_createdā: False, āchannel_chat_createdā: False, āfromā: {āidā: , āfirst_nameā: āā, āis_botā: True, āusernameā: āā}}, ādataā: ā/removekeyboardā, āfromā: {āidā: , āfirst_nameā: ā<FIRST_NAME>ā, āis_botā: False, ālanguage_codeā: ādeā}})
I found the following information: https://www.home-assistant.io/components/telegram_bot.webhooks/
āTo get your chat_id
and api_key
follow the instructions here. As well as authorizing the chat, if you have added your bot to a group you will also need to authorize any user that will be interacting with the webhook. When an unauthorized user tries to interact with the webhook Home Assistant will raise an error (āIncoming message is not allowedā), you can easily obtain the users id by looking in the āfromā section of this error message.ā
But I dont know what to do with this informationā¦
No one an idea how to solve the problem?
@taddeuz Did you send your bot a message first? Cause you have to get in contact with him the first time. Bots are not allowed to send message to users at first.
Hi, I receive successfully messages to my Telegram android app with notification from HASS.
But I receive message only from one user (I called it HASS). Since I setup many notifications I receive 2-300 messages a day making it a bit less useful.
I wish to establish more users and receive messages from different users like HASS-error-messages, HASS-sensor-values, HASS-important-alarms, and so on all of course from the same Home Assistant server.
Is this possible?
I achieved this by creating multiple group chats. Iām still only using a single Telegram bot but one bot can join many different groups. Since a group does require more than two participants in order to be created, I just add my bot and IDBot to the group initially. Once I get the chat id, I remove IDBot from the group. So, i currently have one regular chat with my bot for my main notification channel, and one group called Hass-system that I use for lower-priority system status notifications. But you could create as many as you want in the same fashion.
Great thanks.
Still trying to understand how to make new groups.
I go in my Telegram android app, click on + then New groupā¦ then, if i put my name (which in settings is @ xxxxx) xxxxx its not thereā¦?
Edit got it, when you create a group the creator is part of the group by default.
I am curious how many groups you created and which type of messages for each group you use.
I really only have one group right now. My main chat with my bot is for my main notifications that I want to see. Right now, I get notifications when our mode changes to Home or Away. I also get an actionable notification when my alarm clock goes off in the morning, tied to a lighting routine on my bedside lamp.
My group, Hass-system, is for lower priority notifications. I have the android app configured to put notifications from that group at a low priority. Right now I get notifications for when my weekly snapshot runs and backs up to Google Drive, and when files get added to a folder Iām monitoring, as well as when Home Assistant updates are available.
Thatās all I have for now, but I still have more in mind. For example, Iām also going to have a group that includes my wife, so that the bot can remind us of daily/weekly tasks that either of us can do (feeding the dogs, getting the mail, putting the trash out). That way, whoever completes the task can use the inline keyboard to indicate this so that if my wife wakes up after me, she can already know if the dogs have been fed. Or when I get home from work, I can already know whether sheās brought in the mail or not.
I am having a hard time making this work
So this is what I did
I do have my bot called @mybot
I created a group HOME ALERT MESSAGES consisting of
- MYBOT
- HOME ALERT MESSAGES
its CHAT_ID of this group is 12345
When I do the below command, the text SAMPLE TEXT goes correctly to the group HOME ALERT MESSAGES (XXX:YYY is the api of MYBOT)
curl -X POST "https://api.telegram.org/botXXXXX:YYYYY/sendMessage" -d "chat_id=-12345&text=SAMPLE TEXT"
But when I do this from Home assistant
notify:
- name: alerts_telegram
platform: telegram
chat_id: 12345
with an automation
action:
- service: notify.alerts_telegram
data_template:
message: 'TEST MESSAGE'
the message does not go to the group HOME ALERT MESSAGES, but only to MYBOT
What am I missing here??
EDIT I found two problems in my installation
1 groups starts with minus: -1234567
2 the service notify.xxxxx sends the message only to my bot, in order to send messages to my groups I need to use
- service: telegram_bot.send_message
data_template:
message: 'John is home'
target: '-group_chat_id' # the group chat id (do not forget the minus)
EDIT: Nvm, looks like you got it while I was replying.
Did you also add this piece to your configuration.yaml file?
telegram_bot:
- platform: polling
api_key: YOUR_API_KEY
allowed_chat_ids:
- CHAT_ID_1
- CHAT_ID_2
- CHAT_ID_3
The only other thing I see is that for the chat_id, it has a dash in front of it in the cURL example, but not in your configuration.yaml file. I know 12345 is not your actual chat id, but you may want to check and confirm what you have in configuration.yaml completely matches your Telegram chat_id. I donāt have my config in front of me, but Iām pretty sure users have a positive number for their chat_id and groups always have a negative number.
Yes I had 3 problems (tweo are explained in the previous post), I also had to add the group id (with a minus in telegram_bot configuration
telegram_bot:
- platform: polling
api_key: !secret telegram_bot_api
allowed_chat_ids:
- -12345 # this is a group
- 23456 # thjis is a user
No, I did that but was not working, I had to do the
- service: telegram_bot.send_message # it works,
- service: notify.xxxxx # NOT working