hope, someone can help me with templating.
ive setup a rest sensor to retrieve current connected teamspeak clients:
sensor:
- platform: rest
scan_interval: 5
resource: http://ts3.example.url:10080/1/?clientlist
verify_ssl: false
headers:
x-api-key: "{{ states('input_text.api') }}"
name: "TS3 Online"
value_template: "{{ value_json.body | map(attribute='client_nickname') | join(', ') }}"
json_attributes:
- body
with these results as attributes:
then i have setup some template sensors for up to 5 online clients generated automatically:
template:
- sensor:
- name: "{{ state_attr('sensor.ts3_online', 'body')[0]['client_nickname'] }}"
unique_id: "ts3_0"
state: "{% if not state_attr('sensor.ts3_online', 'body')[0]['client_nickname'] or state_attr('sensor.ts3_online', 'body')[0]['client_nickname'] == 'serveradmin' %}OFF{% else %}ON{% endif %}"
attributes:
image: /local/images/ts3_{{ state_attr('sensor.ts3_online', 'body')[0]['client_nickname'] }}.jpg
- name: "{{ state_attr('sensor.ts3_online', 'body')[1]['client_nickname'] }}"
unique_id: "ts3_1"
state: "{% if not state_attr('sensor.ts3_online', 'body')[1]['client_nickname'] or state_attr('sensor.ts3_online', 'body')[1]['client_nickname'] == 'serveradmin' %}OFF{% else %}ON{% endif %}"
attributes:
image: /local/images/ts3_{{ state_attr('sensor.ts3_online', 'body')[1]['client_nickname'] }}.jpg
- name: "{{ state_attr('sensor.ts3_online', 'body')[2]['client_nickname'] }}"
unique_id: "ts3_2"
state: "{% if not state_attr('sensor.ts3_online', 'body')[2]['client_nickname'] or state_attr('sensor.ts3_online', 'body')[2]['client_nickname'] == 'serveradmin' %}OFF{% else %}ON{% endif %}"
attributes:
image: /local/images/ts3_{{ state_attr('sensor.ts3_online', 'body')[2]['client_nickname'] }}.jpg
- name: "{{ state_attr('sensor.ts3_online', 'body')[3]['client_nickname'] }}"
unique_id: "ts3_3"
state: "{% if not state_attr('sensor.ts3_online', 'body')[3]['client_nickname'] or state_attr('sensor.ts3_online', 'body')[3]['client_nickname'] == 'serveradmin' %}OFF{% else %}ON{% endif %}"
attributes:
image: /local/images/ts3_{{ state_attr('sensor.ts3_online', 'body')[3]['client_nickname'] }}.jpg
- name: "{{ state_attr('sensor.ts3_online', 'body')[4]['client_nickname'] }}"
unique_id: "ts3_4"
state: "{% if not state_attr('sensor.ts3_online', 'body')[4]['client_nickname'] or state_attr('sensor.ts3_online', 'body')[4]['client_nickname'] == 'serveradmin' %}OFF{% else %}ON{% endif %}"
attributes:
image: /local/images/ts3_{{ state_attr('sensor.ts3_online', 'body')[0]['client_nickname'] }}.jpg
so they got these attributes:
image: /local/images/ts3_rog.jpg
friendly_name: rog
i have tried to use auto-entities to filter out these clients, but im unable to pass the āimageā attributes to use the image as badge image. Currently im trying entity-filter with badge-cards, but the image url does not workā¦only if i type the url directly:
type: entity-filter
entities:
- entity: sensor.template_ts3_0
image: "{{ state_attr('sensor.template_ts3_0', 'image') }}"
state_filter:
- 'ON'
card:
type: custom:badge-card
card_mod:
style: |
div#badges {
display: flex;
justify-content: space-around;
font-size: 1.5em;
}
resulting in an empty badge.
hopefully anyone help me to pass the āimageā attribute to a card, eventually with auto-entities?
thank you!