Skip to content

Commit e45805f

Browse files
authored
Merge pull request #1746 from Antonio112009/fix/climate-shared-mutable-hvac-modes
Fix shared mutable _attr_hvac_modes list in XClimateNS
2 parents 069066b + 3e4f4c0 commit e45805f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

custom_components/sonoff/climate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ class XClimateNS(XEntity, ClimateEntity):
151151
params = {"ATCEnable", "ATCMode", "temperature", "tempCorrection"}
152152

153153
_attr_entity_registry_enabled_default = False
154-
_attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT_COOL, HVACMode.AUTO]
155154
_attr_max_temp = 31
156155
_attr_min_temp = 16
157156
_attr_temperature_unit = UnitOfTemperature.CELSIUS
@@ -168,6 +167,11 @@ class XClimateNS(XEntity, ClimateEntity):
168167
else:
169168
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
170169

170+
def __init__(self, ewelink, device: dict):
171+
# copy mutable list so each instance has its own hvac_modes
172+
self._attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT_COOL, HVACMode.AUTO]
173+
super().__init__(ewelink, device)
174+
171175
def set_state(self, params: dict):
172176
cache = self.device["params"]
173177
if cache != params:

0 commit comments

Comments
 (0)