diff --git a/README.md b/README.md index b9f31d6..29555b7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # **Important message** > > Unfortunately, I no longer have time to maintain this repo. I am therefore looking for someone to take it over before archiving it. If interested please contact me. @@ -44,6 +45,13 @@ logger: pyvesync: debug ``` +## TODO LIST +``` +- [x] Air Fryer Properties (AirFryer158) +- [ ] Air Fryer Methods +- [ ] Create the Card +``` + ### Contributing All contributions are very welcomed! @@ -54,3 +62,4 @@ pip install pre-commit pre-commit install pre-commit run --all-files ``` + diff --git a/custom_components/vesync/__init__.py b/custom_components/vesync/__init__.py index 29e3ddc..16bec23 100644 --- a/custom_components/vesync/__init__.py +++ b/custom_components/vesync/__init__.py @@ -15,6 +15,7 @@ DOMAIN, SERVICE_UPDATE_DEVS, VS_BINARY_SENSORS, + VS_BUTTON, VS_DISCOVERY, VS_FANS, VS_HUMIDIFIERS, @@ -33,6 +34,7 @@ Platform.HUMIDIFIER: VS_HUMIDIFIERS, Platform.NUMBER: VS_NUMBERS, Platform.BINARY_SENSOR: VS_BINARY_SENSORS, + Platform.BUTTON: VS_BUTTON, } _LOGGER = logging.getLogger(__name__) diff --git a/custom_components/vesync/binary_sensor.py b/custom_components/vesync/binary_sensor.py index f587dac..a9dbd8f 100644 --- a/custom_components/vesync/binary_sensor.py +++ b/custom_components/vesync/binary_sensor.py @@ -9,7 +9,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from .common import VeSyncBaseEntity, has_feature -from .const import DOMAIN, VS_BINARY_SENSORS, VS_DISCOVERY +from .const import BINARY_SENSOR_TYPES_AIRFRYER, DOMAIN, VS_BINARY_SENSORS, VS_DISCOVERY _LOGGER = logging.getLogger(__name__) @@ -44,6 +44,15 @@ def _setup_entities(devices, async_add_entities, coordinator): """Check if device is online and add entity.""" entities = [] for dev in devices: + if hasattr(dev, "fryer_status"): + for stype in BINARY_SENSOR_TYPES_AIRFRYER.values(): + entities.append( + VeSyncairfryerSensor( + dev, + coordinator, + stype, + ) + ) if has_feature(dev, "details", "water_lacks"): entities.append(VeSyncOutOfWaterSensor(dev, coordinator)) if has_feature(dev, "details", "water_tank_lifted"): @@ -52,10 +61,47 @@ def _setup_entities(devices, async_add_entities, coordinator): async_add_entities(entities, update_before_add=True) +class VeSyncairfryerSensor(VeSyncBaseEntity, BinarySensorEntity): + """Class representing a VeSyncairfryerSensor.""" + + def __init__(self, airfryer, coordinator, stype) -> None: + """Initialize the VeSync humidifier device.""" + super().__init__(airfryer, coordinator) + self.airfryer = airfryer + self.stype = stype + + @property + def entity_category(self): + """Return the diagnostic entity category.""" + return EntityCategory.DIAGNOSTIC + + @property + def unique_id(self): + """Return unique ID for water tank lifted sensor on device.""" + return f"{super().unique_id}-" + self.stype[0] + + @property + def name(self): + """Return sensor name.""" + return self.stype[1] + + @property + def is_on(self) -> bool: + """Return a value indicating whether the Humidifier's water tank is lifted.""" + value = getattr(self.airfryer, self.stype[0], None) + return value + # return self.smarthumidifier.details["water_tank_lifted"] + + @property + def icon(self): + """Return the icon to use in the frontend, if any.""" + return self.stype[2] + + class VeSyncBinarySensorEntity(VeSyncBaseEntity, BinarySensorEntity): """Representation of a binary sensor describing diagnostics of a VeSync humidifier.""" - def __init__(self, humidifier, coordinator): + def __init__(self, humidifier, coordinator) -> None: """Initialize the VeSync humidifier device.""" super().__init__(humidifier, coordinator) self.smarthumidifier = humidifier diff --git a/custom_components/vesync/button.py b/custom_components/vesync/button.py new file mode 100644 index 0000000..8109629 --- /dev/null +++ b/custom_components/vesync/button.py @@ -0,0 +1,95 @@ +"""Support for VeSync button.""" +import logging + +from homeassistant.components.button import ButtonEntity +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity_platform import AddEntitiesCallback + +from .common import VeSyncBaseEntity +from .const import DOMAIN, VS_BUTTON, VS_DISCOVERY + +_LOGGER = logging.getLogger(__name__) + + +SENSOR_TYPES_CS158 = { + # unique_id,name # icon, + "end": [ + "end", + "End cooking or preheating ", + "mdi:stop", + ], +} + + +async def async_setup_entry( + hass: HomeAssistant, + config_entry: ConfigEntry, + async_add_entities: AddEntitiesCallback, +) -> None: + """Set up switches.""" + + coordinator = hass.data[DOMAIN][config_entry.entry_id]["coordinator"] + + @callback + def discover(devices): + """Add new devices to platform.""" + _setup_entities(devices, async_add_entities, coordinator) + + config_entry.async_on_unload( + async_dispatcher_connect(hass, VS_DISCOVERY.format(VS_BUTTON), discover) + ) + + _setup_entities( + hass.data[DOMAIN][config_entry.entry_id][VS_BUTTON], + async_add_entities, + coordinator, + ) + + +@callback +def _setup_entities(devices, async_add_entities, coordinator): + """Check if device is online and add entity.""" + entities = [] + for dev in devices: + if hasattr(dev, "cook_set_temp"): + for stype in SENSOR_TYPES_CS158.values(): + entities.append( + VeSyncairfryerButton( + dev, + coordinator, + stype, + ) + ) + + async_add_entities(entities, update_before_add=True) + + +class VeSyncairfryerButton(VeSyncBaseEntity, ButtonEntity): + """Base class for VeSync switch Device Representations.""" + + def __init__(self, airfryer, coordinator, stype) -> None: + """Initialize the VeSync humidifier device.""" + super().__init__(airfryer, coordinator) + self.airfryer = airfryer + self.stype = stype + + @property + def unique_id(self): + """Return unique ID for water tank lifted sensor on device.""" + return f"{super().unique_id}-" + self.stype[0] + + @property + def name(self): + """Return sensor name.""" + return self.stype[1] + + @property + def icon(self): + """Return the icon to use in the frontend, if any.""" + return self.stype[2] + + def press(self) -> None: + """Return True if device is on.""" + self.airfryer.end() diff --git a/custom_components/vesync/common.py b/custom_components/vesync/common.py index 1732c62..e2c9dc5 100644 --- a/custom_components/vesync/common.py +++ b/custom_components/vesync/common.py @@ -4,11 +4,14 @@ from homeassistant.components.diagnostics import async_redact_data from homeassistant.helpers.entity import Entity, ToggleEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity -from pyvesync.vesyncfan import model_features +from pyvesync.vesyncfan import model_features as fan_model_features +from pyvesync.vesynckitchen import model_features as kitchen_model_features from .const import ( DOMAIN, + VS_AIRFRYER_TYPES, VS_BINARY_SENSORS, + VS_BUTTON, VS_FAN_TYPES, VS_FANS, VS_HUMIDIFIERS, @@ -27,16 +30,6 @@ def has_feature(device, dictionary, attribute): return getattr(device, dictionary, {}).get(attribute, None) is not None -def is_humidifier(device_type: str) -> bool: - """Return true if the device type is a humidifier.""" - return model_features(device_type)["module"] in VS_HUMIDIFIERS_TYPES - - -def is_air_purifier(device_type: str) -> bool: - """Return true if the device type is a an air purifier.""" - return model_features(device_type)["module"] in VS_FAN_TYPES - - async def async_process_devices(hass, manager): """Assign devices to proper component.""" devices = { @@ -47,6 +40,7 @@ async def async_process_devices(hass, manager): VS_HUMIDIFIERS: [], VS_NUMBERS: [], VS_BINARY_SENSORS: [], + VS_BUTTON: [], } redacted = async_redact_data( @@ -54,14 +48,15 @@ async def async_process_devices(hass, manager): ["cid", "uuid", "mac_id"], ) - _LOGGER.debug( + _LOGGER.warning( "Found the following devices: %s", redacted, ) if ( - manager.fans is None - and manager.bulbs is None + manager.bulbs is None + and manager.fans is None + and manager.kitchen is None and manager.outlets is None and manager.switches is None ): @@ -70,13 +65,13 @@ async def async_process_devices(hass, manager): if manager.fans: for fan in manager.fans: # VeSync classifies humidifiers as fans - if is_humidifier(fan.device_type): + if fan_model_features(fan.device_type)["module"] in VS_HUMIDIFIERS_TYPES: devices[VS_HUMIDIFIERS].append(fan) - elif is_air_purifier(fan.device_type): + elif fan_model_features(fan.device_type)["module"] in VS_FAN_TYPES: devices[VS_FANS].append(fan) else: _LOGGER.warning( - "Unknown device type %s %s (enable debug for more info)", + "Unknown fan type %s %s (enable debug for more info)", fan.device_name, fan.device_type, ) @@ -102,13 +97,33 @@ async def async_process_devices(hass, manager): else: devices[VS_LIGHTS].append(switch) + if manager.kitchen: + for airfryer in manager.kitchen: + if ( + kitchen_model_features(airfryer.device_type)["module"] + in VS_AIRFRYER_TYPES + ): + _LOGGER.warning( + "Found air fryer %s, support in progress.\n%s", airfryer.device_name + ) + devices[VS_SENSORS].append(airfryer) + devices[VS_BINARY_SENSORS].append(airfryer) + devices[VS_SWITCHES].append(airfryer) + devices[VS_BUTTON].append(airfryer) + else: + _LOGGER.warning( + "Unknown device type %s %s (enable debug for more info)", + airfryer.device_name, + airfryer.device_type, + ) + return devices class VeSyncBaseEntity(CoordinatorEntity, Entity): """Base class for VeSync Entity Representations.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync device.""" self.device = device super().__init__(coordinator, context=device) @@ -130,7 +145,7 @@ def unique_id(self): @property def base_name(self): """Return the name of the device.""" - return self.device.device_name + return self.device.device_type @property def name(self): @@ -163,7 +178,7 @@ async def async_added_to_hass(self): class VeSyncDevice(VeSyncBaseEntity, ToggleEntity): """Base class for VeSync Device Representations.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync device.""" super().__init__(device, coordinator) diff --git a/custom_components/vesync/config_flow.py b/custom_components/vesync/config_flow.py index edba11c..c1b34c7 100644 --- a/custom_components/vesync/config_flow.py +++ b/custom_components/vesync/config_flow.py @@ -20,7 +20,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - def __init__(self): + def __init__(self) -> None: """Instantiate config flow.""" self._username = None self._password = None diff --git a/custom_components/vesync/const.py b/custom_components/vesync/const.py index 7ea7957..65f07e2 100644 --- a/custom_components/vesync/const.py +++ b/custom_components/vesync/const.py @@ -1,9 +1,12 @@ """Constants for VeSync Component.""" +from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TIME_MINUTES + DOMAIN = "vesync" VS_DISCOVERY = "vesync_discovery_{}" SERVICE_UPDATE_DEVS = "update_devices" +VS_BUTTON = "button" VS_SWITCHES = "switches" VS_FAN = "fan" VS_FANS = "fans" @@ -26,6 +29,8 @@ VS_FAN_TYPES = ["VeSyncAirBypass", "VeSyncAir131", "VeSyncVital"] VS_HUMIDIFIERS_TYPES = ["VeSyncHumid200300S", "VeSyncHumid200S", "VeSyncHumid1000S"] +VS_AIRFRYER_TYPES = ["VeSyncAirFryer158"] + DEV_TYPE_TO_HA = { "ESL100": "bulb-dimmable", @@ -40,3 +45,76 @@ "ESD16": "walldimmer", "ESWD16": "walldimmer", } + + +BINARY_SENSOR_TYPES_AIRFRYER = { + # unique_id,name # icon, #attribute read, + "is_heating": [ + "is_heating", + "preheating", + "mdi:pot-steam-outline", + ], + "is_cooking": [ + "is_cooking", + "cooking", + "mdi:rice", + ], + "is_running": [ + "is_running", + "running", + "mdi:pause", + ], +} + + +SENSOR_TYPES_AIRFRYER = { + # unique_id ,#name ,# unit of measurement,# icon, # device class, #attribute read, + "current_temp": [ + "current_temperature", + "Current temperature", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + "current_temp", + ], + "cook_set_temp": [ + "set_temperature", + "Set temperature", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + "cook_set_temp", + ], + "cook_last_time": [ + "cook_last_time", + "Cook Remaining", + TIME_MINUTES, + "mdi:timer", + TIME_MINUTES, + "cook_last_time", + ], + "preheat_last_time": [ + "preheat_last_time", + "Preheat Remaining", + TIME_MINUTES, + "mdi:timer", + TIME_MINUTES, + "preheat_last_time", + ], + "cook_status": [ + "cook_status", + "Cook Status", + None, + "mdi:rotate-3d-variant", + None, + "cook_status", + ], + # "remaining_time": [ + # "remaining_time", + # "running:", + # TIME_MINUTES, + # "mdi:timer", + # TIME_MINUTES, + # "remaining_time", + # ], +} diff --git a/custom_components/vesync/diagnostics.py b/custom_components/vesync/diagnostics.py index ccaad25..ee418ac 100644 --- a/custom_components/vesync/diagnostics.py +++ b/custom_components/vesync/diagnostics.py @@ -7,8 +7,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from .common import is_humidifier -from .const import DOMAIN +# from .common import is_humidifier +# from .const import DOMAIN TO_REDACT = {"cid", "uuid", "mac_id"} @@ -17,13 +17,14 @@ async def async_get_config_entry_diagnostics( hass: HomeAssistant, entry: ConfigEntry ) -> dict[str, Any]: """Return diagnostics for a config entry.""" - data = hass.data[DOMAIN][entry.entry_id] + # data = hass.data[DOMAIN][entry.entry_id] devices = {} - for type in ["fans", "outlets", "switches", "bulbs"]: - for d in data["manager"]._dev_list[type]: - t = "humidifier" if is_humidifier(d.device_type) else type - devices = { - **devices, - **{t: [{k: v for k, v in d.__dict__.items() if k != "manager"}]}, - } + + # for type in ["fans", "outlets", "switches", "bulbs"]: + # for d in data["manager"]._dev_list[type]: + # t = "humidifier" if is_humidifier(d.device_type) else type + # devices = { + # **devices, + # **{t: [{k: v for k, v in d.__dict__.items() if k != "manager"}]}, + # } return async_redact_data(devices, TO_REDACT) diff --git a/custom_components/vesync/fan.py b/custom_components/vesync/fan.py index ea64b84..6b3e736 100644 --- a/custom_components/vesync/fan.py +++ b/custom_components/vesync/fan.py @@ -62,7 +62,7 @@ def _setup_entities(devices, async_add_entities, coordinator): class VeSyncFanHA(VeSyncDevice, FanEntity): """Representation of a VeSync fan.""" - def __init__(self, fan, coordinator): + def __init__(self, fan, coordinator) -> None: """Initialize the VeSync fan device.""" super().__init__(fan, coordinator) self.smartfan = fan diff --git a/custom_components/vesync/humidifier.py b/custom_components/vesync/humidifier.py index 431e295..e8a7703 100644 --- a/custom_components/vesync/humidifier.py +++ b/custom_components/vesync/humidifier.py @@ -100,7 +100,7 @@ class VeSyncHumidifierHA(VeSyncDevice, HumidifierEntity): _attr_max_humidity = MAX_HUMIDITY _attr_min_humidity = MIN_HUMIDITY - def __init__(self, humidifier: VeSyncHumid200300S, coordinator): + def __init__(self, humidifier: VeSyncHumid200300S, coordinator) -> None: """Initialize the VeSync humidifier device.""" super().__init__(humidifier, coordinator) self.smarthumidifier = humidifier diff --git a/custom_components/vesync/light.py b/custom_components/vesync/light.py index fd45cd7..59ab5e5 100644 --- a/custom_components/vesync/light.py +++ b/custom_components/vesync/light.py @@ -140,7 +140,7 @@ def turn_on(self, **kwargs): class VeSyncDimmableLightHA(VeSyncBaseLight, LightEntity): """Representation of a VeSync dimmable light device.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync dimmable light device.""" super().__init__(device, coordinator) @@ -158,7 +158,7 @@ def supported_color_modes(self): class VeSyncTunableWhiteLightHA(VeSyncBaseLight, LightEntity): """Representation of a VeSync Tunable White Light device.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync Tunable White Light device.""" super().__init__(device, coordinator) @@ -213,7 +213,7 @@ def supported_color_modes(self): class VeSyncNightLightHA(VeSyncDimmableLightHA): """Representation of the night light on a VeSync device.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync device.""" super().__init__(device, coordinator) self.device = device diff --git a/custom_components/vesync/manifest.json b/custom_components/vesync/manifest.json index ea55c1e..5c37b8d 100644 --- a/custom_components/vesync/manifest.json +++ b/custom_components/vesync/manifest.json @@ -1,7 +1,7 @@ { "domain": "vesync", "name": "VeSync", - "codeowners": ["@markperdue", "@webdjoe", "@thegardenmonkey", "@vlebourl"], + "codeowners": ["@markperdue", "@webdjoe", "@thegardenmonkey", "@vlebourl","@tv4you2016"], "config_flow": true, "dhcp": [ { diff --git a/custom_components/vesync/number.py b/custom_components/vesync/number.py index 306044a..1c9de09 100644 --- a/custom_components/vesync/number.py +++ b/custom_components/vesync/number.py @@ -61,7 +61,7 @@ def _setup_entities(devices, async_add_entities, coordinator): class VeSyncNumberEntity(VeSyncBaseEntity, NumberEntity): """Representation of a number for configuring a VeSync fan.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync fan device.""" super().__init__(device, coordinator) @@ -74,7 +74,7 @@ def entity_category(self): class VeSyncFanSpeedLevelHA(VeSyncNumberEntity): """Representation of the fan speed level of a VeSync fan.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the number entity.""" super().__init__(device, coordinator) self._attr_native_min_value = device.config_dict["levels"][0] @@ -109,7 +109,7 @@ def set_native_value(self, value): class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity): """Representation of the mist level of a VeSync humidifier.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the number entity.""" super().__init__(device, coordinator) self._attr_native_min_value = device.config_dict["mist_levels"][0] @@ -144,7 +144,7 @@ def set_native_value(self, value): class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity): """Representation of the warmth level of a VeSync humidifier.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the number entity.""" super().__init__(device, coordinator) self._attr_native_min_value = device.config_dict["warm_mist_levels"][0] @@ -179,7 +179,7 @@ def set_native_value(self, value): class VeSyncHumidifierTargetLevelHA(VeSyncNumberEntity): """Representation of the target humidity level of a VeSync humidifier.""" - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the number entity.""" super().__init__(device, coordinator) self._attr_native_min_value = MIN_HUMIDITY diff --git a/custom_components/vesync/sensor.py b/custom_components/vesync/sensor.py index e69a785..b98b43c 100644 --- a/custom_components/vesync/sensor.py +++ b/custom_components/vesync/sensor.py @@ -14,7 +14,13 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from .common import VeSyncBaseEntity, has_feature -from .const import DEV_TYPE_TO_HA, DOMAIN, VS_DISCOVERY, VS_SENSORS +from .const import ( + DEV_TYPE_TO_HA, + DOMAIN, + SENSOR_TYPES_AIRFRYER, + VS_DISCOVERY, + VS_SENSORS, +) _LOGGER = logging.getLogger(__name__) @@ -49,6 +55,16 @@ def _setup_entities(devices, async_add_entities, coordinator): """Check if device is online and add entity.""" entities = [] for dev in devices: + if hasattr(dev, "fryer_status"): + for stype in SENSOR_TYPES_AIRFRYER.values(): + entities.append( + VeSyncairfryerSensor( + dev, + coordinator, + stype, + ) + ) + if DEV_TYPE_TO_HA.get(dev.device_type) == "outlet": entities.extend( ( @@ -68,10 +84,52 @@ def _setup_entities(devices, async_add_entities, coordinator): async_add_entities(entities, update_before_add=True) +class VeSyncairfryerSensor(VeSyncBaseEntity, SensorEntity): + """Class representing a VeSyncairfryerSensor.""" + + def __init__(self, airfryer, coordinator, stype) -> None: + """Initialize the VeSync airfryer.""" + super().__init__(airfryer, coordinator) + self.airfryer = airfryer + self.stype = stype + + @property + def unique_id(self): + """Return unique ID for power sensor on device.""" + return f"{super().unique_id}-" + self.stype[0] + + @property + def name(self): + """Return sensor name.""" + return self.stype[1] + + @property + def device_class(self): + """Return the class.""" + return self.stype[4] + + @property + def native_value(self): + """Return the value.""" + value = getattr(self.airfryer, self.stype[5], None) + return value + + @property + def native_unit_of_measurement(self): + """Return the unit of measurement.""" + # return self.airfryer.temp_unit + return self.stype[2] + + @property + def icon(self): + """Return the icon to use in the frontend, if any.""" + return self.stype[3] + + class VeSyncOutletSensorEntity(VeSyncBaseEntity, SensorEntity): """Representation of a sensor describing diagnostics of a VeSync outlet.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(plug, coordinator) self.smartplug = plug @@ -85,7 +143,7 @@ def entity_category(self): class VeSyncPowerSensor(VeSyncOutletSensorEntity): """Representation of current power use for a VeSync outlet.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(plug, coordinator) @@ -128,7 +186,7 @@ def update(self): class VeSyncEnergySensor(VeSyncOutletSensorEntity): """Representation of current day's energy use for a VeSync outlet.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(plug, coordinator) self.smartplug = plug @@ -172,7 +230,7 @@ def update(self): class VeSyncHumidifierSensorEntity(VeSyncBaseEntity, SensorEntity): """Representation of a sensor describing diagnostics of a VeSync humidifier.""" - def __init__(self, humidifier, coordinator): + def __init__(self, humidifier, coordinator) -> None: """Initialize the VeSync humidifier device.""" super().__init__(humidifier, coordinator) self.smarthumidifier = humidifier @@ -189,7 +247,7 @@ class VeSyncAirQualitySensor(VeSyncHumidifierSensorEntity): _attr_state_class = SensorStateClass.MEASUREMENT _attr_native_unit_of_measurement = " " - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync device.""" super().__init__(device, coordinator) self._numeric_quality = None @@ -234,7 +292,7 @@ class VeSyncAirQualityValueSensor(VeSyncHumidifierSensorEntity): _attr_device_class = SensorDeviceClass.AQI _attr_native_unit_of_measurement = " " - def __init__(self, device, coordinator): + def __init__(self, device, coordinator) -> None: """Initialize the VeSync device.""" super().__init__(device, coordinator) @@ -267,7 +325,7 @@ def native_value(self): class VeSyncFilterLifeSensor(VeSyncHumidifierSensorEntity): """Representation of a filter life sensor.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(plug, coordinator) @@ -318,7 +376,7 @@ def state_attributes(self): class VeSyncHumiditySensor(VeSyncHumidifierSensorEntity): """Representation of current humidity for a VeSync humidifier.""" - def __init__(self, humidity, coordinator): + def __init__(self, humidity, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(humidity, coordinator) diff --git a/custom_components/vesync/switch.py b/custom_components/vesync/switch.py index 65887b1..bf7332e 100644 --- a/custom_components/vesync/switch.py +++ b/custom_components/vesync/switch.py @@ -63,7 +63,7 @@ def _setup_entities(devices, async_add_entities, coordinator): class VeSyncBaseSwitch(VeSyncDevice, SwitchEntity): """Base class for VeSync switch Device Representations.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(plug, coordinator) @@ -75,7 +75,7 @@ def turn_on(self, **kwargs): class VeSyncSwitchHA(VeSyncBaseSwitch, SwitchEntity): """Representation of a VeSync switch.""" - def __init__(self, plug, coordinator): + def __init__(self, plug, coordinator) -> None: """Initialize the VeSync switch device.""" super().__init__(plug, coordinator) self.smartplug = plug @@ -103,7 +103,7 @@ def update(self): class VeSyncLightSwitch(VeSyncBaseSwitch, SwitchEntity): """Handle representation of VeSync Light Switch.""" - def __init__(self, switch, coordinator): + def __init__(self, switch, coordinator) -> None: """Initialize Light Switch device class.""" super().__init__(switch, coordinator) self.switch = switch @@ -112,7 +112,7 @@ def __init__(self, switch, coordinator): class VeSyncSwitchEntity(VeSyncBaseEntity, SwitchEntity): """Representation of a switch for configuring a VeSync humidifier.""" - def __init__(self, humidifier, coordinator): + def __init__(self, humidifier, coordinator) -> None: """Initialize the VeSync humidifier device.""" super().__init__(humidifier, coordinator) self.smarthumidifier = humidifier @@ -126,7 +126,7 @@ def entity_category(self): class VeSyncFanChildLockHA(VeSyncSwitchEntity): """Representation of the child lock switch.""" - def __init__(self, lock, coordinator): + def __init__(self, lock, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(lock, coordinator) @@ -157,7 +157,7 @@ def turn_off(self, **kwargs): class VeSyncHumidifierDisplayHA(VeSyncSwitchEntity): """Representation of the child lock switch.""" - def __init__(self, lock, coordinator): + def __init__(self, lock, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(lock, coordinator) @@ -188,7 +188,7 @@ def turn_off(self, **kwargs): class VeSyncHumidifierAutomaticStopHA(VeSyncSwitchEntity): """Representation of the automatic stop toggle on a VeSync humidifier.""" - def __init__(self, automatic, coordinator): + def __init__(self, automatic, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(automatic, coordinator) @@ -219,7 +219,7 @@ def turn_off(self, **kwargs): class VeSyncHumidifierAutoOnHA(VeSyncSwitchEntity): """Provide switch to turn off auto mode and set manual mist level 1 on a VeSync humidifier.""" - def __init__(self, autooff, coordinator): + def __init__(self, autooff, coordinator) -> None: """Initialize the VeSync outlet device.""" super().__init__(autooff, coordinator)