Skip to content

Commit

Permalink
Improve error proofing. Ensure list as input.
Browse files Browse the repository at this point in the history
  • Loading branch information
SirGoodenough committed Sep 24, 2023
1 parent 79927a2 commit 7e366eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you cannot see templates in your HACS listing, you *may* need to enable 'expe

# Availability Test

## `avail([entity1, ...])`
## `avail([entity1, entity2, /])`

This expects a list of entities.

Expand Down
5 changes: 4 additions & 1 deletion availability_template.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
{% from 'availability_template.jinja' import avail %}
{{- avail(['entity_1','entity_2']) | bool -}}
#}
{%- if entity_list is iterable -%}
{# First tests to make sure this is a list #}
{%- if entity_list is iterable and
(entity_list is not string and entity_list is not mapping)
-%}
{{- entity_list | map('states') | reject('in', ['unknown','unavailable','','none'])
| list | count == entity_list | count -}}
{%- else -%}
Expand Down

0 comments on commit 7e366eb

Please sign in to comment.