Friendly_name is being reverted when set via states API

Hi Everyone,

I’m setting up a Node-RED flow to set the friendly_name of my SeventeenTrack packages (because It really clutters up the UI when they’re all prefixed with 'Seventeentrack Package: ')

Currently I’m trying to do this via a POST to the HTTP States API - something like:

POST /api/states/sensor.seventeentrack_package_mypackage
{"state":"[Entity's Current State]","attributes":{"friendly_name":"mypackage"}}

The call initially succeeds and updates the name shown in the UI, but it reverts about 10 seconds later. I’m also not seeing any changes being made to the entities in .storage/core.entity_registry, which are made when changing the Friendly Name directly via the UI (which does persist).

Has anyone got any ideas as to how I can get the changes to persist? Also open to any alternate ways of doing this (which don’t involve manually setting the name in the UI)

I’ve also tried using the same method for the Coronavirus sensors, which also revert, so it doesn’t appear to be limited to one integration.

Thanks!

1 Like

Look at using entity_namespace

Hi David - I’ve had a look at the documentation, but I’m not sure how entity_namespace affects the Friendly name of the entity?

here’s an example

sensor:
  - platform: sun2
    monitored_conditions:
      - solar_midnight
      - astronomical_dawn
      - nautical_dawn
      - dawn
      - sunrise
      - solar_noon
      - sunset
      - dusk
      - nautical_dusk
      - astronomical_dusk
      - daylight
      - civil_daylight
      - nautical_daylight
      - astronomical_daylight
      - night
      - civil_night
      - nautical_night
      - astronomical_night
      - elevation
      - max_elevation
    entity_namespace: solar

With that, all entities look like this:


So they get grouped together.

But maybe I’m mistaken and that’s not what you want?

Looking at this:

POST /api/states/sensor.seventeentrack_package_mypackage

If you DON’T want seventeentrack_package why are you setting that as the name of the sensor? Or do you just want the friendly name changed? Customize should do that

I’m not seeing this behaviour here on core-2024.1.2, so maybe it got fixed along the way. friendly_name seems to stick nicely.

Have to eat my words here; they still disappear, but only much later/on a restart.
The solution that I went with now uses template-sensors as permanent placeholders.

I’m having this same issue … I set a new friendly_name via the REST API and the old name comes back.