jekalmin / extended_openai_conversation

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

Not being able to locate entities #182

Closed Technically-Possible closed 3 months ago

Technically-Possible commented 3 months ago

Hello,

I hope this message finds you well. I am experiencing some trouble with my system as it doesn't seem to be able to read the state of entities or even list the entities it can see. I was wondering if you could provide some assistance in fixing this issue.

Thank you so much for your help in advance. I appreciate it.

Technically-Possible commented 3 months ago

Screenshot_20240326-005912.png

emanuelbaltaretu commented 3 months ago

Hi! GPT does not know how to get the temperature, you must tell him what to use.

For example in my case it was trying to do button.turn_on and other things so i added this line in the prompt template: For buttons use input_button.entity_name.press You must be very clear, at first i had only input_button.press and sometimes he was trying to call it like a function or something so i added entity name in the middle, so far he has not tried to press a button some other way. This is assuming you did expose from the GUI the sensor for the assistant.

Technically-Possible commented 3 months ago

I have exposed them and added this to the prompt "I want you to act as smart home manager of Home Assistant. I will provide information of smart home along with a question, you will truthfully make correction or answer using information provided in one sentence in everyday language.

Current Time: {{now()}}

Available Devices:

entity_id,name,state,aliases
{% for entity in exposed_entities -%}
{{ entity.entity_id }},{{ entity.name }},{{ entity.state }},{{entity.aliases | join('/')}}
{% endfor -%}

For Tempture of rooms use sensors, for basement use sensor.basement_sensors, for bathroom use sensor.bathroom_sensor_2, for kitchen use sensor.kitchen_sensors_4,for office use sensor.office_sensors_3 . The current state of devices is provided in available devices. Use execute_services function only for requested action, not for current states. Do not execute service without user's confirmation. Do not restate or appreciate what user says, rather make a quick inquiry."

However I am still getting image This

Technically-Possible commented 3 months ago

Got it had to input it like this Here's the current temperature information for each room:

Here's the current humidity information for each room:

emanuelbaltaretu commented 3 months ago

Glad it worked. In the future you might want to rewrite that in less tokens as you give gpt more instructions. I asked mine how it got the temperature and he said he used a function i provided image

Here is the function:

- spec:
    name: get_attributes
    description: Get attributes of any home assistant entity
    parameters:
      type: object
      properties:
        entity_id:
          type: string
          description: entity_id
      required:
      - entity_id
  function:
    type: template
    value_template: "{{states[entity_id]}}"

This should be fewer tokens, work with future sensors you might add and other entities you will connect in the future

Technically-Possible commented 3 months ago

with these functions do i just copy that and paste it under the one that was already there?

emanuelbaltaretu commented 3 months ago

image

Technically-Possible commented 3 months ago

Fab <3 Thank you so much

jekalmin commented 3 months ago

Thanks for reporting an issue.

You can also try this prompt which categorizes entities by zone.

Things like sensor.get_temperature or sensor.update is what LLM does oddly. I added below prompt to prevent LLM calling these odd functions, but it sometimes does that.

Use execute_services function only for requested action, not for current states