jekalmin / extended_openai_conversation

Home Assistant custom component of conversation agent. It uses OpenAI to control your devices.
916 stars 129 forks source link

can't use to activate automations #129

Open starschild86 opened 8 months ago

starschild86 commented 8 months ago

hi! i'm trying to create a new automation to get my little one involved into this home assistant adventure :slight_smile: she has a doll and she always asks me "how cute is sorellina?" (the name of her dolly) and i reply her with a number from 1 to 5. i would like to have home assistant to be able to do the same thing leveraging an automation but i'm running into some problems.

i've created an automation like the one below - see yaml below for reference - however it seems that it prioritizes looking the web rather than being the input of the automation and it does reply something along the lines of "i cannot reply this question accurately as i don't have specific information on you or your family" (i translated because i run home assistant and chatgpt in italian)

am i missing something?

thanks a lot, Nicola

alias: piccolezza sorellina
description: ""
trigger:
  - platform: conversation
    command: Quanto è piccola sorellina
condition: []
action:
  - service: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.vlc_telnet
      message: 5
mode: single
starschild86 commented 8 months ago

i was thinking of adding this sentence within the prompt template, does it make sense? If my request matches a command within the automations.yaml file execute the actions within the same ID.

TBTHEDBA commented 8 months ago
- spec:
    name: say_tts_family_room
    description: Say message
    parameters:
      type: object
      properties:
        message:
          type: string
          description: message you want to say on family room wifi.
      required:
      - message
  function:
    type: script
    sequence:
    - service: tts.cloud_say
      data:
        entity_id: media_player.family_room_wifi
        message: "{{message}}"

This is the spec I had to create to get TTS functionality into extended.

starschild86 commented 8 months ago

Thanks! So I guess I will add something like this in the functions section of the integration configuration, do you say something particular to the voice assistant in order to trigger this action instead of other things? Can the speaker be the same as the one you are talking to?

TBTHEDBA commented 8 months ago
service: conversation.process
data:
  agent_id: e817a5bfac9040401e94c5ff9471fc11
  text: Say how cute sorellina is on basement display

Sorry I don't have satellite speakers so I can't test that for you but you can hard code a speaker in (doesn't have to be the speaker mentioned in the spec.

jekalmin commented 8 months ago

Thanks for reporting an issue! I'm quite not sure if I understand it right. Feel free to correct me!

I added following prompt at the end.

If asked about sorellina's cuteness, reply with a number from 1 to 5.

And asked how cute is sorellina? like below.

스크린샷 2024-02-04 오후 9 25 04 스크린샷 2024-02-04 오후 9 25 20

Is this what you wanted? or is there more?

starschild86 commented 8 months ago

That's great! Yes that's perfect for the specific use case. What do you think about my general solution reported here for leveraging existing automations that have a phrase as a trigger? I'm not sure sure if this will break something big 😅

If my request matches a command within the automations.yaml file execute the actions within the same ID.

jekalmin commented 7 months ago

I am quite not sure if this automation is working. I haven't tried conversation trigger yet, but below prompt will not work because we have not passed our automation.yaml file to gpt.

If my request matches a command within the automations.yaml file execute the actions within the same ID.