Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Make helper function is_exposed() more available #207

Open
jleinenbach opened this issue Apr 29, 2024 · 0 comments
Open

Comments

@jleinenbach
Copy link

jleinenbach commented Apr 29, 2024

To reduce tokens, I do not publish all entities in my first prompt.
I would like to be able to filter non-exposed entities, similar to the HA function "is_hidden_entity()"
Please make the helper function is_exposed() more available, not just for sqlite.

This is my non-elegant workaround as sqlite includes this function:

...
        response_variable: filtered_entity_ids
      - type: sqlite
        query: >-
          {% set ns = namespace(exposed_entities = '') %}
          {% set entity_ids = (filtered_entity_ids | from_json) %}
          
          {% for entity_id in entity_ids %}
            {% if is_exposed(entity_id) %}
              {% set ns.exposed_entities = ns.exposed_entities + entity_id + ',' %}
            {% endif %}
          {% endfor %}
          {% if ns.exposed_entities %}
            SELECT '{{ ns.exposed_entities[:-1] }}' AS result;
          {% else %}
            SELECT '' AS result;
          {% endif %}
        response_variable: result
      - type: template
        value_template: >-
          {% if result is defined %}
            {% set json_result = result | tojson %}
            {% set result_value = (json_result | from_json)[0].result | default('', true) | safe %}
          {% else %}
            {% set result_value = '' %}
          {% endif %}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant