Person entity_picture based on state

no, its not, this mod is about styling the various parts of the badge.

if you want to use picture thats totally possible of course, in various ways. Here’s what I do:

homeassistant:

  customize:

    person.marijn: &picture
      templates:
        entity_picture: >
          var id = entity.entity_id.split('.')[1].split('_')[0];
          var sensor = 'sensor.' + id + '_picture';
          if (entities[sensor]) return entities[sensor].state;
          return '/local/family/' + id + '_not_home.png';

and use the anchors on all other person entities

and that uses custom-ui (to be able to use templates)

the sensor.*_picture is somewhat complex in my setup,

template:

  - sensor:

      - unique_id: marijn_picture
        state: >-
          {% set id = 'marijn' %}
          {% set state = states('device_tracker.' ~ id ~ '_app') %}
          {% set activity = states('sensor.' ~ id ~ '_app_activity') %}
          {% set zones = states.zone|map(attribute='name')|list %}
          {% if state in zones %} /local/family/{{id}}_zoning.png
          {% elif activity in ['Automotive','Cycling','Walking']
                  and state != 'home'%} /local/family/{{id}}_not_home.png
          {% else %} /local/family/{{id}}_{{state|slugify}}.png
          {% endif %}

but you get the idea.

a simpler variant would be:

        entity_picture: >
          var id = entity.entity_id.split('.')[1];
          return '/local/family/' + id + '_' + state + '.png';

1 Like