custom_components/smartthinq_sensors/sensor.py
async def async_setup_sensors(hass, config_entry, async_add_entities, type_binary):
    """Set up LGE device sensors and bynary sensor based on config_entry."""
    lge_sensors = []
    washer_sensors = WASHER_BINARY_SENSORS if type_binary else WASHER_SENSORS
    dryer_sensors = DRYER_BINARY_SENSORS if type_binary else DRYER_SENSORS
    dishwasher_sensors = DISHWASHER_BINARY_SENSORS if type_binary else DISHWASHER_SENSORS
    refrigerator_sensors = REFRIGERATOR_BINARY_SENSORS if type_binary else REFRIGERATOR_SENSORS
    ac_sensors = AC_BINARY_SENSORS if type_binary else AC_SENSORS

    entry_config = hass.data[DOMAIN]
    lge_devices = entry_config.get(LGE_DEVICES, [])

    lge_sensors.extend(
        [
            LGEWasherSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in washer_sensors.items()
            for lge_device in lge_devices.get(DeviceType.WASHER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEDryerSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in dryer_sensors.items()
            for lge_device in lge_devices.get(DeviceType.DRYER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEAcSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in ac_sensors.items()
            for lge_device in lge_devices.get(DeviceType.AC, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEDishWasherSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in dishwasher_sensors.items()
            for lge_device in lge_devices.get(DeviceType.DISHWASHER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGERefrigeratorSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in refrigerator_sensors.items()
            for lge_device in lge_devices.get(DeviceType.REFRIGERATOR, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )

    async_add_entities(lge_sensors, True)
Set up LGE device sensors and bynary sensor based on config_entry.
Set up LGE device sensors and bynary sensor based on config_entry.
Set up LGE device sensors and bynary sensor based on config_entry .
async def async_setup_sensors(hass, config_entry, async_add_entities, type_binary):
    lge_sensors = []
    washer_sensors = WASHER_BINARY_SENSORS if type_binary else WASHER_SENSORS
    dryer_sensors = DRYER_BINARY_SENSORS if type_binary else DRYER_SENSORS
    dishwasher_sensors = DISHWASHER_BINARY_SENSORS if type_binary else DISHWASHER_SENSORS
    refrigerator_sensors = REFRIGERATOR_BINARY_SENSORS if type_binary else REFRIGERATOR_SENSORS
    ac_sensors = AC_BINARY_SENSORS if type_binary else AC_SENSORS
    entry_config = hass.data[DOMAIN]
    lge_devices = entry_config.get(LGE_DEVICES, [])
    lge_sensors.extend(
        [
            LGEWasherSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in washer_sensors.items()
            for lge_device in lge_devices.get(DeviceType.WASHER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEDryerSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in dryer_sensors.items()
            for lge_device in lge_devices.get(DeviceType.DRYER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEAcSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in ac_sensors.items()
            for lge_device in lge_devices.get(DeviceType.AC, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGEDishWasherSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in dishwasher_sensors.items()
            for lge_device in lge_devices.get(DeviceType.DISHWASHER, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    lge_sensors.extend(
        [
            LGERefrigeratorSensor(lge_device, measurement, definition, type_binary)
            for measurement, definition in refrigerator_sensors.items()
            for lge_device in lge_devices.get(DeviceType.REFRIGERATOR, [])
            if definition[ATTR_ENABLED_FN](lge_device)
        ]
    )
    async_add_entities(lge_sensors, True)
async def async_setup_sensors ( hass , config_entry , async_add_entities , type_binary ) : lge_sensors = [ ] washer_sensors = WASHER_BINARY_SENSORS if type_binary else WASHER_SENSORS dryer_sensors = DRYER_BINARY_SENSORS if type_binary else DRYER_SENSORS dishwasher_sensors = DISHWASHER_BINARY_SENSORS if type_binary else DISHWASHER_SENSORS refrigerator_sensors = REFRIGERATOR_BINARY_SENSORS if type_binary else REFRIGERATOR_SENSORS ac_sensors = AC_BINARY_SENSORS if type_binary else AC_SENSORS entry_config = hass . data [ DOMAIN ] lge_devices = entry_config . get ( LGE_DEVICES , [ ] ) lge_sensors . extend ( [ LGEWasherSensor ( lge_device , measurement , definition , type_binary ) for measurement , definition in washer_sensors . items ( ) for lge_device in lge_devices . get ( DeviceType . WASHER , [ ] ) if definition [ ATTR_ENABLED_FN ] ( lge_device ) ] ) lge_sensors . extend ( [ LGEDryerSensor ( lge_device , measurement , definition , type_binary ) for measurement , definition in dryer_sensors . items ( ) for lge_device in lge_devices . get ( DeviceType . DRYER , [ ] ) if definition [ ATTR_ENABLED_FN ] ( lge_device ) ] ) lge_sensors . extend ( [ LGEAcSensor ( lge_device , measurement , definition , type_binary ) for measurement , definition in ac_sensors . items ( ) for lge_device in lge_devices . get ( DeviceType . AC , [ ] ) if definition [ ATTR_ENABLED_FN ] ( lge_device ) ] ) lge_sensors . extend ( [ LGEDishWasherSensor ( lge_device , measurement , definition , type_binary ) for measurement , definition in dishwasher_sensors . items ( ) for lge_device in lge_devices . get ( DeviceType . DISHWASHER , [ ] ) if definition [ ATTR_ENABLED_FN ] ( lge_device ) ] ) lge_sensors . extend ( [ LGERefrigeratorSensor ( lge_device , measurement , definition , type_binary ) for measurement , definition in refrigerator_sensors . items ( ) for lge_device in lge_devices . get ( DeviceType . REFRIGERATOR , [ ] ) if definition [ ATTR_ENABLED_FN ] ( lge_device ) ] ) async_add_entities ( lge_sensors , True )
Set up LGE device sensors and bynary sensor based on config_entry.
Set up LGE device sensors and bynary sensor based on config_entry .
"""Set up LGE device sensors and bynary sensor based on config_entry."""
hass
config_entry
async_add_entities
type_binary