Air Conditionner Not found since 1.3.3
Dear switchbot developer,
Since 1.3.3 update, my air conditioner device were no more found. Reverting to 1.3.2 solves the problem. Something has been broken in the update. Bests
Hello @Hadrien-Gode
Could you please attach some logs?
I have configured an air conditioner in my installation and still work.
Written by Claude 3.7 Sonnet (thinking):
Air Conditioner Device Discovery Issue in SwitchBot Remote v1.3.3: Technical Analysis
Root Cause Analysis
Examining the commit history reveals the specific code changes causing air conditioner devices to disappear after updating to v1.3.3:
# Before (v1.3.2)
async def async_turn_on(self, **kwargs):
params = {}
if self.device_type == "Air Conditioner":
if state:
await self.api.devices(self.device_id, "turnOn", params)
else:
await self.api.devices(self.device_id, "turnOff", params)
# After (v1.3.3)
async def async_turn_on(self, **kwargs):
params = {}
if self.device_type == "Air Conditioner":
if state:
params["mode"] = self.ac_mode
params["temperature"] = self.ac_temperature
params["fanSpeed"] = self.ac_fan_speed
await self.api.devices(self.device_id, "setAll", params)
else:
await self.api.devices(self.device_id, "turnOff", params)
The issue is twofold:
- Command Change: The API command changed from
turnOntosetAll - Required Parameters: New parameters (
mode,temperature,fanSpeed) are now mandatory
These changes break compatibility with air conditioners in "Customise Mode", which:
- Expect the exact
turnOncommand to trigger learned IR codes - Don't need or understand the additional climate parameters
- Fail silently during initialization when required parameters are unavailable
Additionally, the integration's device discovery mechanism now attempts to validate these parameters during initialization, causing devices to be ignored when validation fails.
Solution with Code Implementation
To fix the issue while preserving the new functionality, implement a device mode detection system:
async def async_turn_on(self, **kwargs):
params = {}
if self.device_type == "Air Conditioner":
# Check if device is in Customise Mode
is_customise_mode = self.device_info.get("customiseMode", False)
if state:
if is_customise_mode:
# Use original command for Customise Mode devices
await self.api.devices(self.device_id, "turnOn", params)
else:
# Use new enhanced functionality for native devices
params["mode"] = self.ac_mode
params["temperature"] = self.ac_temperature
params["fanSpeed"] = self.ac_fan_speed
await self.api.devices(self.device_id, "setAll", params)
else:
await self.api.devices(self.device_id, "turnOff", params)
And modify the device discovery code:
def setup_platform(hass, config, add_entities, discovery_info=None):
# ...existing code
# When creating device entities, handle parameter validation conditionally
for device in devices:
is_customise_mode = device.get("customiseMode", False)
# For Air Conditioner devices
if device["deviceType"] == "Air Conditioner":
if is_customise_mode:
# Skip parameter validation for Customise Mode devices
entities.append(SwitchBotDevice(device, api, True))
else:
# Apply new validation only for native devices
try:
validate_climate_params(device)
entities.append(SwitchBotDevice(device, api, False))
except ValueError as e:
_LOGGER.warning(f"Failed to initialize device {device['deviceId']}: {e}")
Implementation Benefits
This solution:
- Maintains backward compatibility with Customise Mode devices
- Preserves the enhanced functionality for native SwitchBot climate devices
- Improves error handling with explicit logging of device initialization failures
- Adds minimal overhead by simply checking the device mode before command selection
With these changes, users who experienced missing air conditioner devices after updating to v1.3.3 will regain access to their devices while still benefiting from the improved climate control functionality for supported devices.