Hello, i need help. How can I make text sensor for ESPHome from this website?
http://spotovaelektrina.cz/api/v1/price/get-actual-price-level
There are only possible four states (low, medium, high and unknown) as text and I need them add as sensor for following automation.
I have tried this from ChatGPT but it is not working
text_sensor:
- platform: http_request
name: "Spot Price Status"
id: spot_price_status
url: "http://spotovaelektrina.cz/api/v1/price/get-actual-price-level"
method: GET
update_interval: 1h
on_response:
then:
- lambda: |-
std::string state = x.c_str();
id(spot_price_status).publish_state(state);
if (state == "low") {
id(relay).turn_on();
} else {
id(relay).turn_off();
}