Skip to content

Commit

Permalink
Add support Aqara Thermostat E1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 9, 2023
1 parent 26cd982 commit a10b17f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
48 changes: 48 additions & 0 deletions custom_components/xiaomi_gateway3/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def setup(gateway: XGateway, device: XDevice, conv: Converter):
if conv.attr in device.entities:
entity: XEntity = device.entities[conv.attr]
entity.gw = gateway
elif conv.mi == "4.21.85":
entity = AqaraE1(gateway, device, conv)
else:
entity = XiaomiClimate(gateway, device, conv)
async_add_entities([entity])
Expand Down Expand Up @@ -71,3 +73,49 @@ async def async_set_fan_mode(self, fan_mode: str) -> None:
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
payload = {"hvac_mode": hvac_mode}
await self.device_send({self.attr: payload})


# noinspection PyAbstractClass
class AqaraE1(XEntity, ClimateEntity):
_attr_hvac_mode = None
_attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_AUTO]
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE
_attr_temperature_unit = TEMP_CELSIUS
_attr_max_temp = 30
_attr_min_temp = 5
_attr_target_temperature_step = 0.5

_enabled = False
_mode = None

@callback
def async_set_state(self, data: dict):
if "climate" in data:
self._enabled = data["climate"]
if "mode" in data:
self._mode = data["mode"]
if "current_temp" in data:
self._attr_current_temperature = data["current_temp"]
if "target_temp" in data:
self._attr_target_temperature = data["target_temp"]

if self._enabled:
self._attr_hvac_mode = self._mode or HVAC_MODE_OFF
else:
self._attr_hvac_mode = HVAC_MODE_OFF

async def async_update(self):
await self.device_read(self.subscribed_attrs)

async def async_set_temperature(self, **kwargs) -> None:
payload = {"target_temp": kwargs[ATTR_TEMPERATURE]}
await self.device_send({self.attr: payload})

async def async_set_hvac_mode(self, hvac_mode: str) -> None:
if hvac_mode in (HVAC_MODE_HEAT, HVAC_MODE_AUTO):
payload = {"mode": hvac_mode}
elif hvac_mode == HVAC_MODE_OFF:
payload = {"climate": False}
else:
return
await self.device_send(payload)
19 changes: 19 additions & 0 deletions custom_components/xiaomi_gateway3/core/converters/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,25 @@
}),
ClimateTempConv("target_temp", mi="14.9.85"),
],
}, {
"lumi.airrtc.agl001": ["Aqara", "Thermostat E1", "SRTS-A01"],
"spec": [
BoolConv("climate", "climate", mi="4.21.85"),
# 0: Manual module 1: Smart schedule mode 2: Antifreeze mode 3: Installation mode
MapConv("mode", mi="14.51.85", parent="climate", map={0: "heat", 2: "auto"}),
MathConv("current_temp", mi="0.1.85", multiply=0.01, parent="climate"),
MathConv("target_temp", mi="1.8.85", multiply=0.01, parent="climate"),
MathConv("antifreeze_temp", "number", mi="1.10.85", multiply=0.01, min=500,
max=15000),
BoolConv("window_detection", "switch", mi="4.24.85", enabled=False),
BoolConv("valve_calibration", "switch", mi="4.22.85", enabled=False),
BoolConv("valve_notification", "switch", mi="4.25.85", enabled=False),
BoolConv("child_lock", "switch", mi="4.26.85", enabled=False),
MapConv("find_device", "switch", mi="8.0.2096", map={2: True, 1: False},
enabled=False),
Converter("battery", "sensor", mi="8.0.2001"),
ChipTemp,
],
}, {
"lumi.airrtc.vrfegl01": ["Xiaomi", "VRF Air Conditioning EU"],
"support": 1,
Expand Down

0 comments on commit a10b17f

Please sign in to comment.