joselcaguilar / azure-openai-ha

Azure OpenAI Conversation for Home Assistant
MIT License
43 stars 6 forks source link

Is there a way for this integration to see device and entity changes in real-time? #33

Closed ubersandwich closed 1 year ago

ubersandwich commented 1 year ago

Currently I use this template to read in various entities and their states:

{%- for area in areas() %}
  {%- set entities = area_entities(area) -%}
  {%- set area_info = namespace(printed=false) %}
  {%- if entities -%}
    {%- for entity_id in entities -%}
      {%- set entity_state = states.entity_id -%}
      {%- if entity_state is not none %}
        {%- if not area_info.printed %}
{{ area_name(area) }}:
          {%- set area_info.printed = true %}
        {%- endif %}
- {{ entity_id }}: {{ states(entity_id) }}
      {%- endif %}
    {%- endfor %}
  {%- endif %}
{%- endfor %}

This only updates entity states when the Azure OpenAI integration is reloaded, is there any way for this information to be read by the Azure OpenAI integration in real-time?

joselcaguilar commented 1 year ago

@ubersandwich You need to create a new session with Azure OpenAI unfortunately, because the initial states are read and sent at startup time, it's the same behaviour as the official OpenAI integration.

joselcaguilar commented 1 year ago

@ubersandwich I'm going to close this issue as it is not directly related as explained above, thanks for your feedback 😊