move icloud services to icloud domain (#29144)

This commit is contained in:
Raman Gupta 2019-11-27 05:16:53 -05:00 committed by Pascal Vizeli
parent b8f03aa3be
commit ff4d256893
5 changed files with 58 additions and 45 deletions

View file

@ -316,7 +316,7 @@ omit =
homeassistant/components/iaqualink/light.py
homeassistant/components/iaqualink/sensor.py
homeassistant/components/iaqualink/switch.py
homeassistant/components/icloud/device_tracker.py
homeassistant/components/icloud/*
homeassistant/components/izone/climate.py
homeassistant/components/izone/discovery.py
homeassistant/components/izone/__init__.py

View file

@ -24,40 +24,3 @@ see:
battery:
description: Battery level of device.
example: '100'
icloud_lost_iphone:
description: Service to play the lost iphone sound on an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will play the sound. This is optional, if it isn't given it will play on all devices for the given account.
example: 'iphonebart'
icloud_set_interval:
description: Service to set the interval of an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will get a new interval. This is optional, if it isn't given it will change the interval for all devices for the given account.
example: 'iphonebart'
interval:
description: The interval (in minutes) that the iDevice will have until the according device_tracker entity changes from zone or until this service is used again. This is optional, if it isn't given the interval of the device will revert back to the original interval based on the current state.
example: 1
icloud_update:
description: Service to ask for an update of an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will be updated. This is optional, if it isn't given it will update all devices for the given account.
example: 'iphonebart'
icloud_reset_account:
description: Service to restart an iCloud account. Helpful when not all devices are found after initializing or when you add a new device.
fields:
account_name:
description: Name of the account in the config that will be restarted. This is optional, if it isn't given it will restart all accounts.
example: 'bart'

View file

@ -0,0 +1,6 @@
"""Constants for the iCloud component."""
DOMAIN = "icloud"
SERVICE_LOST_IPHONE = "lost_iphone"
SERVICE_UPDATE = "update"
SERVICE_RESET_ACCOUNT = "reset_account"
SERVICE_SET_INTERVAL = "set_interval"

View file

@ -14,7 +14,6 @@ import voluptuous as vol
from homeassistant.components.device_tracker import PLATFORM_SCHEMA
from homeassistant.components.device_tracker.const import (
ATTR_ATTRIBUTES,
DOMAIN,
ENTITY_ID_FORMAT,
)
from homeassistant.components.device_tracker.legacy import DeviceScanner
@ -27,6 +26,14 @@ from homeassistant.util.async_ import run_callback_threadsafe
import homeassistant.util.dt as dt_util
from homeassistant.util.location import distance
from .const import (
DOMAIN,
SERVICE_LOST_IPHONE,
SERVICE_RESET_ACCOUNT,
SERVICE_SET_INTERVAL,
SERVICE_UPDATE,
)
_LOGGER = logging.getLogger(__name__)
CONF_ACCOUNTNAME = "account_name"
@ -144,7 +151,7 @@ def setup_scanner(hass, config: dict, see, discovery_info=None):
ICLOUDTRACKERS[account].lost_iphone(devicename)
hass.services.register(
DOMAIN, "icloud_lost_iphone", lost_iphone, schema=SERVICE_SCHEMA
DOMAIN, SERVICE_LOST_IPHONE, lost_iphone, schema=SERVICE_SCHEMA
)
def update_icloud(call):
@ -155,9 +162,7 @@ def setup_scanner(hass, config: dict, see, discovery_info=None):
if account in ICLOUDTRACKERS:
ICLOUDTRACKERS[account].update_icloud(devicename)
hass.services.register(
DOMAIN, "icloud_update", update_icloud, schema=SERVICE_SCHEMA
)
hass.services.register(DOMAIN, SERVICE_UPDATE, update_icloud, schema=SERVICE_SCHEMA)
def reset_account_icloud(call):
"""Reset an iCloud account."""
@ -167,7 +172,7 @@ def setup_scanner(hass, config: dict, see, discovery_info=None):
ICLOUDTRACKERS[account].reset_account_icloud()
hass.services.register(
DOMAIN, "icloud_reset_account", reset_account_icloud, schema=SERVICE_SCHEMA
DOMAIN, SERVICE_RESET_ACCOUNT, reset_account_icloud, schema=SERVICE_SCHEMA
)
def setinterval(call):
@ -180,7 +185,7 @@ def setup_scanner(hass, config: dict, see, discovery_info=None):
ICLOUDTRACKERS[account].setinterval(interval, devicename)
hass.services.register(
DOMAIN, "icloud_set_interval", setinterval, schema=SERVICE_SCHEMA
DOMAIN, SERVICE_SET_INTERVAL, setinterval, schema=SERVICE_SCHEMA
)
# Tells the bootstrapper that the component was successfully initialized

View file

@ -0,0 +1,39 @@
lost_iphone:
description: Service to play the lost iphone sound on an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will play the sound. This is optional, if it isn't given it will play on all devices for the given account.
example: 'iphonebart'
set_interval:
description: Service to set the interval of an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will get a new interval. This is optional, if it isn't given it will change the interval for all devices for the given account.
example: 'iphonebart'
interval:
description: The interval (in minutes) that the iDevice will have until the according device_tracker entity changes from zone or until this service is used again. This is optional, if it isn't given the interval of the device will revert back to the original interval based on the current state.
example: 1
update:
description: Service to ask for an update of an iDevice.
fields:
account_name:
description: Name of the account in the config that will be used to look for the device. This is optional, if it isn't given it will use all accounts.
example: 'bart'
device_name:
description: Name of the device that will be updated. This is optional, if it isn't given it will update all devices for the given account.
example: 'iphonebart'
reset_account:
description: Service to restart an iCloud account. Helpful when not all devices are found after initializing or when you add a new device.
fields:
account_name:
description: Name of the account in the config that will be restarted. This is optional, if it isn't given it will restart all accounts.
example: 'bart'