diogopms
(Diogo)
June 4, 2021, 12:57pm
1
Hi, I would like to know if it’s possible to use ONLY Esphome to do an HTTP Get to a rest API and save the JSON response in a sensor state so this can be manipulated in a display.
curl -s https://api.coindesk.com/v1/bpi/currentprice.json | jq ".bpi.EUR"
{
"code": "EUR",
"symbol": "€",
"rate": "30,494.8974",
"description": "Euro",
"rate_float": 30494.8974
}
References:
Troon
(Troon)
June 4, 2021, 1:06pm
2
Not out-of-the-box: the only information you get back is the status code. See here for guidance:
I managed to make it work.
I dismissed the visual track for on / off so that I had no synchronization problems. It also prevents needless relay activation.
How I dit it:
globals:
- id: nanoState
type: bool
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
id: button_1
on_press:
then:
- lambda: |-
HTTPClient http;
http.begin("http://192.168.1.74:16021/api/v1/myauthtoken/state/on");
…
It’d be much easier to do the request in HA and publish that value to your ESPHome node.