Fix switch_as_x entity naming (#89992)

* Fix switch_as_x entity naming

* Simplify name logic
This commit is contained in:
Erik Montnemery 2023-03-22 20:24:05 +01:00 committed by GitHub
parent 1ea3312ed4
commit 5948347b6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 148 additions and 84 deletions

View file

@ -21,18 +21,14 @@ async def async_setup_entry(
entity_id = er.async_validate_entity_id(
registry, config_entry.options[CONF_ENTITY_ID]
)
wrapped_switch = registry.async_get(entity_id)
device_id = wrapped_switch.device_id if wrapped_switch else None
entity_category = wrapped_switch.entity_category if wrapped_switch else None
async_add_entities(
[
LightSwitch(
hass,
config_entry.title,
entity_id,
config_entry.entry_id,
device_id,
entity_category,
)
]
)