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 %}
...
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: