custom_components/best_bottrop_garbage_collection/sensor.py
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Defer sensor setup to the shared sensor module."""

    coordinator = hass.data[DOMAIN]["coordinator"]

    entities: list[BESTBottropSensor] = []

    bgc = BESTBottropGarbageCollectionDates()

    await bgc.get_trash_types()

    for trash_type in bgc.trash_types_json:
        entities.append(
            BESTBottropSensor(
                coordinator,
                config_entry.data["street_name"],
                config_entry.data["street_id"],
                config_entry.data["number"],
                trash_type.get("id"),
                trash_type.get("name"),
            )
        )

    platform = entity_platform.async_get_current_platform()

    _LOGGER.debug("Registering service")

    platform.async_register_entity_service(
        SERVICE_IGNORE,
        {vol.Optional("days", default=2): int},
        SERVICE_IGNORE,
    )

    async_add_entities(entities)
Defer sensor setup to the shared sensor module.
Defer sensor setup to the shared sensor module.
Defer sensor setup to the shared sensor module .
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    coordinator = hass.data[DOMAIN]["coordinator"]
    entities: list[BESTBottropSensor] = []
    bgc = BESTBottropGarbageCollectionDates()
    await bgc.get_trash_types()
    for trash_type in bgc.trash_types_json:
        entities.append(
            BESTBottropSensor(
                coordinator,
                config_entry.data["street_name"],
                config_entry.data["street_id"],
                config_entry.data["number"],
                trash_type.get("id"),
                trash_type.get("name"),
            )
        )
    platform = entity_platform.async_get_current_platform()
    _LOGGER.debug("Registering service")
    platform.async_register_entity_service(
        SERVICE_IGNORE,
        {vol.Optional("days", default=2): int},
        SERVICE_IGNORE,
    )
    async_add_entities(entities)
async def async_setup_entry ( hass : HomeAssistant , config_entry : ConfigEntry , async_add_entities : AddEntitiesCallback , ) -> None : coordinator = hass . data [ DOMAIN ] [ "coordinator" ] entities : list [ BESTBottropSensor ] = [ ] bgc = BESTBottropGarbageCollectionDates ( ) await bgc . get_trash_types ( ) for trash_type in bgc . trash_types_json : entities . append ( BESTBottropSensor ( coordinator , config_entry . data [ "street_name" ] , config_entry . data [ "street_id" ] , config_entry . data [ "number" ] , trash_type . get ( "id" ) , trash_type . get ( "name" ) , ) ) platform = entity_platform . async_get_current_platform ( ) _LOGGER . debug ( "Registering service" ) platform . async_register_entity_service ( SERVICE_IGNORE , { vol . Optional ( "days" , default = 2 ) : int } , SERVICE_IGNORE , ) async_add_entities ( entities )
Defer sensor setup to the shared sensor module.
Defer sensor setup to the shared sensor module .
"""Defer sensor setup to the shared sensor module."""
hass
HomeAssistant
config_entry
ConfigEntry
async_add_entities
AddEntitiesCallback