Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update service domain for icloud from 'device_tracker' to 'icloud' #29144

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 0 additions & 37 deletions homeassistant/components/device_tracker/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 6 additions & 0 deletions homeassistant/components/icloud/const.py
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 12 additions & 7 deletions homeassistant/components/icloud/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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
Expand All @@ -27,6 +26,14 @@
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"
Expand Down Expand Up @@ -144,7 +151,7 @@ def lost_iphone(call):
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):
Expand All @@ -155,9 +162,7 @@ def update_icloud(call):
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."""
Expand All @@ -167,7 +172,7 @@ def reset_account_icloud(call):
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):
Expand All @@ -180,7 +185,7 @@ def setinterval(call):
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
Expand Down
39 changes: 39 additions & 0 deletions homeassistant/components/icloud/services.yaml
Original file line number Diff line number Diff line change
@@ -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'