Mobile App Integration - Renaming Entity IDs

I recently purchased a new Android phone (Pixel 10) for my wife and now we both have the same device model. To avoid confusion, I have renamed my device in the Companion app to "Pixel Chris".

Now I want to recreate all the entity IDs, via the Mobile App integration. When I do so, the entity IDs will be changed to e.g. "sensor.pixel_chris_pixel_10_accent_color"

I do not want the "_pixel_10" appended to all entity ID's, how do I prevent this?

I'm only guessing but if you are using the HA Android app, maybe using the web interface will avoid this.

Thanks for the guess. I am using the web interface to rename the entities.

I don't know of any way to override the ID composition when using "Recreate entity IDs"... but, you could just set up a quick script that uses Spook's Update Entity ID action in a Repeat For each with a templated for_each providing the entities:

sequence:
  - repeat:
      for_each: |
        {{ integration_entities('mobile_app') | select('search','pixel_chris_pixel_10') | list}} 
      sequence:
        - action: homeassistant.update_entity_id  #This is a custom action that requires installing the Spook custom integration
          target: {}
          data:
            entity_id: "{{ repeat.item }}"
            new_entity_id: "{{ repeat.item | replace('_pixel_10', '' ) }}"

I'm not sure how it you're using a web browser it can know the name of the device you're using, or is that name stored somewhere in HA? What if you are using a web browser from your PC for example?

There's much I don't understand about HA being so new, but I think there's more to this than that!

This worked great, but does not work on disabled entities. Do you know how to make it run on disabled entities?

It would require a little manual work to apply a Label to all the entities:

  • Go to the Entities dashboard
  • Apply filters so the desired entities are in the list. Add a check to "Disabled" in the Status filters. You can also add a check to "Mobile App" in the Integration filters if you want to be safe.
  • Type your search string ("pixel_chris_pixel_10") into the bar
  • Click the "Enter selection mode" button to the left of the search bar and choose "Select All"
  • On the top right click "Add Label", then create a unique label and apply it to all the entities.

Once they are labelled, you can use a variation on the same script to update the entity IDs... and, while you're at it, you might as well remove the label from the entities:

sequence:
  - variables:
      my_label: YOUR_UNIQUE_LABEL
  - repeat:
      for_each: |
        {{ label_entities(my_label) }} 
      sequence:
        - action: homeassistant.remove_label_from_entity #This is a custom action that requires installing the Spook custom integration
           data:
             label_id: "{{ my_label }}"
           entity_id: "{{ repeat.item }}"
        - delay:
            milliseconds: 100
        - action: homeassistant.update_entity_id  #This is a custom action that requires installing the Spook custom integration
          target: {}
          data:
            entity_id: "{{ repeat.item }}"
            new_entity_id: "{{ repeat.item | replace('_pixel_10', '' ) }}"
  - alias: Enable this action if you want to delete the label completely after the loop finishes
    enabled: false
    action: homeassistant.delete_label
    data:
      label_id: "{{ my_label }}"

Thanks again, you're awesome!