Closed sfstar closed 1 year ago
take for example the following description:
EntsoeEntityDescription( key="current_price", name="Current electricity market price", native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}", value_fn=lambda data: data["current_price"], state_class="measurement" ),
this will currently cause the entity_id used by end-user to be either:
sensor.current_price
or sensor.<name>_current_price
While originally it was:
sensor.current_electricity_market_price
By approving #50 you would change this back to:
sensor.current_electricity_market_price
or sensor.<name>_current_electricity_market_price
You're right. I merged it now. Thanks!
Reason for using key in there was because the ID name gave an error when using a value with spaces in there. But this works!
Great, thank you for the quick review. Regarding the entity naming, the entity helper file in core seems to have an generate entity_id function that converts and checks the entity name to a pre-defined format (regex). You could consider using this function when determining the entity_id value (would make it a safer integration if input is checked/automatically converted to ha standards.
The 0.1.0 release changes the entity id from it's description.name to the description.key value. Thereby, causing issues for keeping the original entity names (and history) In order to achieve (what i believe you wanted to achieve) you should set
_attr_unique_id
to the original description.key value andself.entity_id
to description.name. Since before my PR (for supporting multiple integrations) theentity_id
property was not set by the integration. Thereby, causing HA to infer thedescription.name
value as the entity id.Anybody upgrading now will not have working dashboards / history afterwards due to the key property != the name property.