Telegram bot how to Get data from DHT sensor by command

Hello all,

Im new with home assistant and im stuck i just wanna send /comman1 and know the temperature and humidity from my dht22 sensor. The sensor is working and i can comunicate with the bot. But i have no idea how to make the callback; any one can help me? Rpi 3 b with Home Assistant.


This should do it:

- id: 'telegram_dht22'
  alias: 'Telegram DHT22'
    platform: event
    event_type: telegram_command
      data: '/comman1'
    service: notify.your_telegram_notification_here
      callback_query_id: '{{ }}'
      message: " The temperature is: {{ states('sensor_your_dht22_emp_sensor_here') }}°C and the relative humidity is: {{ states('sensor_your_dht22_humid_sensor_here') }}%"

Hello bckfast877,

If you have the Telegram bot setup and communicating with HomeAssistant, then I think this is the Automation that you are looking for:

alias: 'DHT Temp and Humidity'
  platform: event
  event_type: telegram_command
    command: '/DHT'
  - service: telegram_bot.send_message
      target: '{{ }}'
      disable_notification: true
      message: "Temp - {{ states.sensor.dht_temp.state }} F \n
                Humidity - {{ states.sensor.dht_humidity.state }} F \n"

So once you have this setup, in your Telegram Bot you type the command:


You can name the the command anything you like in the automation and in the message section you have to put in your sensor info:

  message: "Temp - {{ states.sensor.your_temp sensor.state }} F \n
            Humidity - {{ states.sensor.your_humidity_sensor.state }} F \n"

And, this should send you the Temp and Humidity, Hope this helps.

@tom_l, dang it you beat me to it.

I adapted it from the famous keyboard example and the callback_query_id: I included may not be valid.