mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-03-13 00:00:08 +01:00
update to latest official pyvesync
This commit is contained in:
parent
0f2fd2f880
commit
077a7cf1f7
@ -151,6 +151,7 @@ class VeSyncWaterTankLiftedSensor(VeSyncBinarySensorEntity):
|
|||||||
"""Return a value indicating whether the Humidifier's water tank is lifted."""
|
"""Return a value indicating whether the Humidifier's water tank is lifted."""
|
||||||
return self.smarthumidifier.details["water_tank_lifted"]
|
return self.smarthumidifier.details["water_tank_lifted"]
|
||||||
|
|
||||||
|
|
||||||
class VeSyncFilterOpenStateSensor(VeSyncBinarySensorEntity):
|
class VeSyncFilterOpenStateSensor(VeSyncBinarySensorEntity):
|
||||||
"""Filter Open Sensor."""
|
"""Filter Open Sensor."""
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ VS_MODE_TURBO = "turbo"
|
|||||||
|
|
||||||
VS_TO_HA_ATTRIBUTES = {"humidity": "current_humidity"}
|
VS_TO_HA_ATTRIBUTES = {"humidity": "current_humidity"}
|
||||||
|
|
||||||
VS_FAN_TYPES = ["VeSyncAirBypass", "VeSyncAir131", "VeSyncVital"]
|
VS_FAN_TYPES = ["VeSyncAirBypass", "VeSyncAir131", "VeSyncAirBaseV2"]
|
||||||
VS_HUMIDIFIERS_TYPES = ["VeSyncHumid200300S", "VeSyncHumid200S", "VeSyncHumid1000S"]
|
VS_HUMIDIFIERS_TYPES = ["VeSyncHumid200300S", "VeSyncHumid200S", "VeSyncHumid1000S"]
|
||||||
VS_AIRFRYER_TYPES = ["VeSyncAirFryer158"]
|
VS_AIRFRYER_TYPES = ["VeSyncAirFryer158"]
|
||||||
|
|
||||||
|
@ -70,15 +70,15 @@ class VeSyncFanHA(VeSyncDevice, FanEntity):
|
|||||||
self.smartfan = fan
|
self.smartfan = fan
|
||||||
self._speed_range = (1, 1)
|
self._speed_range = (1, 1)
|
||||||
self._attr_preset_modes = [VS_MODE_MANUAL, VS_MODE_AUTO, VS_MODE_SLEEP]
|
self._attr_preset_modes = [VS_MODE_MANUAL, VS_MODE_AUTO, VS_MODE_SLEEP]
|
||||||
if has_feature(self.smartfan, "config_dict", VS_LEVELS):
|
if has_feature(self.smartfan, "_config_dict", VS_LEVELS):
|
||||||
self._speed_range = (1, max(self.smartfan.config_dict[VS_LEVELS]))
|
self._speed_range = (1, max(self.smartfan._config_dict[VS_LEVELS]))
|
||||||
if has_feature(self.smartfan, "config_dict", VS_MODES):
|
if has_feature(self.smartfan, "_config_dict", VS_MODES):
|
||||||
self._attr_preset_modes = [
|
self._attr_preset_modes = [
|
||||||
VS_MODE_MANUAL,
|
VS_MODE_MANUAL,
|
||||||
*[
|
*[
|
||||||
mode
|
mode
|
||||||
for mode in [VS_MODE_AUTO, VS_MODE_SLEEP, VS_MODE_TURBO]
|
for mode in [VS_MODE_AUTO, VS_MODE_SLEEP, VS_MODE_TURBO]
|
||||||
if mode in self.smartfan.config_dict[VS_MODES]
|
if mode in self.smartfan._config_dict[VS_MODES]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
if self.smartfan.device_type == "LV-PUR131S":
|
if self.smartfan.device_type == "LV-PUR131S":
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.helpers.entity import EntityCategory
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .common import VeSyncDevice, has_feature
|
from .common import VeSyncDevice, has_feature
|
||||||
from .const import DEV_TYPE_TO_HA, DOMAIN, VS_DISCOVERY, VS_LIGHTS, VS_FAN_TYPES
|
from .const import DEV_TYPE_TO_HA, DOMAIN, VS_DISCOVERY, VS_FAN_TYPES, VS_LIGHTS
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ class VeSyncNightLightHA(VeSyncDimmableLightHA):
|
|||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the night light on."""
|
"""Turn the night light on."""
|
||||||
if self.device.config_dict["module"] in VS_FAN_TYPES:
|
if self.device._config_dict["module"] in VS_FAN_TYPES:
|
||||||
if ATTR_BRIGHTNESS in kwargs and kwargs[ATTR_BRIGHTNESS] < 255:
|
if ATTR_BRIGHTNESS in kwargs and kwargs[ATTR_BRIGHTNESS] < 255:
|
||||||
self.device.set_night_light("dim")
|
self.device.set_night_light("dim")
|
||||||
else:
|
else:
|
||||||
@ -269,7 +269,7 @@ class VeSyncNightLightHA(VeSyncDimmableLightHA):
|
|||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the night light off."""
|
"""Turn the night light off."""
|
||||||
if self.device.config_dict["module"] in VS_FAN_TYPES:
|
if self.device._config_dict["module"] in VS_FAN_TYPES:
|
||||||
self.device.set_night_light("off")
|
self.device.set_night_light("off")
|
||||||
else:
|
else:
|
||||||
self.device.set_night_light_brightness(0)
|
self.device.set_night_light_brightness(0)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"issue_tracker": "https://github.com/AndreaTomatis/custom_vesync",
|
"issue_tracker": "https://github.com/AndreaTomatis/custom_vesync",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyvesync==2.1.10"
|
"pyvesync==2.1.12"
|
||||||
],
|
],
|
||||||
"version": "1.3.1"
|
"version": "1.3.2"
|
||||||
}
|
}
|
@ -52,7 +52,7 @@ def _setup_entities(devices, async_add_entities, coordinator):
|
|||||||
entities.append(VeSyncHumidifierTargetLevelHA(dev, coordinator))
|
entities.append(VeSyncHumidifierTargetLevelHA(dev, coordinator))
|
||||||
if has_feature(dev, "details", "warm_mist_level"):
|
if has_feature(dev, "details", "warm_mist_level"):
|
||||||
entities.append(VeSyncHumidifierWarmthLevelHA(dev, coordinator))
|
entities.append(VeSyncHumidifierWarmthLevelHA(dev, coordinator))
|
||||||
if has_feature(dev, "config_dict", "levels"):
|
if has_feature(dev, "_config_dict", "levels"):
|
||||||
entities.append(VeSyncFanSpeedLevelHA(dev, coordinator))
|
entities.append(VeSyncFanSpeedLevelHA(dev, coordinator))
|
||||||
|
|
||||||
async_add_entities(entities, update_before_add=True)
|
async_add_entities(entities, update_before_add=True)
|
||||||
@ -77,8 +77,8 @@ class VeSyncFanSpeedLevelHA(VeSyncNumberEntity):
|
|||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the number entity."""
|
"""Initialize the number entity."""
|
||||||
super().__init__(device, coordinator)
|
super().__init__(device, coordinator)
|
||||||
self._attr_native_min_value = device.config_dict["levels"][0]
|
self._attr_native_min_value = device._config_dict["levels"][0]
|
||||||
self._attr_native_max_value = device.config_dict["levels"][-1]
|
self._attr_native_max_value = device._config_dict["levels"][-1]
|
||||||
self._attr_native_step = 1
|
self._attr_native_step = 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -99,7 +99,7 @@ class VeSyncFanSpeedLevelHA(VeSyncNumberEntity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes of the humidifier."""
|
"""Return the state attributes of the humidifier."""
|
||||||
return {"fan speed levels": self.device.config_dict["levels"]}
|
return {"fan speed levels": self.device._config_dict["levels"]}
|
||||||
|
|
||||||
def set_native_value(self, value):
|
def set_native_value(self, value):
|
||||||
"""Set the fan speed level."""
|
"""Set the fan speed level."""
|
||||||
@ -112,8 +112,8 @@ class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity):
|
|||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the number entity."""
|
"""Initialize the number entity."""
|
||||||
super().__init__(device, coordinator)
|
super().__init__(device, coordinator)
|
||||||
self._attr_native_min_value = device.config_dict["mist_levels"][0]
|
self._attr_native_min_value = device._config_dict["mist_levels"][0]
|
||||||
self._attr_native_max_value = device.config_dict["mist_levels"][-1]
|
self._attr_native_max_value = device._config_dict["mist_levels"][-1]
|
||||||
self._attr_native_step = 1
|
self._attr_native_step = 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -134,7 +134,7 @@ class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes of the humidifier."""
|
"""Return the state attributes of the humidifier."""
|
||||||
return {"mist levels": self.device.config_dict["mist_levels"]}
|
return {"mist levels": self.device._config_dict["mist_levels"]}
|
||||||
|
|
||||||
def set_native_value(self, value):
|
def set_native_value(self, value):
|
||||||
"""Set the mist level."""
|
"""Set the mist level."""
|
||||||
@ -147,8 +147,8 @@ class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity):
|
|||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the number entity."""
|
"""Initialize the number entity."""
|
||||||
super().__init__(device, coordinator)
|
super().__init__(device, coordinator)
|
||||||
self._attr_native_min_value = device.config_dict["warm_mist_levels"][0]
|
self._attr_native_min_value = device._config_dict["warm_mist_levels"][0]
|
||||||
self._attr_native_max_value = device.config_dict["warm_mist_levels"][-1]
|
self._attr_native_max_value = device._config_dict["warm_mist_levels"][-1]
|
||||||
self._attr_native_step = 1
|
self._attr_native_step = 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -169,7 +169,7 @@ class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity):
|
|||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes of the humidifier."""
|
"""Return the state attributes of the humidifier."""
|
||||||
return {"warm mist levels": self.device.config_dict["warm_mist_levels"]}
|
return {"warm mist levels": self.device._config_dict["warm_mist_levels"]}
|
||||||
|
|
||||||
def set_native_value(self, value):
|
def set_native_value(self, value):
|
||||||
"""Set the mist level."""
|
"""Set the mist level."""
|
||||||
|
@ -8,7 +8,13 @@ from homeassistant.components.sensor import (
|
|||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE, UnitOfEnergy, UnitOfPower, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, DEGREE
|
from homeassistant.const import (
|
||||||
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
DEGREE,
|
||||||
|
PERCENTAGE,
|
||||||
|
UnitOfEnergy,
|
||||||
|
UnitOfPower,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
@ -269,12 +275,12 @@ class VeSyncAirQualitySensor(VeSyncHumidifierSensorEntity):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return unique ID for air quality sensor on device."""
|
"""Return unique ID for air quality sensor on device."""
|
||||||
return f"{super().unique_id}-air-quality-index"
|
return f"{super().unique_id}-air-quality"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return sensor name."""
|
"""Return sensor name."""
|
||||||
return f"{super().name} air quality index"
|
return f"{super().name} air quality"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
@ -291,6 +297,7 @@ class VeSyncAirQualitySensor(VeSyncHumidifierSensorEntity):
|
|||||||
_LOGGER.warning("No air quality index found in '%s'", self.name)
|
_LOGGER.warning("No air quality index found in '%s'", self.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VeSyncAirQualityPercSensor(VeSyncHumidifierSensorEntity):
|
class VeSyncAirQualityPercSensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of an air quality percentage sensor."""
|
"""Representation of an air quality percentage sensor."""
|
||||||
|
|
||||||
@ -306,12 +313,12 @@ class VeSyncAirQualityPercSensor(VeSyncHumidifierSensorEntity):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return unique ID for air quality sensor on device."""
|
"""Return unique ID for air quality sensor on device."""
|
||||||
return f"{super().unique_id}-air-quality"
|
return f"{super().unique_id}-air-quality-perc"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return sensor name."""
|
"""Return sensor name."""
|
||||||
return f"{super().name} air quality"
|
return f"{super().name} air quality percentage"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self):
|
def native_unit_of_measurement(self):
|
||||||
@ -333,12 +340,13 @@ class VeSyncAirQualityPercSensor(VeSyncHumidifierSensorEntity):
|
|||||||
_LOGGER.warning("No air quality percentage found in '%s'", self.name)
|
_LOGGER.warning("No air quality percentage found in '%s'", self.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VeSyncAirQualityValueSensor(VeSyncHumidifierSensorEntity):
|
class VeSyncAirQualityValueSensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of an air quality sensor."""
|
"""Representation of an air quality sensor."""
|
||||||
|
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_device_class = SensorDeviceClass.PM25
|
_attr_device_class = SensorDeviceClass.PM25
|
||||||
_attr_native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
_attr_native_unit_of_measurement = CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
|
|
||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the VeSync device."""
|
"""Initialize the VeSync device."""
|
||||||
@ -347,12 +355,12 @@ class VeSyncAirQualityValueSensor(VeSyncHumidifierSensorEntity):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return unique ID for air quality sensor on device."""
|
"""Return unique ID for air quality sensor on device."""
|
||||||
return f"{super().unique_id}-pm25"
|
return f"{super().unique_id}-air-quality-value"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return sensor name."""
|
"""Return sensor name."""
|
||||||
return f"{super().name} PM2.5"
|
return f"{super().name} air quality value"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
@ -369,12 +377,13 @@ class VeSyncAirQualityValueSensor(VeSyncHumidifierSensorEntity):
|
|||||||
_LOGGER.warning("No air quality value found in '%s'", self.name)
|
_LOGGER.warning("No air quality value found in '%s'", self.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VeSyncPM1Sensor(VeSyncHumidifierSensorEntity):
|
class VeSyncPM1Sensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of a PM1 sensor."""
|
"""Representation of a PM1 sensor."""
|
||||||
|
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_device_class = SensorDeviceClass.PM1
|
_attr_device_class = SensorDeviceClass.PM1
|
||||||
_attr_native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
_attr_native_unit_of_measurement = CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
|
|
||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the VeSync device."""
|
"""Initialize the VeSync device."""
|
||||||
@ -392,7 +401,7 @@ class VeSyncPM1Sensor(VeSyncHumidifierSensorEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the PM1"""
|
"""Return the PM1."""
|
||||||
if has_feature(self.smarthumidifier, "details", "pm1"):
|
if has_feature(self.smarthumidifier, "details", "pm1"):
|
||||||
quality_value = self.smarthumidifier.details["pm1"]
|
quality_value = self.smarthumidifier.details["pm1"]
|
||||||
if isinstance(quality_value, (int, float)):
|
if isinstance(quality_value, (int, float)):
|
||||||
@ -405,12 +414,13 @@ class VeSyncPM1Sensor(VeSyncHumidifierSensorEntity):
|
|||||||
_LOGGER.warning("No PM1 value found in '%s'", self.name)
|
_LOGGER.warning("No PM1 value found in '%s'", self.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VeSyncPM10Sensor(VeSyncHumidifierSensorEntity):
|
class VeSyncPM10Sensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of a PM10 sensor."""
|
"""Representation of a PM10 sensor."""
|
||||||
|
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_device_class = SensorDeviceClass.PM10
|
_attr_device_class = SensorDeviceClass.PM10
|
||||||
_attr_native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
_attr_native_unit_of_measurement = CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
|
|
||||||
def __init__(self, device, coordinator) -> None:
|
def __init__(self, device, coordinator) -> None:
|
||||||
"""Initialize the VeSync device."""
|
"""Initialize the VeSync device."""
|
||||||
@ -428,7 +438,7 @@ class VeSyncPM10Sensor(VeSyncHumidifierSensorEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the PM10"""
|
"""Return the PM10."""
|
||||||
if has_feature(self.smarthumidifier, "details", "pm10"):
|
if has_feature(self.smarthumidifier, "details", "pm10"):
|
||||||
quality_value = self.smarthumidifier.details["pm10"]
|
quality_value = self.smarthumidifier.details["pm10"]
|
||||||
if isinstance(quality_value, (int, float)):
|
if isinstance(quality_value, (int, float)):
|
||||||
@ -441,6 +451,7 @@ class VeSyncPM10Sensor(VeSyncHumidifierSensorEntity):
|
|||||||
_LOGGER.warning("No PM10 value found in '%s'", self.name)
|
_LOGGER.warning("No PM10 value found in '%s'", self.name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VeSyncFilterLifeSensor(VeSyncHumidifierSensorEntity):
|
class VeSyncFilterLifeSensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of a filter life sensor."""
|
"""Representation of a filter life sensor."""
|
||||||
|
|
||||||
@ -501,6 +512,7 @@ class VeSyncFilterLifeSensor(VeSyncHumidifierSensorEntity):
|
|||||||
"""Return the icon to use in the frontend, if any."""
|
"""Return the icon to use in the frontend, if any."""
|
||||||
return "mdi:air-filter"
|
return "mdi:air-filter"
|
||||||
|
|
||||||
|
|
||||||
class VeSyncFanRotateAngleSensor(VeSyncHumidifierSensorEntity):
|
class VeSyncFanRotateAngleSensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of a fan rotate angle sensor."""
|
"""Representation of a fan rotate angle sensor."""
|
||||||
|
|
||||||
@ -552,6 +564,7 @@ class VeSyncFanRotateAngleSensor(VeSyncHumidifierSensorEntity):
|
|||||||
"""Return the icon to use in the frontend, if any."""
|
"""Return the icon to use in the frontend, if any."""
|
||||||
return "mdi:rotate-3d-variant"
|
return "mdi:rotate-3d-variant"
|
||||||
|
|
||||||
|
|
||||||
class VeSyncHumiditySensor(VeSyncHumidifierSensorEntity):
|
class VeSyncHumiditySensor(VeSyncHumidifierSensorEntity):
|
||||||
"""Representation of current humidity for a VeSync humidifier."""
|
"""Representation of current humidity for a VeSync humidifier."""
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
pyvesync==2.1.10
|
pyvesync==2.1.12
|
||||||
|
Loading…
x
Reference in New Issue
Block a user