If statement in group

Hi,
I currently have a group called “people” which lists the status of Owntracks location data. There are 2 people who live in my house so it will state something like:
Dan: home
Bex: not home

I also have FIND set up which uses WiFi signal strength to determine where your phone is within the house. I have this data listed under the “people” group as well, so the entire group on the dash will say something like:

Dan: home
Bex: not home
Dan: office
Bex: none

I was wondering if it was possible to run an IF statement on this group that says:

if $person is home then display room name
else display not home

Any pointers appreciated.

Templating:

Here is one I use as an example. The state of the sensor is on but I want it to display yes. Not exactly what you’re doing but hopefully will point you in the right direction.

- platform: template
  sensors:
    mike_in_bed:
      value_template: '{% if is_state("binary_sensor.sleepnumber_ile_mike_is_in_bed", "on") %}Yes{% else %}No{% endif %}'
      friendly_name: "Mike is in bed"

Thanks Mike that helped. Have a question in regards to that though. I have done the following:

  - platform: template
    sensors:
      dan_location:
        value_template: '{% if is_state("device_tracker.dan_dans_phone", "home") %}device_tracker.dan_find_location{% else %}Not Home{% endif %}'
        friendly_name: "Dan"

This doesn’t work because the value that should display if I am “home” (device_tracker.dan_find_location), doesn’t. It just displays “device_tracker.dan_find_location” as text rather than the value of device_tracker.dan_find_location. Any idea how to get that to work?

This is what is being displayed. you probably want that to say

'{% if is_state("device_tracker.dan_dans_phone", "home") %}Home{% else %}Not Home{% endif %}'

EDIT: Are you trying to pull in the state of another device.tracker?

Yes indeed.

If I am “home” then my location could be Office / Kitchen / Living Room etc. This value is stored in the entity “device_tracker.dan_find_location”.

The If statement is supposed to look at “device_tracker.dans_dans_phone”, and if it is “home”, then display the value of “device_tracker.dan_find_location”

Well I think we’re both going to learn something new here. I’m not exactly sure how to do that and unfortunately I’m at work so I can’t dive into the research. I will look around as I can but hopefully someone jumps in here with a quick answer.

Actually i think I found something.

Try the code below. You may need to rework the indentation.

{% if is_state('device_tracker.dan_dans_phone', 'home') %}
            {{ states('device_tracker.dan_find_location') }}
          {% else %}
            Not Home
          {% endif %}

That seemed to do the trick! Many thanks

Awesome. No problem, glad I could help.