{"action":"created","issue":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4560","repository_url":"https://api.github.com/repos/home-assistant/home-assistant","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4560/labels{/name}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4560/comments","events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4560/events","html_url":"https://github.com/home-assistant/home-assistant/issues/4560","id":191403030,"number":4560,"title":"notify.telegram: data_template + Markdown - Can't find end of the entity starting at byte offset N","user":{"login":"danielperna84","id":7396998,"avatar_url":"https://avatars.githubusercontent.com/u/7396998?v=3","gravatar_id":"","url":"https://api.github.com/users/danielperna84","html_url":"https://github.com/danielperna84","followers_url":"https://api.github.com/users/danielperna84/followers","following_url":"https://api.github.com/users/danielperna84/following{/other_user}","gists_url":"https://api.github.com/users/danielperna84/gists{/gist_id}","starred_url":"https://api.github.com/users/danielperna84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielperna84/subscriptions","organizations_url":"https://api.github.com/users/danielperna84/orgs","repos_url":"https://api.github.com/users/danielperna84/repos","events_url":"https://api.github.com/users/danielperna84/events{/privacy}","received_events_url":"https://api.github.com/users/danielperna84/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-23T23:37:53Z","updated_at":"2016-12-07T15:44:53Z","closed_at":null,"body":"**Home Assistant release (`hass --version`):**\r\n0.33.3\r\n\r\n**Python release (`python3 --version`):**\r\n3.4.2\r\n\r\n**Component/platform:**\r\nnotify.telegram\r\n\r\n**Description of problem:**\r\nTelegram notifications fail when building the message with a data_template and using ```{{ trigger.entity_id }}``` and the number of ```_``` (markdown for italic text) is not even. So if the template resolves to ```device_tracker.device```, there's a final ```_``` missing to finish the italic text. This leads to the traceback posted below.  \r\n\r\n**Expected:**\r\nWorking notifications.\r\n\r\n**Problem-relevant `configuration.yaml` entries and steps to reproduce:**\r\n```yaml\r\n- alias: \"Loginnotify\"\r\n  trigger:\r\n    platform: state\r\n    entity_id: device_tracker.daniel\r\n    to: \"home\"\r\n  action:\r\n    - service: notify.tele\r\n      data_template:\r\n        message: >\r\n          {{ trigger.entity_id }}\r\n```\r\n\r\n**Traceback (if applicable):**\r\n```bash\r\nNov 24 00:21:01 homeassistant hass[21793]: INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service_call_id=1975746672-11, service=tele, service_data=message=device_tracker.daniel, domain=notify>\r\nNov 24 00:21:01 homeassistant hass[21793]: ERROR:homeassistant.components.notify.telegram:Error sending message\r\nNov 24 00:21:01 homeassistant hass[21793]: Traceback (most recent call last):\r\nNov 24 00:21:01 homeassistant hass[21793]: File \"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/notify/telegram.py\", line 122, in send_message\r\nNov 24 00:21:01 homeassistant hass[21793]: parse_mode=parse_mode)\r\nNov 24 00:21:01 homeassistant hass[21793]: File \"/home/hass/.homeassistant/deps/telegram/bot.py\", line 124, in decorator\r\nNov 24 00:21:01 homeassistant hass[21793]: result = func(self, *args, **kwargs)\r\nNov 24 00:21:01 homeassistant hass[21793]: File \"/home/hass/.homeassistant/deps/telegram/bot.py\", line 150, in decorator\r\nNov 24 00:21:01 homeassistant hass[21793]: result = self._request.post(url, data, timeout=kwargs.get('timeout'))\r\nNov 24 00:21:01 homeassistant hass[21793]: File \"/home/hass/.homeassistant/deps/telegram/utils/request.py\", line 205, in post\r\nNov 24 00:21:01 homeassistant hass[21793]: **urlopen_kwargs)\r\nNov 24 00:21:01 homeassistant hass[21793]: File \"/home/hass/.homeassistant/deps/telegram/utils/request.py\", line 152, in _request_wrapper\r\nNov 24 00:21:01 homeassistant hass[21793]: raise BadRequest(repr(message))\r\nNov 24 00:21:01 homeassistant hass[21793]: telegram.error.BadRequest: \"Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 6\"\r\n```\r\n\r\n**Additional info:**\r\n**Workaround**: Add a ```_``` to the template. Which only works if I don't add entity_ids as triggers with even number of ```_```.  \r\nI believe [line 116](https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/notify/telegram.py#L116) is part of the problem.\r\n"},"comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments/265482075","html_url":"https://github.com/home-assistant/home-assistant/issues/4560#issuecomment-265482075","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/4560","id":265482075,"user":{"login":"DuckY1987","id":16365083,"avatar_url":"https://avatars.githubusercontent.com/u/16365083?v=3","gravatar_id":"","url":"https://api.github.com/users/DuckY1987","html_url":"https://github.com/DuckY1987","followers_url":"https://api.github.com/users/DuckY1987/followers","following_url":"https://api.github.com/users/DuckY1987/following{/other_user}","gists_url":"https://api.github.com/users/DuckY1987/gists{/gist_id}","starred_url":"https://api.github.com/users/DuckY1987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DuckY1987/subscriptions","organizations_url":"https://api.github.com/users/DuckY1987/orgs","repos_url":"https://api.github.com/users/DuckY1987/repos","events_url":"https://api.github.com/users/DuckY1987/events{/privacy}","received_events_url":"https://api.github.com/users/DuckY1987/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T15:44:53Z","updated_at":"2016-12-07T15:44:53Z","body":"Hmm... i have kind of a similar problem i guess: \r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/concurrent/futures/thread.py\", line 54, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/usr/local/lib/python3.4/dist-packages/homeassistant/core.py\", line 1045, in execute_service\r\n    service_handler.func(service_call)\r\n  File \"/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/__init__.py\", line 110, in notify_message\r\n    notify_service.send_message(**kwargs)\r\n  File \"/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/telegram.py\", line 122, in send_message\r\n    parse_mode=parse_mode)\r\n  File \"/root/.homeassistant/deps/telegram/bot.py\", line 124, in decorator\r\n    result = func(self, *args, **kwargs)\r\n  File \"/root/.homeassistant/deps/telegram/bot.py\", line 150, in decorator\r\n    result = self._request.post(url, data, timeout=kwargs.get('timeout'))\r\n  File \"/root/.homeassistant/deps/telegram/utils/request.py\", line 205, in post\r\n    **urlopen_kwargs)\r\n  File \"/root/.homeassistant/deps/telegram/utils/request.py\", line 132, in _request_wrapper\r\n    resp = self._con_pool.request(*args, **kwargs)\r\n  File \"/usr/lib/python3/dist-packages/urllib3/request.py\", line 72, in request\r\n    **urlopen_kw)\r\n  File \"/usr/lib/python3/dist-packages/urllib3/request.py\", line 135, in request_encode_body\r\n    **urlopen_kw)\r\nTypeError: urlopen() got multiple values for keyword argument 'body'\r\n```\r\n\r\nI can not figure out how to get telegram in general working, might be connected i didn't want to open another issue, before it is clear."}}
{"actor":{"display_login":"DuckY1987"}}