REST API and unique id

Home Assistant’s REST API documentation shows that you can create an entity and update the state of the entity with just one HTTP POST request to URL POST /api/states/<entity_id>. This works to mostly, but the entities created are lacking “unique id”, which prevents e.g. renaming them from the UI.

I suppose I would need to register the entity somehow, but the REST API documentation does not seem to contain any information on that topic. I would be happy if someone could point me to right direction. Basically, I’m looking a way to create an entity by using the REST API, so that it would be a fully fledged entity. Is that even possible with just REST API?

1 Like

Did you manage to figure this out at all please? I’m having the same issue. I can’t find out how to delete the “test” entities I made whilst poking around in the API :confused: thanks

this thread is getting old, but I’m facing the same thing right now.
Can anyone help on that?

@asgrim, you can delete such entities via an http delete.


1 Like

Also interested in doing this. I am able to create an entity via the REST API, but it doesn’t have a unique ID and is deleted upon a HA restart.

How are you creating it? As an example, here’s one of my sensors:

- platform: rest
  name: "West Midlands carbon intensity"
  unit_of_measurement: 'g/kWh'
  value_template: '{{ }}'
  scan_interval: 600

No unique ID, but HA queries the resource at startup and the sensor is “live” by the time the system has fully come up.

From the rest API directly: /api/states/<entity_id>. I’m trying to create a new entity in HA from another application via the REST API.

I see. Options are to use the HA restart to trigger this application to re-send the state; configure the entity manually in HA YAML and just update via the API; or “mirror” it via an automation into an input_number (or whatever helper type is appropriate) which will survive a reboot.