AirTag "integration" (user friendly + device tracker)

The 2.0 version does not use “object”, to avoid issues regarding translations.

However, you are free to modify the shortcut as you want to suit your needs :blush:

This is strange because this is how a fresh shortcut import looks like:

In this part of the guide

  1. Look for the “Call” action with the Home Assistant icon and tap on the arrow icon to expand the details. In the “Server” section, you must select your Home Assistant instance to send the data.

What is the HA instance? how to I selected?

2 Likes

Sure, here is the translation:


Okay, my attempt went better by following the instructions in version 2.0.

However, the guide still says that a sensors.yaml needs to be created, which we had previously mentioned doesn’t work. I tried placing it in the configuration.yaml, and this time HA recognized the sensor, but it appeared like this.

I am also sending the code in case i made an error.

  - platform: rest
    name: airtag_car_geo
    value_template: "{{ value_json.results[0].formatted }}"
    json_attributes_path: "$.results[0]"
    json_attributes:
      - lon
      - lat
    verify_ssl: true
    scan_interval: 900 # every 15 min
    force_update: true
    resource_template: >
      {% set address = states('input_text.airtag').split('*Car')[1].split('•')[0] %}
      {% if address == "Home" %}
        {% set home = "HOME_TEST" %}
        {{
          "https://api.geoapify.com/v1/geocode/search?text="
          + home | urlencode
          + "&apiKey=APIKEY&format=json"
        }}
      {% else %}
        {% set fix = address + "" %}
        {{
          "https://api.geoapify.com/v1/geocode/search?text="
          + fix | urlencode
          + "&apiKey=APIKEY&format=json"
        }}
      {% endif %}

  - platform: template
    sensors:
      airtag_car:
        friendly_name: "Car"
        value_template: >
          {% set home = "Lerou" %} 
          {% if ":" in states('input_text.airtag').split('*Car')[1].split('•')[0] %} 
          {{ states('input_text.airtag').split('*Car')[1].split('•')[0].split(',')[0] }}
          {% elif home in states('input_text.airtag').split('*Car')[1].split('•')[0] %}Home
          {% else %}
          {{ states('sensor.airtag_car_geo') }}
          {% endif %}
        attribute_templates:
          latitude: >
            {% if ":" in states('input_text.airtag').split('*Car')[1].split('•')[0] %}null
            {% else %}{{ state_attr('sensor.airtag_car_geo','lat') }}
            {% endif %}
          longitude: >
            {% if ":" in states('input_text.airtag').split('*Car')[1].split('•')[0] %}null
            {% else %}{{ state_attr('sensor.airtag_car_geo','lon') }}
            {% endif %}
          status: >
            {% if ":" in states('input_text.airtag').split('*Car')[1].split('•')[0] %}unavailable
            {% else %}available
            {% endif %}
          last_update: "{{ as_timestamp(states.input_text.airtag.last_updated)|timestamp_custom ('%d/%m/%Y %H:%Mh') }}"
        icon_template: mdi:car```

further more
image

It does work.

If you haven’t used rest sensor before, you need to fully restart HA, or even load rest platform config through developers tools :blush:

Thank you for taking the time to reply.
Unfortunately even after the restart (I even restarted the whole server) the sensor.airtag has unavailable in State.

Further more the blueprint give the above error. Unknown Action device_tracker.see

and lastly I cannot find it as an entity to add it to map.

Try from Developer Tools / YAML. Then clic on “rest entities”.

I have the Docker Version of the ΗΑ. I cannot edit YAML code in HA.
Can I do something else?

I’m having the same issue. I didn’t have a sensors.yaml file anywhere. I ended up creating a new sensors.yaml file, but now I’m stuck on step five where sensor.airtage_ITEM is supposed to be available. Mine isn’t.

One other noobish question–when replacing ITEM_FINDMY_NAME with the exact name from the Find My app, should it include the asterisk (*) or not? I’ve tried it both ways so far.

For me adding a sensors.yaml did not work. I would suggest just adding the code to your configuration.yaml that worked for me.

The ITEM_FINDMY_NAME is without the asterisk.

Also make sure you reload your configuration at least once after you have done these changes, only then will the sensor.airtage_ITEM start showing.

1 Like

Manage to make it work.
The asterisk was the issue for me. I would suggest to add this info in the Guide.

my issue is that I cannot find a way to add the sensor in the Maps, it doesn’t show in the available entities for the map.

That made the difference. Thank you @john2014!

Actually, I think I spoke too soon.

I keep getting an error in my logs. I’m guessing this is because it’s reading too much from the image and so the text is more than 255 characters. Anyone face this problem? Details from log below.

Logger: homeassistant.components.input_text

Source: components/input_text/init.py:276
integration: Input text (documentation, issues)
First occurred: 1:54:24 PM (14 occurrences)
Last logged: 2:49:29 PM

Invalid value: 2:46 • Shortcuts 'ERRY LN ADIRONDACK DR LAKE PLACID LN DR: PAWTUCKET RD COVENTRY L 3D WALTERS AVE DR KINGSPORT CT CHRISTINA IN HILLCREST LN WELLER LN PFINGSTEN RD CHARTRES DR KEYSTONE RD MILLER RD Items Briefcase Home • Now With You Identify Found Item People Devices Items Me (length range 0 - 255)

It seems to be also taking the text from the streets on the map. You need to crop the screenshot to only take the part where the text of the airtags is. There are some posts about it in this thread, but I found it to be a bit of a trial and error to get the right area for the screenshot.

Did you do a reload of the config? Only then will they start appearing.

Just to remember, you can’t use uppercase or special characters on sensor name. Otherwise It won’t appear

1 Like

Yeah, for those that follow me, here’s what worked for me on iOS: you have to maximize the “Items” pane inside the Find My app, and exit the app just like that. That way, when the shortcut copies the screen image, it’s not picking up all the extraneous map data. As soon as I did this, my input_text.airtag entity started working perfectly. Check.

However, I still can’t get the sensor to reflect “AirTag Location” for its state, and the long/lat attributes remain null. Trying to figure out how to verify geoapify is working properly, but I’ll take any suggestions. In case this helps, see below. I’m getting the last_update to populate so seems like I’m close.

EDIT: I’m seeing the below error in the log with every sensor update–I’m far from a yaml pro but it seems like it’s having a hard time with parsing the text helper – any ideas on how to troubleshoot this? TIA!

Template variable error: list object has no element 1 when rendering ‘{% set address = states(‘input_text.airtag’).split(‘Briefcase’)[1].split(’•‘)[0] %} {% if address == “Home” %} {% set home = “*** StreetAddressRedacted *" %} {{ “https://api.geoapify.com/v1/geocode/search?text=” + home | urlencode + "&apiKey= KeyRedacted &format=json" }} {% else %} {% set fix = address + “” %} {{ “https://api.geoapify.com/v1/geocode/search?text=” + fix | urlencode + "&apiKey= KeyRedacted ***&format=json” }} {% endif %}’

Ok I stuck at the same point with same error. I am not a coder but the code itself seems to me to not doing what is expected. I also have zero requests from the API in goapify statistics, so narrowing down, the requests do not work, then the template is empty.