homeassistant-plant icon indicating copy to clipboard operation
homeassistant-plant copied to clipboard

Renaming Plant Device doesn't change Source for DLI/mol

Open trankillity opened this issue 1 year ago • 6 comments

If you rename a plant device and accept the rename of the entities associated with it, the source attribute of the DLI/mol sensors does not update - resulting in broken sensors.

Running the service to reassign the sensors also doesn't appear to work for these entity types as I believe that's updating the external_sensor attribute for other sensors.

The DLI sensor
The DLI sensor
The mol sensors
The mol sensors that should be attached

trankillity avatar Mar 21 '23 03:03 trankillity

Same here

Knobiwahn avatar Jul 10 '23 19:07 Knobiwahn

I'll look into this. I am not sure the integration gets any notification when the entities changes, but I might be able to run a periodic job to make sure the surce for the DLI is correct.

Olen avatar Aug 01 '23 06:08 Olen

Same here

danceoversun avatar Oct 29 '23 09:10 danceoversun

me too

hermanops avatar Nov 02 '23 23:11 hermanops

Me-toos does not help. You may subscribe to the issue, or even better - create a PR.

Olen avatar Nov 03 '23 06:11 Olen

I was curious so I looked up how to do this. I think rather than storing the entity ID as provided by the user, you could look up the entity by entity_id and then get and store unique information about it to look up later. Here's a quick example that goes full circle:

er = entity_registry.async_get(hass)
entity = er.async_get('sensor.foobar')
entity_id = ent_reg.async_get_entity_id(entity.domain, entity.platform, entity.unique_id)

So you'd want to look up the entity object via the entity_id supplied by the user and then store domain, platform, and unique_id of the entity. Then when updating the sensor you'd use those 3 values to get the entity_id and then look up the state using that.

ScottG489 avatar May 21 '24 02:05 ScottG489