Repository: home-assistant/core
File: homeassistant/components/netatmo/data_handler.py (Python)

Code before:

            self.setup_climate_schedule_select(home, signal_home)
            self.setup_rooms(home, signal_home)
            self.setup_modules(home, signal_home)

            self.hass.data[DOMAIN][DATA_PERSONS][home.entity_id] = {
                person.entity_id: person.pseudo for person in home.persons.values()
            }

        await self.unsubscribe(WEATHER, None)
        await self.unsubscribe(AIR_CARE, None)

    def setup_air_care(self) -> None:
        """Set up home coach/air care modules."""
        for module in self.account.modules.values():
            if module.device_category is NetatmoDeviceCategory.air_care:
                async_dispatcher_send(
                    self.hass,
                    NETATMO_CREATE_WEATHER_BINARY_SENSOR,
                    NetatmoDevice(
                        self,
                        module,
                        AIR_CARE,
                        AIR_CARE,
                    ),
                )
                async_dispatcher_send(
                    self.hass,
                    NETATMO_CREATE_WEATHER_SENSOR,
                    NetatmoDevice(
                        self,
                        module,
                        AIR_CARE,
                        AIR_CARE,
                    ),
                )

    def setup_modules(self, home: pyatmo.Home, signal_home: str) -> None:
        """Set up modules."""
        netatmo_type_signal_map = {
            NetatmoDeviceCategory.camera: [
                NETATMO_CREATE_CAMERA,
                NETATMO_CREATE_CAMERA_LIGHT,
            ],
            NetatmoDeviceCategory.dimmer: [NETATMO_CREATE_LIGHT],
            NetatmoDeviceCategory.shutter: [
                NETATMO_CREATE_COVER,
                NETATMO_CREATE_BUTTON,
            ],
            NetatmoDeviceCategory.switch: [
                NETATMO_CREATE_LIGHT,

Review comment (suggestion):
Instead of duplicating, do:

```py
for signal in (NETATMO_CREATE_WEATHER_BINARY_SENSOR, NETATMO_CREATE_WEATHER_SENSOR):
    async_dispatcher_send(
        self.hass,
        signal,
        ...,
)
```

Code after:

            self.setup_climate_schedule_select(home, signal_home)
            self.setup_rooms(home, signal_home)
            self.setup_modules(home, signal_home)

            self.hass.data[DOMAIN][DATA_PERSONS][home.entity_id] = {
                person.entity_id: person.pseudo for person in home.persons.values()
            }

        await self.unsubscribe(WEATHER, None)
        await self.unsubscribe(AIR_CARE, None)

    def setup_air_care(self) -> None:
        """Set up home coach/air care modules."""
        for module in self.account.modules.values():
            if module.device_category is NetatmoDeviceCategory.air_care:
                for signal in (
                    NETATMO_CREATE_WEATHER_BINARY_SENSOR,
                    NETATMO_CREATE_WEATHER_SENSOR,
                ):
                    async_dispatcher_send(
                        self.hass,
                        signal,
                        NetatmoDevice(
                            self,
                            module,
                            AIR_CARE,
                            AIR_CARE,
                        ),
                    )

    def setup_modules(self, home: pyatmo.Home, signal_home: str) -> None:
        """Set up modules."""
        netatmo_type_signal_map = {
            NetatmoDeviceCategory.camera: [
                NETATMO_CREATE_CAMERA,
                NETATMO_CREATE_CAMERA_LIGHT,
            ],
            NetatmoDeviceCategory.dimmer: [NETATMO_CREATE_LIGHT],
            NetatmoDeviceCategory.shutter: [
                NETATMO_CREATE_COVER,
                NETATMO_CREATE_BUTTON,
            ],
            NetatmoDeviceCategory.switch: [
                NETATMO_CREATE_LIGHT,
                NETATMO_CREATE_SWITCH,
                NETATMO_CREATE_SENSOR,
            ],
            NetatmoDeviceCategory.meter: [NETATMO_CREATE_SENSOR],
            NetatmoDeviceCategory.fan: [NETATMO_CREATE_FAN],
        }