custom_components/nea_sg_weather/sensor.py
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Add sensor entities from a config_entry."""
    coordinator: NeaWeatherDataUpdateCoordinator = hass.data[DOMAIN][
        config_entry.entry_id
    ]

    # add area sensor entities
    if "All" in config_entry.data[CONF_SENSORS][CONF_AREAS]:
        entities_list = [
            NeaAreaSensor(coordinator, config_entry.data, area) for area in AREAS
        ]
    else:
        entities_list = [
            NeaAreaSensor(coordinator, config_entry.data, area)
            for area in list(set(config_entry.data[CONF_SENSORS][CONF_AREAS]))
        ]

    # add region sensor entities
    if config_entry.data[CONF_SENSORS][CONF_REGION]:
        entities_list += [
            NeaRegionSensor(coordinator, config_entry.data, region)
            for region in REGIONS
        ]

    # add rainfall sensor entities
    if config_entry.data[CONF_SENSORS][CONF_RAIN]:
        entities_list += [
            NeaRainSensor(coordinator, config_entry.data, rain_sensor_id)
            for rain_sensor_id in coordinator.data.rain.station_list
        ]

    async_add_entities(entities_list)
Add sensor entities from a config_entry.
Add sensor entities from a config_entry.
Add sensor entities from a config_entry .
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    coordinator: NeaWeatherDataUpdateCoordinator = hass.data[DOMAIN][
        config_entry.entry_id
    ]
    if "All" in config_entry.data[CONF_SENSORS][CONF_AREAS]:
        entities_list = [
            NeaAreaSensor(coordinator, config_entry.data, area) for area in AREAS
        ]
    else:
        entities_list = [
            NeaAreaSensor(coordinator, config_entry.data, area)
            for area in list(set(config_entry.data[CONF_SENSORS][CONF_AREAS]))
        ]
    if config_entry.data[CONF_SENSORS][CONF_REGION]:
        entities_list += [
            NeaRegionSensor(coordinator, config_entry.data, region)
            for region in REGIONS
        ]
    if config_entry.data[CONF_SENSORS][CONF_RAIN]:
        entities_list += [
            NeaRainSensor(coordinator, config_entry.data, rain_sensor_id)
            for rain_sensor_id in coordinator.data.rain.station_list
        ]
    async_add_entities(entities_list)
async def async_setup_entry ( hass : HomeAssistant , config_entry : ConfigEntry , async_add_entities : AddEntitiesCallback , ) -> None : coordinator : NeaWeatherDataUpdateCoordinator = hass . data [ DOMAIN ] [ config_entry . entry_id ] if "All" in config_entry . data [ CONF_SENSORS ] [ CONF_AREAS ] : entities_list = [ NeaAreaSensor ( coordinator , config_entry . data , area ) for area in AREAS ] else : entities_list = [ NeaAreaSensor ( coordinator , config_entry . data , area ) for area in list ( set ( config_entry . data [ CONF_SENSORS ] [ CONF_AREAS ] ) ) ] if config_entry . data [ CONF_SENSORS ] [ CONF_REGION ] : entities_list += [ NeaRegionSensor ( coordinator , config_entry . data , region ) for region in REGIONS ] if config_entry . data [ CONF_SENSORS ] [ CONF_RAIN ] : entities_list += [ NeaRainSensor ( coordinator , config_entry . data , rain_sensor_id ) for rain_sensor_id in coordinator . data . rain . station_list ] async_add_entities ( entities_list )
Add sensor entities from a config_entry.
Add sensor entities from a config_entry .
"""Add sensor entities from a config_entry.""" # add area sensor entities # add region sensor entities # add rainfall sensor entities
hass
HomeAssistant
config_entry
ConfigEntry
async_add_entities
AddEntitiesCallback