diff --git a/homeassistant/components/fan/services.yaml b/homeassistant/components/fan/services.yaml index 3cb3db6dfe0..ee478950095 100644 --- a/homeassistant/components/fan/services.yaml +++ b/homeassistant/components/fan/services.yaml @@ -53,144 +53,3 @@ set_direction: direction: description: The direction to rotate. Either 'forward' or 'reverse' example: 'forward' - -xiaomi_miio_set_buzzer_on: - description: Turn the buzzer on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_buzzer_off: - description: Turn the buzzer off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_led_on: - description: Turn the led on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_led_off: - description: Turn the led off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_child_lock_on: - description: Turn the child lock on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_child_lock_off: - description: Turn the child lock off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_favorite_level: - description: Set the favorite level. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - level: - description: Level, between 0 and 16. - example: 1 - -xiaomi_miio_set_led_brightness: - description: Set the led brightness. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - brightness: - description: Brightness (0 = Bright, 1 = Dim, 2 = Off) - example: 1 - -xiaomi_miio_set_auto_detect_on: - description: Turn the auto detect on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_auto_detect_off: - description: Turn the auto detect off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_learn_mode_on: - description: Turn the learn mode on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_learn_mode_off: - description: Turn the learn mode off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_volume: - description: Set the sound volume. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - volume: - description: Volume, between 0 and 100. - example: 50 - -xiaomi_miio_reset_filter: - description: Reset the filter lifetime and usage. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_extra_features: - description: Manipulates a storage register which advertises extra features. The Mi Home app evaluates the value. A feature called "turbo mode" is unlocked in the app on value 1. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - features: - description: Integer, known values are 0 (default) and 1 (turbo mode). - example: 1 - -xiaomi_miio_set_target_humidity: - description: Set the target humidity. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - humidity: - description: Target humidity. Allowed values are 30, 40, 50, 60, 70 and 80. - example: 50 - -xiaomi_miio_set_dry_on: - description: Turn the dry mode on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' - -xiaomi_miio_set_dry_off: - description: Turn the dry mode off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'fan.xiaomi_miio_device' diff --git a/homeassistant/components/light/services.yaml b/homeassistant/components/light/services.yaml index 439c45962db..449e5ea5aaf 100644 --- a/homeassistant/components/light/services.yaml +++ b/homeassistant/components/light/services.yaml @@ -119,23 +119,3 @@ toggle: values: - colorloop - random - -xiaomi_miio_set_scene: - description: Set a fixed scene. - fields: - entity_id: - description: Name of the light entity. - example: "light.xiaomi_miio" - scene: - description: Number of the fixed scene, between 1 and 4. - example: 1 - -xiaomi_miio_set_delayed_turn_off: - description: Delayed turn off. - fields: - entity_id: - description: Name of the light entity. - example: "light.xiaomi_miio" - time_period: - description: Time period for the delayed turn off. - example: "5, '0:05', {'minutes': 5}" diff --git a/homeassistant/components/remote/services.yaml b/homeassistant/components/remote/services.yaml index f728b5033c8..1d712a8f285 100644 --- a/homeassistant/components/remote/services.yaml +++ b/homeassistant/components/remote/services.yaml @@ -64,16 +64,3 @@ learn_command: timeout: description: Timeout, in seconds, for the command to be learned. example: '30' - -xiaomi_miio_learn_command: - description: 'Learn an IR command, press "Call Service", point the remote at the IR device, and the learned command will be shown as a notification in Overview.' - fields: - entity_id: - description: 'Name of the entity to learn command from.' - example: 'remote.xiaomi_miio' - slot: - description: 'Define the slot used to save the IR command (Value from 1 to 1000000)' - example: '1' - timeout: - description: 'Define the timeout in seconds, before which the command must be learned.' - example: '30' diff --git a/homeassistant/components/switch/services.yaml b/homeassistant/components/switch/services.yaml index 3a30a0855f6..352ffb6feec 100644 --- a/homeassistant/components/switch/services.yaml +++ b/homeassistant/components/switch/services.yaml @@ -20,34 +20,3 @@ toggle: entity_id: description: Name(s) of entities to toggle. example: 'switch.living_room' - -xiaomi_miio_set_wifi_led_on: - description: Turn the wifi led on. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'switch.xiaomi_miio_device' -xiaomi_miio_set_wifi_led_off: - description: Turn the wifi led off. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'switch.xiaomi_miio_device' -xiaomi_miio_set_power_price: - description: Set the power price. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'switch.xiaomi_miio_device' - mode: - description: Power price, between 0 and 999. - example: 31 -xiaomi_miio_set_power_mode: - description: Set the power mode. - fields: - entity_id: - description: Name of the xiaomi miio entity. - example: 'switch.xiaomi_miio_device' - mode: - description: Power mode, valid values are 'normal' and 'green'. - example: 'green' diff --git a/homeassistant/components/vacuum/services.yaml b/homeassistant/components/vacuum/services.yaml index 792658bbdfd..7db70c5cd51 100644 --- a/homeassistant/components/vacuum/services.yaml +++ b/homeassistant/components/vacuum/services.yaml @@ -85,62 +85,3 @@ set_fan_speed: fan_speed: description: Platform dependent vacuum cleaner fan speed, with speed steps, like 'medium' or by percentage, between 0 and 100. example: 'low' - -xiaomi_remote_control_start: - description: Start remote control of the vacuum cleaner. You can then move it with `remote_control_move`, when done call `remote_control_stop`. - fields: - entity_id: - description: Name of the vacuum entity. - example: 'vacuum.xiaomi_vacuum_cleaner' - -xiaomi_remote_control_stop: - description: Stop remote control mode of the vacuum cleaner. - fields: - entity_id: - description: Name of the vacuum entity. - example: 'vacuum.xiaomi_vacuum_cleaner' - -xiaomi_remote_control_move: - description: Remote control the vacuum cleaner, make sure you first set it in remote control mode with `remote_control_start`. - fields: - entity_id: - description: Name of the vacuum entity. - example: 'vacuum.xiaomi_vacuum_cleaner' - velocity: - description: Speed, between -0.29 and 0.29. - example: '0.2' - rotation: - description: Rotation, between -179 degrees and 179 degrees. - example: '90' - duration: - description: Duration of the movement. - example: '1500' - -xiaomi_remote_control_move_step: - description: Remote control the vacuum cleaner, only makes one move and then stops. - fields: - entity_id: - description: Name of the vacuum entity. - example: 'vacuum.xiaomi_vacuum_cleaner' - velocity: - description: Speed, between -0.29 and 0.29. - example: '0.2' - rotation: - description: Rotation, between -179 degrees and 179 degrees. - example: '90' - duration: - description: Duration of the movement. - example: '1500' - -xiaomi_clean_zone: - description: Start the cleaning operation in the selected areas for the number of repeats indicated. - fields: - entity_id: - description: Name of the vacuum entity. - example: 'vacuum.xiaomi_vacuum_cleaner' - zone: - description: Array of zones. Each zone is an array of 4 integer values. - example: '[[23510,25311,25110,26362]]' - repeats: - description: Number of cleaning repeats for each zone between 1 and 3. - example: '1' diff --git a/homeassistant/components/xiaomi_miio/const.py b/homeassistant/components/xiaomi_miio/const.py new file mode 100644 index 00000000000..f8be37b313c --- /dev/null +++ b/homeassistant/components/xiaomi_miio/const.py @@ -0,0 +1,48 @@ +"""Constants for the Xiaomi Miio component.""" +DOMAIN = "xiaomi_miio" + +# Fan Services +SERVICE_SET_BUZZER_ON = "fan_set_buzzer_on" +SERVICE_SET_BUZZER_OFF = "fan_set_buzzer_off" +SERVICE_SET_LED_ON = "fan_set_led_on" +SERVICE_SET_LED_OFF = "fan_set_led_off" +SERVICE_SET_CHILD_LOCK_ON = "fan_set_child_lock_on" +SERVICE_SET_CHILD_LOCK_OFF = "fan_set_child_lock_off" +SERVICE_SET_LED_BRIGHTNESS = "fan_set_led_brightness" +SERVICE_SET_FAVORITE_LEVEL = "fan_set_favorite_level" +SERVICE_SET_AUTO_DETECT_ON = "fan_set_auto_detect_on" +SERVICE_SET_AUTO_DETECT_OFF = "fan_set_auto_detect_off" +SERVICE_SET_LEARN_MODE_ON = "fan_set_learn_mode_on" +SERVICE_SET_LEARN_MODE_OFF = "fan_set_learn_mode_off" +SERVICE_SET_VOLUME = "fan_set_volume" +SERVICE_RESET_FILTER = "fan_reset_filter" +SERVICE_SET_EXTRA_FEATURES = "fan_set_extra_features" +SERVICE_SET_TARGET_HUMIDITY = "fan_set_target_humidity" +SERVICE_SET_DRY_ON = "fan_set_dry_on" +SERVICE_SET_DRY_OFF = "fan_set_dry_off" + +# Light Services +SERVICE_SET_SCENE = "light_set_scene" +SERVICE_SET_DELAYED_TURN_OFF = "light_set_delayed_turn_off" +SERVICE_REMINDER_ON = "light_reminder_on" +SERVICE_REMINDER_OFF = "light_reminder_off" +SERVICE_NIGHT_LIGHT_MODE_ON = "light_night_light_mode_on" +SERVICE_NIGHT_LIGHT_MODE_OFF = "light_night_light_mode_off" +SERVICE_EYECARE_MODE_ON = "light_eyecare_mode_on" +SERVICE_EYECARE_MODE_OFF = "light_eyecare_mode_off" + +# Remote Services +SERVICE_LEARN = "remote_learn_command" + +# Switch Services +SERVICE_SET_WIFI_LED_ON = "switch_set_wifi_led_on" +SERVICE_SET_WIFI_LED_OFF = "switch_set_wifi_led_off" +SERVICE_SET_POWER_MODE = "switch_set_power_mode" +SERVICE_SET_POWER_PRICE = "switch_set_power_price" + +# Vacuum Services +SERVICE_MOVE_REMOTE_CONTROL = "vacuum_remote_control_move" +SERVICE_MOVE_REMOTE_CONTROL_STEP = "vacuum_remote_control_move_step" +SERVICE_START_REMOTE_CONTROL = "vacuum_remote_control_start" +SERVICE_STOP_REMOTE_CONTROL = "vacuum_remote_control_stop" +SERVICE_CLEAN_ZONE = "vacuum_clean_zone" diff --git a/homeassistant/components/xiaomi_miio/fan.py b/homeassistant/components/xiaomi_miio/fan.py index 9e496893d56..91b18aaf364 100644 --- a/homeassistant/components/xiaomi_miio/fan.py +++ b/homeassistant/components/xiaomi_miio/fan.py @@ -26,12 +26,7 @@ from miio.airpurifier import ( # pylint: disable=import-error; pylint: disable= OperationMode as AirpurifierOperationMode, ) -from homeassistant.components.fan import ( - DOMAIN, - PLATFORM_SCHEMA, - SUPPORT_SET_SPEED, - FanEntity, -) +from homeassistant.components.fan import PLATFORM_SCHEMA, SUPPORT_SET_SPEED, FanEntity from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_MODE, @@ -42,6 +37,28 @@ from homeassistant.const import ( from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv +from .const import ( + DOMAIN, + SERVICE_SET_BUZZER_ON, + SERVICE_SET_BUZZER_OFF, + SERVICE_SET_LED_ON, + SERVICE_SET_LED_OFF, + SERVICE_SET_CHILD_LOCK_ON, + SERVICE_SET_CHILD_LOCK_OFF, + SERVICE_SET_LED_BRIGHTNESS, + SERVICE_SET_FAVORITE_LEVEL, + SERVICE_SET_AUTO_DETECT_ON, + SERVICE_SET_AUTO_DETECT_OFF, + SERVICE_SET_LEARN_MODE_ON, + SERVICE_SET_LEARN_MODE_OFF, + SERVICE_SET_VOLUME, + SERVICE_RESET_FILTER, + SERVICE_SET_EXTRA_FEATURES, + SERVICE_SET_TARGET_HUMIDITY, + SERVICE_SET_DRY_ON, + SERVICE_SET_DRY_OFF, +) + _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Xiaomi Miio Device" @@ -368,25 +385,6 @@ FEATURE_FLAGS_AIRFRESH = ( | FEATURE_SET_EXTRA_FEATURES ) -SERVICE_SET_BUZZER_ON = "xiaomi_miio_set_buzzer_on" -SERVICE_SET_BUZZER_OFF = "xiaomi_miio_set_buzzer_off" -SERVICE_SET_LED_ON = "xiaomi_miio_set_led_on" -SERVICE_SET_LED_OFF = "xiaomi_miio_set_led_off" -SERVICE_SET_CHILD_LOCK_ON = "xiaomi_miio_set_child_lock_on" -SERVICE_SET_CHILD_LOCK_OFF = "xiaomi_miio_set_child_lock_off" -SERVICE_SET_LED_BRIGHTNESS = "xiaomi_miio_set_led_brightness" -SERVICE_SET_FAVORITE_LEVEL = "xiaomi_miio_set_favorite_level" -SERVICE_SET_AUTO_DETECT_ON = "xiaomi_miio_set_auto_detect_on" -SERVICE_SET_AUTO_DETECT_OFF = "xiaomi_miio_set_auto_detect_off" -SERVICE_SET_LEARN_MODE_ON = "xiaomi_miio_set_learn_mode_on" -SERVICE_SET_LEARN_MODE_OFF = "xiaomi_miio_set_learn_mode_off" -SERVICE_SET_VOLUME = "xiaomi_miio_set_volume" -SERVICE_RESET_FILTER = "xiaomi_miio_reset_filter" -SERVICE_SET_EXTRA_FEATURES = "xiaomi_miio_set_extra_features" -SERVICE_SET_TARGET_HUMIDITY = "xiaomi_miio_set_target_humidity" -SERVICE_SET_DRY_ON = "xiaomi_miio_set_dry_on" -SERVICE_SET_DRY_OFF = "xiaomi_miio_set_dry_off" - AIRPURIFIER_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID): cv.entity_ids}) SERVICE_SCHEMA_LED_BRIGHTNESS = AIRPURIFIER_SERVICE_SCHEMA.extend( diff --git a/homeassistant/components/xiaomi_miio/light.py b/homeassistant/components/xiaomi_miio/light.py index 5b454512f33..2343a6787c2 100644 --- a/homeassistant/components/xiaomi_miio/light.py +++ b/homeassistant/components/xiaomi_miio/light.py @@ -21,7 +21,6 @@ from homeassistant.components.light import ( ATTR_COLOR_TEMP, ATTR_ENTITY_ID, ATTR_HS_COLOR, - DOMAIN, PLATFORM_SCHEMA, SUPPORT_BRIGHTNESS, SUPPORT_COLOR, @@ -33,6 +32,18 @@ from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv from homeassistant.util import color, dt +from .const import ( + DOMAIN, + SERVICE_SET_SCENE, + SERVICE_SET_DELAYED_TURN_OFF, + SERVICE_REMINDER_ON, + SERVICE_REMINDER_OFF, + SERVICE_NIGHT_LIGHT_MODE_ON, + SERVICE_NIGHT_LIGHT_MODE_OFF, + SERVICE_EYECARE_MODE_ON, + SERVICE_EYECARE_MODE_OFF, +) + _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Xiaomi Philips Light" @@ -85,15 +96,6 @@ ATTR_TOTAL_ASSISTANT_SLEEP_TIME = "total_assistant_sleep_time" ATTR_BRAND_SLEEP = "brand_sleep" ATTR_BRAND = "brand" -SERVICE_SET_SCENE = "xiaomi_miio_set_scene" -SERVICE_SET_DELAYED_TURN_OFF = "xiaomi_miio_set_delayed_turn_off" -SERVICE_REMINDER_ON = "xiaomi_miio_reminder_on" -SERVICE_REMINDER_OFF = "xiaomi_miio_reminder_off" -SERVICE_NIGHT_LIGHT_MODE_ON = "xiaomi_miio_night_light_mode_on" -SERVICE_NIGHT_LIGHT_MODE_OFF = "xiaomi_miio_night_light_mode_off" -SERVICE_EYECARE_MODE_ON = "xiaomi_miio_eyecare_mode_on" -SERVICE_EYECARE_MODE_OFF = "xiaomi_miio_eyecare_mode_off" - XIAOMI_MIIO_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID): cv.entity_ids}) SERVICE_SCHEMA_SET_SCENE = XIAOMI_MIIO_SERVICE_SCHEMA.extend( diff --git a/homeassistant/components/xiaomi_miio/remote.py b/homeassistant/components/xiaomi_miio/remote.py index 0e2ac476e05..1e7cada1a7b 100644 --- a/homeassistant/components/xiaomi_miio/remote.py +++ b/homeassistant/components/xiaomi_miio/remote.py @@ -11,7 +11,6 @@ from homeassistant.components.remote import ( ATTR_DELAY_SECS, ATTR_NUM_REPEATS, DEFAULT_DELAY_SECS, - DOMAIN, PLATFORM_SCHEMA, RemoteDevice, ) @@ -28,9 +27,10 @@ from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv from homeassistant.util.dt import utcnow +from .const import DOMAIN, SERVICE_LEARN + _LOGGER = logging.getLogger(__name__) -SERVICE_LEARN = "xiaomi_miio_learn_command" DATA_KEY = "remote.xiaomi_miio" CONF_SLOT = "slot" diff --git a/homeassistant/components/xiaomi_miio/services.yaml b/homeassistant/components/xiaomi_miio/services.yaml index e69de29bb2d..36dcbc950be 100644 --- a/homeassistant/components/xiaomi_miio/services.yaml +++ b/homeassistant/components/xiaomi_miio/services.yaml @@ -0,0 +1,308 @@ +fan_set_buzzer_on: + description: Turn the buzzer on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_buzzer_off: + description: Turn the buzzer off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_led_on: + description: Turn the led on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_led_off: + description: Turn the led off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_child_lock_on: + description: Turn the child lock on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_child_lock_off: + description: Turn the child lock off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_favorite_level: + description: Set the favorite level. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + level: + description: Level, between 0 and 16. + example: 1 + +fan_set_led_brightness: + description: Set the led brightness. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + brightness: + description: Brightness (0 = Bright, 1 = Dim, 2 = Off) + example: 1 + +fan_set_auto_detect_on: + description: Turn the auto detect on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_auto_detect_off: + description: Turn the auto detect off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_learn_mode_on: + description: Turn the learn mode on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_learn_mode_off: + description: Turn the learn mode off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_volume: + description: Set the sound volume. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + volume: + description: Volume, between 0 and 100. + example: 50 + +fan_reset_filter: + description: Reset the filter lifetime and usage. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_extra_features: + description: Manipulates a storage register which advertises extra features. The Mi Home app evaluates the value. A feature called "turbo mode" is unlocked in the app on value 1. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + features: + description: Integer, known values are 0 (default) and 1 (turbo mode). + example: 1 + +fan_set_target_humidity: + description: Set the target humidity. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + humidity: + description: Target humidity. Allowed values are 30, 40, 50, 60, 70 and 80. + example: 50 + +fan_set_dry_on: + description: Turn the dry mode on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +fan_set_dry_off: + description: Turn the dry mode off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'fan.xiaomi_miio_device' + +light_set_scene: + description: Set a fixed scene. + fields: + entity_id: + description: Name of the light entity. + example: "light.xiaomi_miio" + scene: + description: Number of the fixed scene, between 1 and 4. + example: 1 + +light_set_delayed_turn_off: + description: Delayed turn off. + fields: + entity_id: + description: Name of the light entity. + example: "light.xiaomi_miio" + time_period: + description: Time period for the delayed turn off. + example: "5, '0:05', {'minutes': 5}" + +light_reminder_on: + description: Enable the eye fatigue reminder/notification (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +light_reminder_off: + description: Disable the eye fatigue reminder/notification (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +light_night_light_mode_on: + description: Turn the eyecare mode on (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +light_night_light_mode_off: + description: Turn the eyecare mode fan_set_dry_off (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +light_eyecare_mode_on: + description: Enable the eye fatigue reminder/notification (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +light_eyecare_mode_off: + description: Disable the eye fatigue reminder/notification (EYECARE SMART LAMP 2 ONLY). + fields: + entity_id: + description: 'Name of the entity to act on.' + example: 'light.xiaomi_miio' + +remote_learn_command: + description: 'Learn an IR command, press "Call Service", point the remote at the IR device, and the learned command will be shown as a notification in Overview.' + fields: + entity_id: + description: 'Name of the entity to learn command from.' + example: 'remote.xiaomi_miio' + slot: + description: 'Define the slot used to save the IR command (Value from 1 to 1000000)' + example: '1' + timeout: + description: 'Define the timeout in seconds, before which the command must be learned.' + example: '30' + +switch_set_wifi_led_on: + description: Turn the wifi led on. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'switch.xiaomi_miio_device' + +switch_set_wifi_led_off: + description: Turn the wifi led off. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'switch.xiaomi_miio_device' + +switch_set_power_price: + description: Set the power price. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'switch.xiaomi_miio_device' + mode: + description: Power price, between 0 and 999. + example: 31 + +switch_set_power_mode: + description: Set the power mode. + fields: + entity_id: + description: Name of the xiaomi miio entity. + example: 'switch.xiaomi_miio_device' + mode: + description: Power mode, valid values are 'normal' and 'green'. + example: 'green' + +vacuum_remote_control_start: + description: Start remote control of the vacuum cleaner. You can then move it with `remote_control_move`, when done call `remote_control_stop`. + fields: + entity_id: + description: Name of the vacuum entity. + example: 'vacuum.xiaomi_vacuum_cleaner' + +vacuum_remote_control_stop: + description: Stop remote control mode of the vacuum cleaner. + fields: + entity_id: + description: Name of the vacuum entity. + example: 'vacuum.xiaomi_vacuum_cleaner' + +vacuum_remote_control_move: + description: Remote control the vacuum cleaner, make sure you first set it in remote control mode with `remote_control_start`. + fields: + entity_id: + description: Name of the vacuum entity. + example: 'vacuum.xiaomi_vacuum_cleaner' + velocity: + description: Speed, between -0.29 and 0.29. + example: '0.2' + rotation: + description: Rotation, between -179 degrees and 179 degrees. + example: '90' + duration: + description: Duration of the movement. + example: '1500' + +vacuum_remote_control_move_step: + description: Remote control the vacuum cleaner, only makes one move and then stops. + fields: + entity_id: + description: Name of the vacuum entity. + example: 'vacuum.xiaomi_vacuum_cleaner' + velocity: + description: Speed, between -0.29 and 0.29. + example: '0.2' + rotation: + description: Rotation, between -179 degrees and 179 degrees. + example: '90' + duration: + description: Duration of the movement. + example: '1500' + +vacuum_clean_zone: + description: Start the cleaning operation in the selected areas for the number of repeats indicated. + fields: + entity_id: + description: Name of the vacuum entity. + example: 'vacuum.xiaomi_vacuum_cleaner' + zone: + description: Array of zones. Each zone is an array of 4 integer values. + example: '[[23510,25311,25110,26362]]' + repeats: + description: Number of cleaning repeats for each zone between 1 and 3. + example: '1' diff --git a/homeassistant/components/xiaomi_miio/switch.py b/homeassistant/components/xiaomi_miio/switch.py index 023243a1995..f9a06924b5c 100644 --- a/homeassistant/components/xiaomi_miio/switch.py +++ b/homeassistant/components/xiaomi_miio/switch.py @@ -13,7 +13,7 @@ from miio import ( # pylint: disable=import-error from miio.powerstrip import PowerMode # pylint: disable=import-error import voluptuous as vol -from homeassistant.components.switch import DOMAIN, PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_MODE, @@ -24,6 +24,14 @@ from homeassistant.const import ( from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv +from .const import ( + DOMAIN, + SERVICE_SET_WIFI_LED_ON, + SERVICE_SET_WIFI_LED_OFF, + SERVICE_SET_POWER_MODE, + SERVICE_SET_POWER_PRICE, +) + _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Xiaomi Miio Switch" @@ -80,11 +88,6 @@ FEATURE_FLAGS_POWER_STRIP_V2 = FEATURE_SET_WIFI_LED | FEATURE_SET_POWER_PRICE FEATURE_FLAGS_PLUG_V3 = FEATURE_SET_WIFI_LED -SERVICE_SET_WIFI_LED_ON = "xiaomi_miio_set_wifi_led_on" -SERVICE_SET_WIFI_LED_OFF = "xiaomi_miio_set_wifi_led_off" -SERVICE_SET_POWER_MODE = "xiaomi_miio_set_power_mode" -SERVICE_SET_POWER_PRICE = "xiaomi_miio_set_power_price" - SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID): cv.entity_ids}) SERVICE_SCHEMA_POWER_MODE = SERVICE_SCHEMA.extend( diff --git a/homeassistant/components/xiaomi_miio/vacuum.py b/homeassistant/components/xiaomi_miio/vacuum.py index 0320a2e4906..f1845f534bb 100644 --- a/homeassistant/components/xiaomi_miio/vacuum.py +++ b/homeassistant/components/xiaomi_miio/vacuum.py @@ -8,7 +8,6 @@ import voluptuous as vol from homeassistant.components.vacuum import ( ATTR_CLEANED_AREA, - DOMAIN, PLATFORM_SCHEMA, STATE_CLEANING, STATE_DOCKED, @@ -38,6 +37,15 @@ from homeassistant.const import ( ) import homeassistant.helpers.config_validation as cv +from .const import ( + DOMAIN, + SERVICE_MOVE_REMOTE_CONTROL, + SERVICE_MOVE_REMOTE_CONTROL_STEP, + SERVICE_START_REMOTE_CONTROL, + SERVICE_STOP_REMOTE_CONTROL, + SERVICE_CLEAN_ZONE, +) + _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Xiaomi Vacuum cleaner" @@ -52,12 +60,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( extra=vol.ALLOW_EXTRA, ) -SERVICE_MOVE_REMOTE_CONTROL = "xiaomi_remote_control_move" -SERVICE_MOVE_REMOTE_CONTROL_STEP = "xiaomi_remote_control_move_step" -SERVICE_START_REMOTE_CONTROL = "xiaomi_remote_control_start" -SERVICE_STOP_REMOTE_CONTROL = "xiaomi_remote_control_stop" -SERVICE_CLEAN_ZONE = "xiaomi_clean_zone" - FAN_SPEEDS = {"Quiet": 38, "Balanced": 60, "Turbo": 77, "Max": 90, "Gentle": 105} ATTR_CLEAN_START = "clean_start" diff --git a/tests/components/xiaomi_miio/test_vacuum.py b/tests/components/xiaomi_miio/test_vacuum.py index 040e04b3c83..5b6ce578c8b 100644 --- a/tests/components/xiaomi_miio/test_vacuum.py +++ b/tests/components/xiaomi_miio/test_vacuum.py @@ -36,6 +36,7 @@ from homeassistant.components.xiaomi_miio.vacuum import ( CONF_HOST, CONF_NAME, CONF_TOKEN, + DOMAIN as XIAOMI_DOMAIN, SERVICE_MOVE_REMOTE_CONTROL, SERVICE_MOVE_REMOTE_CONTROL_STEP, SERVICE_START_REMOTE_CONTROL, @@ -366,7 +367,10 @@ def test_xiaomi_specific_services(hass, caplog, mock_mirobo_is_on): # Xiaomi vacuum specific services: yield from hass.services.async_call( - DOMAIN, SERVICE_START_REMOTE_CONTROL, {ATTR_ENTITY_ID: entity_id}, blocking=True + XIAOMI_DOMAIN, + SERVICE_START_REMOTE_CONTROL, + {ATTR_ENTITY_ID: entity_id}, + blocking=True, ) mock_mirobo_is_on.assert_has_calls([mock.call.manual_start()], any_order=True) @@ -375,7 +379,7 @@ def test_xiaomi_specific_services(hass, caplog, mock_mirobo_is_on): control = {"duration": 1000, "rotation": -40, "velocity": -0.1} yield from hass.services.async_call( - DOMAIN, SERVICE_MOVE_REMOTE_CONTROL, control, blocking=True + XIAOMI_DOMAIN, SERVICE_MOVE_REMOTE_CONTROL, control, blocking=True ) mock_mirobo_is_on.manual_control.assert_has_calls( [mock.call(**control)], any_order=True @@ -384,7 +388,7 @@ def test_xiaomi_specific_services(hass, caplog, mock_mirobo_is_on): mock_mirobo_is_on.reset_mock() yield from hass.services.async_call( - DOMAIN, SERVICE_STOP_REMOTE_CONTROL, {}, blocking=True + XIAOMI_DOMAIN, SERVICE_STOP_REMOTE_CONTROL, {}, blocking=True ) mock_mirobo_is_on.assert_has_calls([mock.call.manual_stop()], any_order=True) mock_mirobo_is_on.assert_has_calls(STATUS_CALLS, any_order=True) @@ -392,7 +396,7 @@ def test_xiaomi_specific_services(hass, caplog, mock_mirobo_is_on): control_once = {"duration": 2000, "rotation": 120, "velocity": 0.1} yield from hass.services.async_call( - DOMAIN, SERVICE_MOVE_REMOTE_CONTROL_STEP, control_once, blocking=True + XIAOMI_DOMAIN, SERVICE_MOVE_REMOTE_CONTROL_STEP, control_once, blocking=True ) mock_mirobo_is_on.manual_control_once.assert_has_calls( [mock.call(**control_once)], any_order=True @@ -402,7 +406,7 @@ def test_xiaomi_specific_services(hass, caplog, mock_mirobo_is_on): control = {"zone": [[123, 123, 123, 123]], "repeats": 2} yield from hass.services.async_call( - DOMAIN, SERVICE_CLEAN_ZONE, control, blocking=True + XIAOMI_DOMAIN, SERVICE_CLEAN_ZONE, control, blocking=True ) mock_mirobo_is_on.zoned_clean.assert_has_calls( [mock.call([[123, 123, 123, 123, 2]])], any_order=True