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.

THANKS!!!

This should do it:

- id: 'telegram_dht22'
  alias: 'Telegram DHT22'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      data: '/comman1'
  action:
    service: notify.your_telegram_notification_here
    data_template:
      callback_query_id: '{{ trigger.event.data.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'
trigger:
  platform: event
  event_type: telegram_command
  event_data:
    command: '/DHT'
action:
  - service: telegram_bot.send_message
    data_template:
      target: '{{ trigger.event.data.user_id }}'
      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:

/DHT

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.