From 61aab623ca80050e1e8a4b8cc9aaf2a7dc5585e0 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Wed, 9 Jul 2025 14:11:18 +0800 Subject: [PATCH] style: code style --- .../xiaomi_home/miot/specs/specv2entity.py | 63 +++++++------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index dc5c8d6..48d56c2 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -50,18 +50,11 @@ from homeassistant.components.sensor import SensorStateClass from homeassistant.components.event import EventDeviceClass from homeassistant.components.binary_sensor import BinarySensorDeviceClass -from homeassistant.const import ( - CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - EntityCategory, - LIGHT_LUX, - UnitOfEnergy, - UnitOfPower, - UnitOfElectricCurrent, - UnitOfElectricPotential, - UnitOfTemperature, - UnitOfPressure, - PERCENTAGE -) +from homeassistant.const import (CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + EntityCategory, LIGHT_LUX, UnitOfEnergy, + UnitOfPower, UnitOfElectricCurrent, + UnitOfElectricPotential, UnitOfTemperature, + UnitOfPressure, PERCENTAGE) # pylint: disable=pointless-string-statement """SPEC_DEVICE_TRANS_MAP @@ -107,7 +100,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'humidifier': { 'required': { 'humidifier': { - 'required': { + 'required': { 'properties': { 'on': {'read', 'write'} } @@ -119,7 +112,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { }, 'optional': { 'environment': { - 'required': { + 'required': { 'properties': { 'relative-humidity': {'read'} } @@ -131,7 +124,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'dehumidifier': { 'required': { 'dehumidifier': { - 'required': { + 'required': { 'properties': { 'on': {'read', 'write'} } @@ -143,7 +136,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { }, 'optional': { 'environment': { - 'required': { + 'required': { 'properties': { 'relative-humidity': {'read'} } @@ -155,15 +148,13 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'vacuum': { 'required': { 'vacuum': { - 'required': { + 'required': { 'actions': {'start-sweep', 'stop-sweeping'}, }, 'optional': { 'properties': {'status', 'fan-level'}, 'actions': { - 'pause-sweeping', - 'continue-sweep', - 'stop-and-gocharge' + 'pause-sweeping', 'continue-sweep', 'stop-and-gocharge' } } } @@ -171,7 +162,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'optional': { 'identify': { 'required': { - 'actions': {'identify'} + 'actions': {'identify'} } }, 'battery': { @@ -204,10 +195,9 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'required': {}, 'optional': { 'properties': { - 'on', - 'fan-level', - 'horizontal-swing', - 'vertical-swing'}} + 'on', 'fan-level', 'horizontal-swing', 'vertical-swing' + } + } }, 'environment': { 'required': {}, @@ -235,8 +225,8 @@ SPEC_DEVICE_TRANS_MAP: dict = { }, 'optional': { 'properties': { - 'target-temperature', 'mode', 'fan-level', - 'temperature'} + 'target-temperature', 'mode', 'fan-level', 'temperature' + } } } }, @@ -278,7 +268,7 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'ptc-bath-heater': { 'required': { 'properties': { - 'mode':{'read', 'write'} + 'mode': {'read', 'write'} } }, 'optional': { @@ -434,9 +424,7 @@ SPEC_SERVICE_TRANS_MAP: dict = { } }, 'optional': { - 'properties': { - 'mode', 'brightness', 'color', 'color-temperature' - } + 'properties': {'mode', 'brightness', 'color', 'color-temperature'} }, 'entity': 'light' }, @@ -451,7 +439,8 @@ SPEC_SERVICE_TRANS_MAP: dict = { }, 'optional': { 'properties': { - 'mode', 'brightness', + 'mode', + 'brightness', } }, 'entity': 'light', @@ -484,16 +473,14 @@ SPEC_SERVICE_TRANS_MAP: dict = { }, 'entity': 'water_heater' }, - 'curtain': { + 'curtain': { 'required': { 'properties': { 'motor-control': {'write'} } }, 'optional': { - 'properties': { - 'status', 'current-position', 'target-position' - } + 'properties': {'status', 'current-position', 'target-position'} }, 'entity': 'cover' }, @@ -683,6 +670,4 @@ SPEC_EVENT_TRANS_MAP: dict[str, str] = { 'doorbell-ring': EventDeviceClass.DOORBELL } -SPEC_ACTION_TRANS_MAP = { - -} +SPEC_ACTION_TRANS_MAP = {}