Zimer
(Amit Zimerman)
January 8, 2018, 7:21pm
1
Hi,
I configured a DHT22 sensor through my pi zero GPIO and configured it as follows:
- platform: dht
name: 'dht_sensor'
sensor: DHT22
pin: 4
monitored_conditions:
- temperature
- humidity
Now I’m trying to send the temperature as a response to Telegram /temp command with no success.
I tried many automation configurations (including templated) with no success
this is only one example:
service: notify.telegram_test
data:
message: states.sensor.dht.temprature.state
what am I doing wrong?
Thanks
P.S
what is the tag for inserting code snippet?
```
(backticks)
You need the sensor code enclosed in brackets, so your message line will be
message: '{{states.sensor.dht.temprature.state}}'
Zimer
(Amit Zimerman)
January 9, 2018, 7:10am
3
Thanks,
I used the brackets with many different parameters that didn’t work.
After more reading I managed to find this post:
sensor:
- platform: dht
sensor: DHT22
pin: 4
**name: temperature**
temperature_offset: -1
humidity_offset: 0
monitored_conditions:
- temperature
Try taking the “name: temperature” line out of your sensor definition.
Allow the DHT module to name them, and you’ll have a sensor called:
sensor.dht_sensor_temperature
Try the automation then.
with one comment suggesting to remove the “name” field and referring the sensor as:
dht_sensor_temperature (or humidity)
Now it works like a charm.
- alias: 'Telegram get temp inline'
hide_entity: true
trigger:
platform: event
event_type: telegram_callback
event_data:
data: '/temp'
action:
service: notify.telegram_test
data:
message: '{{ states.sensor.dht_sensor_temperature.state}} °C
2 Likes
BnvS
(Sal)
April 12, 2018, 10:00pm
4
Hey all of the above you did, i.e. getting temp in telegram. did you do this in the config file or did you write another script for this?
if you did write a script how to you point the config to go get the script file?