mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Remove unneeded guards from (async_)add_entities call (#80471)
This commit is contained in:
parent
ebf73f41ba
commit
a8f1cc0d33
@ -84,7 +84,6 @@ async def async_setup_entry(
|
||||
unique_id = f"{config_entry.unique_id} {mode}"
|
||||
entities.append(AemetWeather(name, unique_id, weather_coordinator, mode))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities, False)
|
||||
|
||||
|
||||
|
@ -47,7 +47,6 @@ def add_entities(
|
||||
new_tracked.append(AsusWrtDevice(router, device))
|
||||
tracked.add(mac)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked)
|
||||
|
||||
|
||||
|
@ -274,7 +274,6 @@ async def async_setup_entry(
|
||||
)
|
||||
entities.extend(device_entities)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -53,7 +53,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -36,7 +36,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -157,7 +157,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -156,7 +156,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -50,7 +50,6 @@ async def async_setup_entry(
|
||||
# device supports the streamer, so assume so if it does support
|
||||
# advanced modes.
|
||||
switches.append(DaikinStreamerSwitch(daikin_api))
|
||||
if switches:
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
|
@ -55,7 +55,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
tracked.add(station[MAC_ADDRESS])
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
@callback
|
||||
@ -82,7 +81,6 @@ async def async_setup_entry(
|
||||
)
|
||||
tracked.add(mac_address)
|
||||
|
||||
if missing:
|
||||
async_add_entities(missing)
|
||||
|
||||
if device.device and "wifi1" in device.device.features:
|
||||
|
@ -90,7 +90,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
order = DominosOrder(order_info, dominos)
|
||||
entities.append(order)
|
||||
|
||||
if entities:
|
||||
component.add_entities(entities)
|
||||
|
||||
# Return boolean to indicate that initialization was successfully.
|
||||
|
@ -31,7 +31,6 @@ def async_setup_entry_base(
|
||||
added_entities = []
|
||||
for device in devices:
|
||||
added_entities.append(entity_from_device(device, bridge))
|
||||
if added_entities:
|
||||
async_add_entities(added_entities)
|
||||
|
||||
bridge.register_add_devices(platform, async_add_entities_platform)
|
||||
|
@ -148,7 +148,6 @@ def setup_platform(
|
||||
elif sensor_type == SENSOR_TYPE_WINDOWHANDLE:
|
||||
entities = [EnOceanWindowHandle(dev_id, dev_name, SENSOR_DESC_WINDOWHANDLE)]
|
||||
|
||||
if entities:
|
||||
add_entities(entities)
|
||||
|
||||
|
||||
|
@ -40,7 +40,6 @@ async def async_setup_entry(
|
||||
binary_sensor_entity = FirmataBinarySensor(api, config_entry, name, pin)
|
||||
new_entities.append(binary_sensor_entity)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
|
||||
|
@ -46,7 +46,6 @@ async def async_setup_entry(
|
||||
light_entity = FirmataLight(api, config_entry, name, pin)
|
||||
new_entities.append(light_entity)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
|
||||
|
@ -40,7 +40,6 @@ async def async_setup_entry(
|
||||
sensor_entity = FirmataSensor(api, config_entry, name, pin)
|
||||
new_entities.append(sensor_entity)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
|
||||
|
@ -42,7 +42,6 @@ async def async_setup_entry(
|
||||
switch_entity = FirmataSwitch(api, config_entry, name, pin)
|
||||
new_entities.append(switch_entity)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
|
||||
|
@ -122,7 +122,6 @@ async def async_setup_entry(
|
||||
]
|
||||
)
|
||||
|
||||
if flume_entity_list:
|
||||
async_add_entities(flume_entity_list)
|
||||
|
||||
|
||||
|
@ -120,7 +120,6 @@ async def async_setup_entry(
|
||||
]
|
||||
)
|
||||
|
||||
if flume_entity_list:
|
||||
async_add_entities(flume_entity_list)
|
||||
|
||||
|
||||
|
@ -89,7 +89,6 @@ async def async_setup_entry(
|
||||
FluxSpeedNumber(coordinator, base_unique_id, f"{name} Effect Speed", None)
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -81,7 +81,6 @@ async def async_setup_entry(
|
||||
if FLUX_COLOR_MODE_RGBW in device.color_modes:
|
||||
entities.append(FluxWhiteChannelSelect(coordinator.device, entry))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -48,7 +48,6 @@ async def async_setup_entry(
|
||||
FluxMusicSwitch(coordinator, base_unique_id, f"{name} Music", "music")
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -48,7 +48,6 @@ def add_entities(
|
||||
new_tracked.append(FreeboxDevice(router, device))
|
||||
tracked.add(mac)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked, True)
|
||||
|
||||
|
||||
|
@ -65,7 +65,6 @@ def _async_add_entities(
|
||||
new_tracked.append(FritzBoxTracker(avm_wrapper, device))
|
||||
data_fritz.tracked[avm_wrapper.unique_id].add(mac)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked)
|
||||
|
||||
|
||||
|
@ -104,7 +104,6 @@ class FroniusCoordinatorBase(
|
||||
continue
|
||||
new_entities.append(entity_constructor(self, key, solar_net_id))
|
||||
self.unregistered_keys[solar_net_id].remove(key)
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
_add_entities_for_unregistered_keys()
|
||||
|
@ -142,7 +142,6 @@ async def async_setup_entry(
|
||||
elif isinstance(group, AsyncSecurityZoneGroup):
|
||||
entities.append(HomematicipSecurityZoneSensorGroup(hap, device=group))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -51,7 +51,6 @@ async def async_setup_entry(
|
||||
if isinstance(device, AsyncHeatingGroup):
|
||||
entities.append(HomematicipHeatingGroup(hap, device))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -62,7 +62,6 @@ async def async_setup_entry(
|
||||
if isinstance(group, AsyncExtendedLinkedShutterGroup):
|
||||
entities.append(HomematicipCoverShutterGroup(hap, group))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -62,7 +62,6 @@ async def async_setup_entry(
|
||||
):
|
||||
entities.append(HomematicipDimmer(hap, device))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -130,7 +130,6 @@ async def async_setup_entry(
|
||||
entities.append(HomematicpTemperatureExternalSensorCh2(hap, device))
|
||||
entities.append(HomematicpTemperatureExternalSensorDelta(hap, device))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -82,7 +82,6 @@ async def async_setup_entry(
|
||||
if isinstance(group, (AsyncExtendedLinkedSwitchingGroup, AsyncSwitchingGroup)):
|
||||
entities.append(HomematicipGroupSwitch(hap, group))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -64,7 +64,6 @@ async def async_setup_entry(
|
||||
|
||||
entities.append(HomematicipHomeWeather(hap))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -51,7 +51,6 @@ def add_entities(account: IcloudAccount, async_add_entities, tracked):
|
||||
new_tracked.append(IcloudTrackerEntity(account, device))
|
||||
tracked.add(dev_id)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked, True)
|
||||
|
||||
|
||||
|
@ -47,7 +47,6 @@ def add_entities(account, async_add_entities, tracked):
|
||||
new_tracked.append(IcloudDeviceBatterySensor(account, device))
|
||||
tracked.add(dev_id)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked, True)
|
||||
|
||||
|
||||
|
@ -392,5 +392,4 @@ def async_add_insteon_entities(
|
||||
groups = get_platform_groups(device, platform)
|
||||
for group in groups:
|
||||
new_entities.append(entity_type(device, group))
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
@ -154,7 +154,6 @@ async def async_setup_entry(
|
||||
for key in coordinator.data["sensors"]
|
||||
if key not in created
|
||||
]
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
coordinator.async_add_listener(new_data_received)
|
||||
|
@ -64,7 +64,6 @@ async def async_setup_entry(
|
||||
)
|
||||
)
|
||||
|
||||
if restored:
|
||||
async_add_entities(restored)
|
||||
|
||||
async_dispatcher_connect(hass, router.signal_update, update_from_router)
|
||||
@ -79,7 +78,6 @@ def update_items(router: KeeneticRouter, async_add_entities, tracked: set[str]):
|
||||
tracked.add(mac)
|
||||
new_tracked.append(KeeneticTracker(device, router))
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked)
|
||||
|
||||
|
||||
|
@ -87,7 +87,6 @@ async def async_setup_entry(
|
||||
and not new_members_only
|
||||
):
|
||||
new_entities.append(Life360DeviceTracker(coordinator, member_id))
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
process_data(new_members_only=False)
|
||||
|
@ -67,7 +67,6 @@ async def async_setup_entry(
|
||||
),
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -28,7 +28,6 @@ def setup_platform(
|
||||
if device.is_windowshutter():
|
||||
devices.append(MaxCubeShutter(handler, device))
|
||||
|
||||
if devices:
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
|
@ -60,7 +60,6 @@ def setup_platform(
|
||||
if device.is_thermostat() or device.is_wallthermostat():
|
||||
devices.append(MaxCubeClimate(handler, device))
|
||||
|
||||
if devices:
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
|
@ -68,7 +68,6 @@ def update_items(
|
||||
tracked[mac] = MikrotikDataUpdateCoordinatorTracker(device, coordinator)
|
||||
new_tracked.append(tracked[mac])
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked)
|
||||
|
||||
|
||||
|
@ -88,7 +88,6 @@ def setup_platform(
|
||||
departure.get(CONF_TIME),
|
||||
)
|
||||
)
|
||||
if sensors:
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
|
@ -399,7 +399,6 @@ async def async_setup_entry(
|
||||
for device_id in entities.values():
|
||||
device_registry.async_remove_device(device_id)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
async_dispatcher_connect(
|
||||
|
@ -39,7 +39,6 @@ async def async_setup_entry(
|
||||
new_entities.append(NetgearScannerEntity(coordinator, router, device))
|
||||
tracked.add(mac)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
entry.async_on_unload(coordinator.async_add_listener(new_device_callback))
|
||||
|
@ -338,7 +338,6 @@ async def async_setup_entry(
|
||||
)
|
||||
tracked.add(mac)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
entry.async_on_unload(coordinator.async_add_listener(new_device_callback))
|
||||
|
@ -143,7 +143,6 @@ async def async_setup_entry(
|
||||
)
|
||||
tracked.add(mac)
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
entry.async_on_unload(coordinator.async_add_listener(new_device_callback))
|
||||
|
@ -71,7 +71,6 @@ async def async_setup_entry(
|
||||
device_id,
|
||||
)
|
||||
)
|
||||
if new_tools:
|
||||
async_add_entities(new_tools)
|
||||
|
||||
config_entry.async_on_unload(coordinator.async_add_listener(async_add_tool_sensors))
|
||||
|
@ -49,7 +49,6 @@ async def async_setup_entry(
|
||||
|
||||
hass.data[OT_DOMAIN]["context"].set_async_see(_receive_data)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -42,7 +42,6 @@ async def async_setup_entry(
|
||||
logical_load = plum.get_load(device["llid"])
|
||||
entities.append(PlumLight(load=logical_load))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
async def new_load(device):
|
||||
|
@ -55,7 +55,6 @@ def add_new_entities(coordinator, async_add_entities, tracked):
|
||||
new_tracked.append(RuckusUnleashedDevice(coordinator, mac, device[API_NAME]))
|
||||
tracked.add(mac)
|
||||
|
||||
if new_tracked:
|
||||
async_add_entities(new_tracked)
|
||||
|
||||
|
||||
@ -77,7 +76,6 @@ def restore_entities(registry, coordinator, entry, async_add_entities, tracked):
|
||||
)
|
||||
tracked.add(entity.unique_id)
|
||||
|
||||
if missing:
|
||||
async_add_entities(missing)
|
||||
|
||||
|
||||
|
@ -90,7 +90,6 @@ async def async_setup_entry(
|
||||
]
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
|
@ -104,7 +104,6 @@ async def async_setup_entry(
|
||||
"set_temp_offset",
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
|
@ -82,7 +82,6 @@ async def async_setup_entry(
|
||||
]
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
|
@ -75,7 +75,6 @@ async def async_setup_entry(
|
||||
"set_timer",
|
||||
)
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
|
@ -111,7 +111,6 @@ def add_client_entities(controller, async_add_entities, clients):
|
||||
|
||||
trackers.append(UniFiClientTracker(client, controller))
|
||||
|
||||
if trackers:
|
||||
async_add_entities(trackers)
|
||||
|
||||
|
||||
@ -127,7 +126,6 @@ def add_device_entities(controller, async_add_entities, devices):
|
||||
device = controller.api.devices[mac]
|
||||
trackers.append(UniFiDeviceTracker(device, controller))
|
||||
|
||||
if trackers:
|
||||
async_add_entities(trackers)
|
||||
|
||||
|
||||
|
@ -67,7 +67,6 @@ def add_bandwidth_entities(controller, async_add_entities, clients):
|
||||
client = controller.api.clients[mac]
|
||||
sensors.append(sensor_class(client, controller))
|
||||
|
||||
if sensors:
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
||||
@ -83,7 +82,6 @@ def add_uptime_entities(controller, async_add_entities, clients):
|
||||
client = controller.api.clients[mac]
|
||||
sensors.append(UniFiUpTimeSensor(client, controller))
|
||||
|
||||
if sensors:
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
||||
|
@ -124,7 +124,6 @@ def add_block_entities(controller, async_add_entities, clients):
|
||||
client = controller.api.clients[mac]
|
||||
switches.append(UniFiBlockClientSwitch(client, controller))
|
||||
|
||||
if switches:
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
@ -175,7 +174,6 @@ def add_poe_entities(controller, async_add_entities, clients, known_poe_clients)
|
||||
|
||||
switches.append(UniFiPOEClientSwitch(client, controller))
|
||||
|
||||
if switches:
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
@ -193,7 +191,6 @@ def add_dpi_entities(controller, async_add_entities, dpi_groups):
|
||||
|
||||
switches.append(UniFiDPIRestrictionSwitch(dpi_groups[group], controller))
|
||||
|
||||
if switches:
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
@ -213,7 +210,6 @@ def add_outlet_entities(controller, async_add_entities, devices):
|
||||
if outlet.has_relay:
|
||||
switches.append(UniFiOutletSwitch(device, controller, outlet.index))
|
||||
|
||||
if switches:
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
|
@ -64,7 +64,6 @@ def add_device_update_entities(controller, async_add_entities, devices):
|
||||
device = controller.api.devices[mac]
|
||||
entities.append(UniFiDeviceUpdateEntity(device, controller))
|
||||
|
||||
if entities:
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -76,7 +76,6 @@ def async_setup_bridge(
|
||||
known_light_ids.add(light_id)
|
||||
new_lights.append(WemoLight(coordinator, light))
|
||||
|
||||
if new_lights:
|
||||
async_add_entities(new_lights)
|
||||
|
||||
async_update_lights()
|
||||
|
@ -270,5 +270,4 @@ def async_update_segments(
|
||||
current_ids.add(segment_id)
|
||||
new_entities.append(WLEDSegmentLight(coordinator, segment_id))
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
@ -147,5 +147,4 @@ def async_update_segments(
|
||||
for desc in NUMBERS:
|
||||
new_entities.append(WLEDNumber(coordinator, segment_id, desc))
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
@ -195,5 +195,4 @@ def async_update_segments(
|
||||
current_ids.add(segment_id)
|
||||
new_entities.append(WLEDPaletteSelect(coordinator, segment_id))
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
@ -215,5 +215,4 @@ def async_update_segments(
|
||||
current_ids.add(segment_id)
|
||||
new_entities.append(WLEDReverseSwitch(coordinator, segment_id))
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
@ -62,7 +62,6 @@ def async_update_friends(
|
||||
]
|
||||
new_entities = new_entities + current[xuid]
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
# Process deleted favorites, remove them from Home Assistant
|
||||
|
@ -64,7 +64,6 @@ def async_update_friends(
|
||||
]
|
||||
new_entities = new_entities + current[xuid]
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
|
||||
# Process deleted favorites, remove them from Home Assistant
|
||||
|
@ -60,7 +60,6 @@ def setup_platform(
|
||||
continue
|
||||
entities.append(XboxSensor(api, xuid, gamercard, interval))
|
||||
|
||||
if entities:
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user