So I’ve read over the documentation on service calls and more specifically the part where it refers to response_variable for service calls. Attached is my current non working script. For context, I’m trying to take a prompt and use that prompt in the generate_image service. Then using the url that gets returned by that service I’m trying to pass said url through the response variable and then using a second service to write the url to an input_text to display it in a picture entity. The generate_image service runs fine, but I’m having trouble successfully passing the imageurl variable to the second service.
I already know it’s going to be something with my syntax or usage of the variable. Thanks for any help you may be able to give
So my first mistake was using an input_text. The largest possible is 255 chars, and the urls that the service returns are 512. I should have read the docs on that. Now my issue is, I have no idea how to capture the response url from the service call.
automation:
- alias: "Update image when weather changes"
trigger:
- platform: state
entity_id: weather.home
action:
- alias: "Ask OpenAI to generate an image"
service: openai_conversation.generate_image
response_variable: generated_image
data:
config_entry: f29e6b8696a15e107b4bd843de722249
size: 512
prompt: >-
New York when the weather is {{ state("weather.home") }}"
- alias: "Send out a manual event to update the image entity"
event: new_weather_image
event_data:
url: '{{ generated_image.url }}'
template:
- trigger:
alias: "Update image when a new weather image is generated"
platform: event
event_type: new_weather_image
image:
name: "AI generated image of New York"
url: "{{ trigger.event.data.url }}"
I’m confused because this doesn’t follow the format of any automation YAML that I’ve seen before, and when adding the template portion, that throws an error saying extra keys not allowed. So I don’t exactly know where this example configuration would go.
There are more than 1000 posts on this forum most days, and the number of users who actively answer questions is a very small percentage of the total forum membership. These are often the same users who actively answer questions on other outlets like Facebook, Reddit, and Discord. It is very easy for a thread to fall low enough down the list that it gets missed. This is especially true when you are asking about a new feature on the day it is released; and, the integration in question requires an account with a third party…
It is the convention of the official docs to post YAML examples as-if they are being set up in configuration.yaml. It is also the unofficial/unenforced convention in this forum. That is what is going on in the example you posted.