nordpool icon indicating copy to clipboard operation
nordpool copied to clipboard

Add option to define unique_id in yaml

Open Pave87 opened this issue 1 year ago • 3 comments

Added option for user to configure unique_id that is used as entity id. This can help people who use Nordpool sensor in alot of places.

Pave87 avatar Oct 15 '24 06:10 Pave87

Added some documentation of this to README.md

Will look into making tests for this but might take some as very new to Python and Home Assistant components.

Pave87 avatar Oct 16 '24 16:10 Pave87

Why is this still pending? I would really much like this to be added to next release.

koopee avatar Nov 08 '24 08:11 koopee

This seems like quite an important thing to have. For UI configuration the README recommends renaming the device, but for YAML configuration there's no way.

sim642 avatar Jan 01 '25 13:01 sim642

This goes against HA design principles, unique_id should not be user changeable

https://www.home-assistant.io/faq/unique_id/#can-i-add-a-unique-id-myself https://developers.home-assistant.io/docs/entity_registry_index?_highlight=unique_id#unique-id

WebSpider avatar Oct 08 '25 11:10 WebSpider

Thanks for the links and reference to the principles, which are very understandable. However I think the nordpool sensor is a bit borderline case. I think unique_id is supposed to keep things static, but in nordpool case when VAT changes the sensor id also changes and things are not static anymore.

I would very much like an option for the nordpool sensor that would just provide me an easy "finnish nordpool price inclusive VAT" -unique id option without having to care about changing VATs that cause the need for me to revisit all my nordpool dependent automations if VAT changes again.

Back in 2022-2023 Finnish parlament decided to temporarily lover the electricity Vat from 24% to 10% and 25.5% in September 2024. So I had to refactor my automations three times in those times. Quite a chore because of an "unique_id that is not user selectable" but still changes seemingly arbitrarily.

This goes against HA design principles, unique_id should not be user changeable

https://www.home-assistant.io/faq/unique_id/#can-i-add-a-unique-id-myself https://developers.home-assistant.io/docs/entity_registry_index?_highlight=unique_id#unique-id

koopee avatar Oct 08 '25 15:10 koopee

Note there is a difference between entity_id and unique_id

WebSpider avatar Oct 08 '25 16:10 WebSpider

Note there is a difference between entity_id and unique_id

Good point, thanks! Maybe entity_id would work as well. Still, I think nordpool unique_id definition maybe should not change if Vat changes. At least for me the unique_id change does not make much sense.

https://github.com/custom-components/nordpool/blob/8ed34837fe315b74ad72434225cc843a0083cb56/custom_components/nordpool/sensor.py#L203-L212

koopee avatar Oct 08 '25 18:10 koopee

Thanks for the links and reference to the principles, which are very understandable. However I think the nordpool sensor is a bit borderline case. I think unique_id is supposed to keep things static, but in nordpool case when VAT changes the sensor id also changes and things are not static anymore.

I would very much like an option for the nordpool sensor that would just provide me an easy "finnish nordpool price inclusive VAT" -unique id option without having to care about changing VATs that cause the need for me to revisit all my nordpool dependent automations if VAT changes again.

These VAT changes are exactly reason why I did this. I know my solution here is a bit hack. But having entity id staying same after sensor has been created makes sense.

Pave87 avatar Oct 14 '25 09:10 Pave87