INNER CODE UNIT · Python

async_setup_entry

dummylabs/thewatchman · custom_components/watchman/button.py:54

async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback
) -> None:
    """Set up the button platform."""
    ent_reg = er.async_get(hass)
    button_key = "report_button"
    new_uid = f"{DOMAIN}_{button_key}"

    # migration logic
    # fixing the bug in WM prior to 8.x where sensor uids were generated using entry uid
    old_uid = f"{config_entry.entry_id}_{DOMAIN}_{button_key}"
    await update_or_cleanup_entity(ent_reg, "button", DOMAIN, old_uid, new_uid)

    # fix for duplicated domain uid, introduced by first dev versions of 0.8
    dub_uid = f"{DOMAIN}_{DOMAIN}_{button_key}"
    await update_or_cleanup_entity(ent_reg, "button", DOMAIN, dub_uid, new_uid)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…