Aap
(Stef)
September 3, 2018, 5:47pm
1
I tried the following code in known_devices.yaml, but get an empty white circle, whatever the state is.
stef:
name: Stef
hide_if_away: false
icon:
mac:
picture: >-
{% if is_state(‘device_tracker.stef’, ‘Home’) %}
https://www.home-assistant.io/images/favicon-192x192.png
{% else %}
https://www.home-assistant.io/images/favicon-192x192.png
{% endif %}
track: true
best regards, Stef
Aap
(Stef)
September 3, 2018, 5:48pm
2
sorry didn’t quote the code correctly
stef:
name: Stef
hide_if_away: false
icon:
mac: 3C:BB:FD:1F:3F:F0
picture: >-
{% if is_state('device_tracker.stef', 'Home') %}
https://www.home-assistant.io/images/favicon-192x192.png
{% else %}
https://www.home-assistant.io/images/favicon-192x192.png
{% endif %}
track: true
petro
(Petro)
September 4, 2018, 11:55am
3
If you are using lovelace, you can do it with a picture-entity card:
If you are using the normal UI, the easiest way to do this is with a template sensor. Hide the device tracker and make a template sensor that points to the device tracker state attribute. Then use logic in the entity_picture_template config option.
sensor:
- platform: template
sensors:
stef:
friendly_name: Stef
value_template: "{{ states('device_tracker.stef') }}"
entity_picture_template: >
{% if is_state('device_tracker.stef', 'Home') %}
https://www.home-assistant.io/images/favicon-192x192.png
{% else %}
https://www.home-assistant.io/images/favicon-192x192.png
{% endif %}
Aap
(Stef)
September 5, 2018, 7:44am
4
Thanks very much Petro,
works great,
one small improvement: “name” should be “friendly_name”
cheers, Stef
1 Like