mirror of
https://github.com/home-assistant/core.git
synced 2025-08-09 15:45:08 +02:00
Incomplete Air Humidifier CA support fixed.
This commit is contained in:
@@ -26,6 +26,7 @@ CONF_MODEL = 'model'
|
|||||||
MODEL_AIRPURIFIER_PRO = 'zhimi.airpurifier.v6'
|
MODEL_AIRPURIFIER_PRO = 'zhimi.airpurifier.v6'
|
||||||
MODEL_AIRPURIFIER_V3 = 'zhimi.airpurifier.v3'
|
MODEL_AIRPURIFIER_V3 = 'zhimi.airpurifier.v3'
|
||||||
MODEL_AIRHUMIDIFIER_V1 = 'zhimi.humidifier.v1'
|
MODEL_AIRHUMIDIFIER_V1 = 'zhimi.humidifier.v1'
|
||||||
|
MODEL_AIRHUMIDIFIER_CA = 'zhimi.humidifier.ca1'
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
@@ -529,7 +530,7 @@ class XiaomiAirPurifier(XiaomiGenericDevice):
|
|||||||
|
|
||||||
def __init__(self, name, device, model, unique_id):
|
def __init__(self, name, device, model, unique_id):
|
||||||
"""Initialize the plug switch."""
|
"""Initialize the plug switch."""
|
||||||
XiaomiGenericDevice.__init__(self, name, device, model, unique_id)
|
super().__init__(name, device, model, unique_id)
|
||||||
|
|
||||||
if self._model == MODEL_AIRPURIFIER_PRO:
|
if self._model == MODEL_AIRPURIFIER_PRO:
|
||||||
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO
|
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO
|
||||||
@@ -721,11 +722,16 @@ class XiaomiAirHumidifier(XiaomiGenericDevice):
|
|||||||
|
|
||||||
def __init__(self, name, device, model, unique_id):
|
def __init__(self, name, device, model, unique_id):
|
||||||
"""Initialize the plug switch."""
|
"""Initialize the plug switch."""
|
||||||
XiaomiGenericDevice.__init__(self, name, device, model, unique_id)
|
super().__init__(name, device, model, unique_id)
|
||||||
|
|
||||||
self._device_features = FEATURE_FLAGS_AIRHUMIDIFIER
|
if self._model == MODEL_AIRHUMIDIFIER_CA:
|
||||||
self._state_attrs.update({attribute: None for attribute in
|
self._device_features = FEATURE_FLAGS_AIRHUMIDIFIER_CA
|
||||||
AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER})
|
self._state_attrs.update({attribute: None for attribute in
|
||||||
|
AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER_CA})
|
||||||
|
else:
|
||||||
|
self._device_features = FEATURE_FLAGS_AIRHUMIDIFIER
|
||||||
|
self._state_attrs.update({attribute: None for attribute in
|
||||||
|
AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER})
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Fetch state from the device."""
|
"""Fetch state from the device."""
|
||||||
@@ -744,9 +750,16 @@ class XiaomiAirHumidifier(XiaomiGenericDevice):
|
|||||||
self._available = True
|
self._available = True
|
||||||
self._state = state.is_on
|
self._state = state.is_on
|
||||||
|
|
||||||
self._state_attrs.update(
|
if self._model == MODEL_AIRHUMIDIFIER_CA:
|
||||||
{key: self._extract_value_from_attribute(state, value) for
|
self._state_attrs.update(
|
||||||
key, value in AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER.items()})
|
{key: self._extract_value_from_attribute(state, value)
|
||||||
|
for key, value in
|
||||||
|
AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER_CA.items()})
|
||||||
|
else:
|
||||||
|
self._state_attrs.update(
|
||||||
|
{key: self._extract_value_from_attribute(state, value)
|
||||||
|
for key, value in
|
||||||
|
AVAILABLE_ATTRIBUTES_AIRHUMIDIFIER.items()})
|
||||||
|
|
||||||
except DeviceException as ex:
|
except DeviceException as ex:
|
||||||
self._available = False
|
self._available = False
|
||||||
@@ -758,6 +771,7 @@ class XiaomiAirHumidifier(XiaomiGenericDevice):
|
|||||||
if self._model == MODEL_AIRHUMIDIFIER_V1:
|
if self._model == MODEL_AIRHUMIDIFIER_V1:
|
||||||
return [mode.name for mode in OperationMode if mode.name != 'Auto']
|
return [mode.name for mode in OperationMode if mode.name != 'Auto']
|
||||||
|
|
||||||
|
# Air Humidifier CA
|
||||||
return [mode.name for mode in OperationMode]
|
return [mode.name for mode in OperationMode]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Reference in New Issue
Block a user