Skip to content

Add unique_id configuration option#58

Open
pilotak wants to merge 3 commits intomasterfrom
add-unique-id-option
Open

Add unique_id configuration option#58
pilotak wants to merge 3 commits intomasterfrom
add-unique-id-option

Conversation

@pilotak
Copy link
Copy Markdown
Owner

@pilotak pilotak commented Nov 14, 2025

Description

This PR adds support for a configurable unique_id option for attribute sensors. Previously, the unique ID was automatically generated from the entity ID and device ID, but now users can specify a custom prefix.

Changes

  • Added unique_id as an optional configuration parameter
  • When provided, the unique_id is used as a prefix: {unique_id}_{entity_name}_{attribute}
  • Falls back to the original auto-generated format if not specified (backward compatible)
  • Uses CONF_UNIQUE_ID constant from homeassistant.const

Usage Example

sensor:
  - platform: attributes
    unique_id: "my_custom_prefix"
    attribute: battery_level
    entities:
      - sensor.myslipo_1_0
      - sensor.myslipo_2_0

This will create sensors with unique IDs like:

  • my_custom_prefix_myslipo_1_0_battery_level
  • my_custom_prefix_myslipo_2_0_battery_level

Backward Compatibility

✅ Fully backward compatible - existing configurations will continue to work without any changes.

@pilotak pilotak mentioned this pull request Nov 14, 2025
@Tirpitz93
Copy link
Copy Markdown

created the attribute sensor for the versatile_bedroom but ID is still created as sensor.versatile_bedroom_temperature

image firefox_qcrLf0hu9q

@pilotak
Copy link
Copy Markdown
Owner Author

pilotak commented Dec 1, 2025

ok entity ID is not unique ID - that is a different thing. I will have to think about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants