diff --git a/tests/components/api/common.yaml b/tests/components/api/common.yaml index 4f1693dac8..061282d184 100644 --- a/tests/components/api/common.yaml +++ b/tests/components/api/common.yaml @@ -10,6 +10,36 @@ esphome: data: message: Button was pressed - homeassistant.tag_scanned: pulse + - homeassistant.action: + action: weather.get_forecasts + data: + entity_id: weather.forecast_home + type: hourly + on_response: + - lambda: |- + if (response->is_success()) { + JsonObject json = response->get_json(); + JsonObject next_hour = json["response"]["weather.forecast_home"]["forecast"][0]; + float next_temperature = next_hour["temperature"].as(); + ESP_LOGD("main", "Next hour temperature: %f", next_temperature); + } else { + ESP_LOGE("main", "Action failed: %s", response->get_error_message().c_str()); + } + - homeassistant.action: + action: weather.get_forecasts + data: + entity_id: weather.forecast_home + type: hourly + response_template: "{{ response['weather.forecast_home']['forecast'][0]['temperature'] }}" + on_response: + - lambda: |- + if (response->is_success()) { + JsonObject json = response->get_json(); + float temperature = json["response"].as(); + ESP_LOGD("main", "Next hour temperature: %f", temperature); + } else { + ESP_LOGE("main", "Action failed: %s", response->get_error_message().c_str()); + } api: port: 8000