Hi syssi,
how do you send the weather-icon via Telegram. Thank you.
Hi syssi,
how do you send the weather-icon via Telegram. Thank you.
This is the automation:
- alias: 'Telegram bot that provides a weather forecast'
trigger:
platform: event
event_type: telegram_command
event_data:
command: '/weather'
action:
- service: telegram_bot.send_photo
data_template:
target: '{{ trigger.event.data.user_id }}'
disable_notification: true
file: '/home/homeassistant/.homeassistant/www/climacons/{{ states.sensor.dark_sky_icon.state }}.png'
caption: '{{ states.sensor.dark_sky_summary.state }}'
- service: telegram_bot.send_message
data_template:
target: '{{ trigger.event.data.user_id }}'
disable_notification: true
message: '{{ states.sensor.dark_sky_hourly_summary.state }} {{ states.sensor.dark_sky_daily_summary.state }}'
This is the used icon set: http://adamwhitcroft.com/climacons/
this is nice thank you very much.
cool, thank you
@anon43302295 thats odd, the documentation requires it to be in a string format. @Will711990 can you post the error that the automation posts to the log?
Yeah, I think @Will711990 is saying itās arriving as a string, but it has added single quotes that need stripping off?
Oh, thats ridiculous! I hate when software does that.
Should be able to replace the characters, for safety, we will remove both types of quotes:
- service: input_datetime.set_datetime
entity_id: input_datetime.YOUR _ALARM_CLOCK
data_template:
time: "{{ trigger.event.data.args | replace('\'', '') | replace('\"','') }}"
So the slashes are needed to let the software know you want the character that follows the slash. This has to be done because the parser will think itās the end of the string instead of being a character inside the string.
The code is essentially replacing ā with nothing and " with nothing. Should be all instances of each character as well.
Amen
Hopefully thatāll fix it
It is possible that the args is returning a datetime object and when it prints, it displays it as a string. In that case, youād need to use strftime. It really depends on what the error is
Thank you to spend time to help me, thatās very cool from youā¦!
The error is:
Invalid service data for input_datetime.set_datetime: Invalid time specified: ['06:45:00'] for dictionary value @ data['time']. Got "['06:45:00']"
thats odd, it shouldnāt be a list. Try
time: "{{ trigger.event.data.args[0] }}"
OMG that worksā¦
Thank you so so much, you reeeeaaaaaalllyyyy rock !!!
How can we setup the config.yaml with a chat ID if we havent yet made contact with the bot? Dont we need the Bot running first so we can chat to it and then get the ID? Or do we put a fake allowed_chat_id in the config until we find out what our real one is? seems a bit chicken before the eggā¦
I think you deleted your question, but I think it was valid! It stopped me progressing for a while until I figured that part out.
The chat_id is totally seperate from Home Assistant, you need to start a conversation between you and the bot and get the ID of that particular conversation/chat thread. Thatās a Telegram thing. You take that ID and it tells HA which conversation to post messages to.
Yeah, I removed my question after I figured it out. My issue was that the docs make it seem like you need to get the Chat ID from the Bot that we create in HA (which obviously isnāt set up yet at that point), but I ended up getting my Chat ID from Telegram by sending a message to @get_id_bot. Iām hoping that is correct and that things workā¦ Iāll hopefully try it out today.
Hmmā¦ ok, so rereading your reply, I need the chat ID of a particular chat between me and MY botā¦ but my bot isnt running until I complete the setup entry in config.yaml which cant be done without allowed_chat_idāsā¦
currently I get no reply if I send a message to MY bot
Thank you for sharing, just when I thought the sleepless nights had ended
The simplest way IMAO was:
FYI: Iām using Android.