Person entity_picture based on state

Hi ALl,

I have this part in Lovelace, only problem is its a tracking device.
When I’m at home there state will be home. When im away it will show different states.

How can add something that when its not home then show this image… (The part not_home)

- entity: device_tracker.cenkay_xr
  show_state: false
  show_name: true
  name: iCloud3
  tap_action:
    action: toggle
  state_image:
    not_home: /local/images/person/kay_away.png
    home: /local/images/person/kay_home.png

Cheers,
Peter

Being that I’m trying very hard to learn this… Is this what I want to show a picture instead of my name? Currently it shows John - Home or John - Away… I’d like to use pictures instead.

AND not really sure where to put the above is this is the code I need.

Thank you ALL in advance!!

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

Got it!! Thank you!!! I’ll give it a whack, time to start learning stuff or I’ll never get this to where I want it :slight_smile:

I do some like this:

media_player.android_tv:
  templates:
      entity_picture: >
        {% set app = states.media_player.android_tv.attributes.app_id %}
        /local/img/googletvicons/{{app}}.png

but it don’t work…
I check in developer-tools/template:
{{ states.media_player.android_tv.attributes.entity_picture }}
“UndefinedError: ‘homeassistant.util.read_only_dict.ReadOnlyDict object’ has no attribute ‘entity_picture’”

wrong topic? (this is about person pictures)

and if you got the wrong attribute, you should check the tab next to that, dev tools/states and see in the attributes column which attributes Are available

I use this template…

If there isn’t attribute how can I add new one? It’s Android TV integration.

You can not add an attribute, the integration sets attributes. (Unless you want to customize those )

This topic is about person entities and you ask about media_player entities which are different integrations alltogether.

If you check like I suggested, in dev tools states, you can see which attributes the entity has. En adapt any template to those.