Make text sensor from http

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();
            }

Change the switch to your relay and the interval

text_sensor:
  - platform: template
    name: "Spot Price Status"
    id: spot_price_status

http_request:
  useragent: esphome/device
  verify_ssl: false

interval:
  - interval: 10s
    then:
      if:
        condition:
          wifi.connected:
        then:
          - http_request.get:
              url: http://spotovaelektrina.cz/api/v1/price/get-actual-price-level
              capture_response: true
              on_response:
                - if:
                    condition:
                        lambda: |-
                          return response->status_code == 200;  
                    then:
                      - lambda: |-
                          id(spot_price_status).publish_state(body);
                          if (body == "low") {
                            id(relay).publish_state(true);
                          } else {
                            id(relay).publish_state(false);
                          }

switch:
  - platform: template
    name: "Template Switch"
    optimistic: true
    id: relay