diff --git a/custom_components/tapo_control/select.py b/custom_components/tapo_control/select.py index 7f49c0b..420c9ff 100644 --- a/custom_components/tapo_control/select.py +++ b/custom_components/tapo_control/select.py @@ -21,19 +21,26 @@ async def async_setup_entry( entry = hass.data[DOMAIN][config_entry.entry_id] selects = [] + LOGGER.debug("Adding TapoNightVisionSelect...") selects.append(TapoNightVisionSelect(entry, hass, config_entry)) + LOGGER.debug("Adding TapoAutomaticAlarmModeSelect...") selects.append(TapoAutomaticAlarmModeSelect(entry, hass, config_entry)) + LOGGER.debug("Adding TapoLightFrequencySelect...") selects.append(TapoLightFrequencySelect(entry, hass, config_entry)) - selects.append( - await check_and_create( - entry, hass, TapoMotionDetectionSelect, "getAutoTrackTarget", config_entry - ) + + tapoMotionDetectionSelect = await check_and_create( + entry, hass, TapoMotionDetectionSelect, "getAutoTrackTarget", config_entry ) - selects.append( - await check_and_create( - entry, hass, TapoMoveToPresetSelect, "getPresets", config_entry - ) + if tapoMotionDetectionSelect: + LOGGER.debug("Adding TapoMotionDetectionSelect...") + selects.append(tapoMotionDetectionSelect) + + tapoMoveToPresetSelect = await check_and_create( + entry, hass, TapoMoveToPresetSelect, "getPresets", config_entry ) + if tapoMoveToPresetSelect: + LOGGER.debug("Adding TapoMoveToPresetSelect...") + selects.append(tapoMoveToPresetSelect) async_add_entities(selects) diff --git a/custom_components/tapo_control/switch.py b/custom_components/tapo_control/switch.py index 392564d..dee2f72 100644 --- a/custom_components/tapo_control/switch.py +++ b/custom_components/tapo_control/switch.py @@ -21,37 +21,51 @@ async def async_setup_entry( entry: dict = hass.data[DOMAIN][config_entry.entry_id] switches = [] - switches.append( - await check_and_create( - entry, hass, TapoPrivacySwitch, "getPrivacyMode", config_entry - ) + + tapoPrivacySwitch = await check_and_create( + entry, hass, TapoPrivacySwitch, "getPrivacyMode", config_entry ) - switches.append( - await check_and_create( - entry, - hass, - TapoLensDistortionCorrectionSwitch, - "getLensDistortionCorrection", - config_entry, - ) + if tapoPrivacySwitch: + LOGGER.debug("Adding tapoPrivacySwitch...") + switches.append(tapoPrivacySwitch) + + tapoLensDistortionCorrectionSwitch = await check_and_create( + entry, + hass, + TapoLensDistortionCorrectionSwitch, + "getLensDistortionCorrection", + config_entry, ) - switches.append( - await check_and_create( - entry, hass, TapoIndicatorLedSwitch, "getLED", config_entry - ) - ) - switches.append( - await check_and_create( - entry, hass, TapoFlipSwitch, "getImageFlipVertical", config_entry - ) + if tapoLensDistortionCorrectionSwitch: + LOGGER.debug("Adding tapoLensDistortionCorrectionSwitch...") + switches.append(tapoLensDistortionCorrectionSwitch) + + tapoIndicatorLedSwitch = await check_and_create( + entry, hass, TapoIndicatorLedSwitch, "getLED", config_entry ) - switches.append( - await check_and_create( - entry, hass, TapoAutoTrackSwitch, "getAutoTrackTarget", config_entry - ) + if tapoIndicatorLedSwitch: + LOGGER.debug("Adding tapoIndicatorLedSwitch...") + switches.append(tapoIndicatorLedSwitch) + + tapoFlipSwitch = await check_and_create( + entry, hass, TapoFlipSwitch, "getImageFlipVertical", config_entry ) + if tapoFlipSwitch: + LOGGER.debug("Adding tapoFlipSwitch...") + switches.append(tapoFlipSwitch) - async_add_entities(switches) + tapoAutoTrackSwitch = await check_and_create( + entry, hass, TapoAutoTrackSwitch, "getAutoTrackTarget", config_entry + ) + if tapoAutoTrackSwitch: + LOGGER.debug("Adding tapoAutoTrackSwitch...") + switches.append(tapoAutoTrackSwitch) + + if switches: + LOGGER.debug("Adding switch entities...") + async_add_entities(switches) + else: + LOGGER.debug("No switch entities available.") class TapoLensDistortionCorrectionSwitch(TapoSwitchEntity):