I get, “Could not render template Harmony Family Activity, the state is unknown” in the logs when HA first comes up and the icons take a varied amount to show up due to the entity not being ready.
- platform: template
sensors:
family_activity:
friendly_name: 'Harmony Family'
entity_id: remote.family_room
value_template: '{{ states.remote.family_room.attributes.current_activity }}'
icon_template: >
{% if is_state_attr('remote.family_room', 'current_activity', 'Dish') %} mdi:satellite-uplink
{% elif is_state_attr('remote.family_room', 'current_activity', 'Xbox') %} mdi:xbox
{% elif is_state_attr('remote.family_room', 'current_activity', 'Roku') %} mdi:alpha-r-box-outline
{% elif is_state_attr('remote.family_room', 'current_activity', 'Blu-ray') %} mdi:disc-player
{% elif is_state_attr('remote.family_room', 'current_activity', 'TV') %} mdi:television-classic
{% elif is_state_attr('remote.family_room','current_activity', 'PowerOff') %} mdi:power-plug-off
{% endif %}
EDIT: I’m sure there is a more elegant solution, but this works;
value_template: >
{% if '' in states.remote.family_room.state %}
'{{ states.remote.family_room.attributes.current_activity }}'
{% endif %}