As so many, I am playing around - mostly for fun - trying to use OpenAI conversation to actually control entities. It is not too difficult to come up with (or find with google) a prompt that provides some information about entities and entity states and that will return a json formatted HA service call.
When running conversation.process using the official OpenAI Conversation service, this would for example give me the below response. I understand the reason why the response is only in the speech field (and that is fine).
response:
speech:
plain:
speech: >-
{"service": "light.turn_off", "entity_id": "light.light_living_room_local"}
extra_data: null
card: {}
language: en
response_type: action_done
data:
targets: []
success: []
failed: []
conversation_id: xxxxx
What I would like to do now, is to run this in a script and use the response.speech.plain.speech variable to actually execute the service call. I got the feeling this should be trivial, but I just can’t seem to figure out a way to do it. Does someone have an idea?