mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-29 22:24:26 +00:00 
			
		
		
		
	Add action response to tests
This commit is contained in:
		| @@ -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<float>(); | ||||
|                   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<float>(); | ||||
|                   ESP_LOGD("main", "Next hour temperature: %f", temperature); | ||||
|                 } else { | ||||
|                   ESP_LOGE("main", "Action failed: %s", response->get_error_message().c_str()); | ||||
|                 } | ||||
|  | ||||
| api: | ||||
|   port: 8000 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user