leon3011
(Leon Zuleger)
January 3, 2023, 2:10pm
1
Hello,
i have esphome with a DHT22 sensor and i want to save the data with one request in influxdb.
At the moment im only able to save either the temperature or the humidity with one request:
sensor:
- platform: dht
model: DHT22
pin: D1
temperature:
id: temp
name: "Living Room Temperature"
on_value:
then:
- http_request.post:
url: http://192.168.178.4:8086/api/v2/write?org=main&bucket=tmp
headers:
Authorization: 'Token x'
body: !lambda |-
char buf[64];
sprintf(buf, "%0.1f", id(temp).state);
return ((std::string) "dht22,device_key=0001,room=livingroom temperature="+buf).c_str();
humidity:
name: "Living Room Humidity"
update_interval: 60s
If i also want to save the humidity i would have to create a second on_value
with nearly the same config i have in temperature but this would also result in a second post request.
Is it somehow possible to send one request with both values? E.g. one on_value
for both sensors?
illoo
(illoo)
January 5, 2023, 7:14pm
2
interval:
- interval: 1min
then:
- http_request.post:
url: !lambda |-
char buf1[64];
char buf2[64];
sprintf(buf1, "%0.1f", id(hum).state);
sprintf(buf2, "%0.1f", id(temp).state);
return ((std::string) "https://api.thingspeak.com/update?api_key=1234567890234567&field1=" + buf1 + "&field2=" + buf2).c_str();
91JJ
(91JJ)
January 12, 2023, 5:07pm
3
I have a similar post but using the Nabu Casa URL.
My aim was to be able to send info from all the sensors… Could this be replicated?
Ok… So I managed to get this working both locally and via the Nabu Casa URL.
It would be useful if this was more integrated with the API and/or Logger (?) so you could define the URL.
This method works great but as you can probably tell - I’m not too familiar with ESP … yet.
Use:
To send data to Home Assistant via Nabu Casa ’s remote access (or other alterative) from any ESP device that has a WiFi connection.
This means you can connect to any WiFi network and send updates remotely.
Requirem…
Hi,
Can you please post your final code, I used it like this, but maybe there is a better coding:
body: !lambda |-
char buf1[64];
char buf2[64];
char buf3[64];
sprintf(buf1, "%0.1f", id(temp).state);
sprintf(buf2, "%0.1f", id(temp2).state);
sprintf(buf3, "%0.1f", id(temp3).state);
return ((std::string) "temperature,device=TEST,id=1 value="+buf1 + "\n" + "temperature,device=TEST,id=2 value="+buf2 + "\n" + "temperature,device=TEST,id=3 value="+buf3 ).c_str();
Many thanks!