diff --git a/homeassistant/components/alert.py b/homeassistant/components/alert.py index 72689b301381..e224351f9db1 100644 --- a/homeassistant/components/alert.py +++ b/homeassistant/components/alert.py @@ -10,6 +10,8 @@ import logging import voluptuous as vol +from homeassistant.components.notify import ( + ATTR_MESSAGE, DOMAIN as DOMAIN_NOTIFY) from homeassistant.const import ( CONF_ENTITY_ID, STATE_IDLE, CONF_NAME, CONF_STATE, STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE, ATTR_ENTITY_ID) @@ -204,7 +206,7 @@ class Alert(ToggleEntity): self._send_done_message = True for target in self._notifiers: await self.hass.services.async_call( - 'notify', target, {'message': self._name}) + DOMAIN_NOTIFY, target, {ATTR_MESSAGE: self._name}) await self._schedule_notify() async def _notify_done_message(self, *args): @@ -213,7 +215,7 @@ class Alert(ToggleEntity): self._send_done_message = False for target in self._notifiers: await self.hass.services.async_call( - 'notify', target, {'message': self._done_message}) + DOMAIN_NOTIFY, target, {ATTR_MESSAGE: self._done_message}) async def async_turn_on(self, **kwargs): """Async Unacknowledge alert.""" diff --git a/homeassistant/components/device_sun_light_trigger.py b/homeassistant/components/device_sun_light_trigger.py index cd81b3a01adc..40a602056bf3 100644 --- a/homeassistant/components/device_sun_light_trigger.py +++ b/homeassistant/components/device_sun_light_trigger.py @@ -11,9 +11,11 @@ import voluptuous as vol from homeassistant.core import callback import homeassistant.util.dt as dt_util +from homeassistant.components.light import ( + ATTR_PROFILE, ATTR_TRANSITION, DOMAIN as DOMAIN_LIGHT) from homeassistant.const import ( - SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_HOME, STATE_NOT_HOME) -from homeassistant.components.light import DOMAIN as DOMAIN_LIGHT + ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_HOME, + STATE_NOT_HOME) from homeassistant.helpers.event import ( async_track_point_in_utc_time, async_track_state_change) from homeassistant.helpers.sun import is_up, get_astral_event_next @@ -88,10 +90,10 @@ async def async_setup(hass, config): return hass.async_create_task( hass.services.async_call( - DOMAIN_LIGHT, SERVICE_TURN_ON, dict( - entity_id=light_id, - transition=LIGHT_TRANSITION_TIME.seconds, - profile=light_profile))) + DOMAIN_LIGHT, SERVICE_TURN_ON, { + ATTR_ENTITY_ID: light_id, + ATTR_TRANSITION: LIGHT_TRANSITION_TIME.seconds, + ATTR_PROFILE: light_profile})) def async_turn_on_factory(light_id): """Generate turn on callbacks as factory.""" @@ -144,7 +146,7 @@ async def async_setup(hass, config): hass.async_create_task( hass.services.async_call( DOMAIN_LIGHT, SERVICE_TURN_ON, - dict(entity_id=light_ids, profile=light_profile))) + {ATTR_ENTITY_ID: light_ids, ATTR_PROFILE: light_profile})) # Are we in the time span were we would turn on the lights # if someone would be home? @@ -160,7 +162,7 @@ async def async_setup(hass, config): hass.async_create_task( hass.services.async_call( DOMAIN_LIGHT, SERVICE_TURN_ON, - dict(entity_id=light_id))) + {ATTR_ENTITY_ID: light_id})) else: # If this light didn't happen to be turned on yet so @@ -184,7 +186,7 @@ async def async_setup(hass, config): "Everyone has left but there are lights on. Turning them off") hass.async_create_task( hass.services.async_call( - DOMAIN_LIGHT, SERVICE_TURN_OFF, dict(entity_id=light_ids))) + DOMAIN_LIGHT, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: light_ids})) async_track_state_change( hass, device_group, turn_off_lights_when_all_leave, diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index a9cc122a6f90..cbf32b4cd5a7 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -15,7 +15,9 @@ from homeassistant.setup import async_prepare_setup_platform from homeassistant.core import callback from homeassistant.loader import bind_hass from homeassistant.components import group, zone -from homeassistant.components.group import DOMAIN as DOMAIN_GROUP, SERVICE_SET +from homeassistant.components.group import ( + ATTR_ADD_ENTITIES, ATTR_ENTITIES, ATTR_OBJECT_ID, ATTR_VISIBLE, + DOMAIN as DOMAIN_GROUP, SERVICE_SET) from homeassistant.components.zone.zone import async_active_zone from homeassistant.config import load_yaml_config_file, async_log_exception from homeassistant.exceptions import HomeAssistantError @@ -32,9 +34,9 @@ from homeassistant.util.yaml import dump from homeassistant.helpers.event import async_track_utc_time_change from homeassistant.const import ( - ATTR_GPS_ACCURACY, ATTR_LATITUDE, ATTR_LONGITUDE, CONF_NAME, CONF_MAC, - DEVICE_DEFAULT_NAME, STATE_HOME, STATE_NOT_HOME, ATTR_ENTITY_ID, - CONF_ICON, ATTR_ICON, ATTR_NAME) + ATTR_ENTITY_ID, ATTR_GPS_ACCURACY, ATTR_ICON, ATTR_LATITUDE, + ATTR_LONGITUDE, ATTR_NAME, CONF_ICON, CONF_MAC, CONF_NAME, + DEVICE_DEFAULT_NAME, STATE_NOT_HOME, STATE_HOME) _LOGGER = logging.getLogger(__name__) @@ -317,11 +319,11 @@ class DeviceTracker: if self.group and self.track_new: self.hass.async_create_task( self.hass.async_call( - DOMAIN_GROUP, SERVICE_SET, dict( - object_id=util.slugify(GROUP_NAME_ALL_DEVICES), - visible=False, - name=GROUP_NAME_ALL_DEVICES, - add=[device.entity_id]))) + DOMAIN_GROUP, SERVICE_SET, { + ATTR_OBJECT_ID: util.slugify(GROUP_NAME_ALL_DEVICES), + ATTR_VISIBLE: False, + ATTR_NAME: GROUP_NAME_ALL_DEVICES, + ATTR_ADD_ENTITIES: [device.entity_id]})) self.hass.bus.async_fire(EVENT_NEW_DEVICE, { ATTR_ENTITY_ID: device.entity_id, @@ -356,11 +358,11 @@ class DeviceTracker: self.hass.async_create_task( self.hass.services.async_call( - DOMAIN_GROUP, SERVICE_SET, dict( - object_id=util.slugify(GROUP_NAME_ALL_DEVICES), - visible=False, - name=GROUP_NAME_ALL_DEVICES, - entities=entity_ids))) + DOMAIN_GROUP, SERVICE_SET, { + ATTR_OBJECT_ID: util.slugify(GROUP_NAME_ALL_DEVICES), + ATTR_VISIBLE: False, + ATTR_NAME: GROUP_NAME_ALL_DEVICES, + ATTR_ENTITIES: entity_ids})) @callback def async_update_stale(self, now: dt_util.dt.datetime): diff --git a/homeassistant/components/notify/telegram.py b/homeassistant/components/notify/telegram.py index b012506acd9d..1dff82fa2cda 100644 --- a/homeassistant/components/notify/telegram.py +++ b/homeassistant/components/notify/telegram.py @@ -47,7 +47,7 @@ class TelegramNotificationService(BaseNotificationService): def send_message(self, message="", **kwargs): """Send a message to a user.""" - service_data = dict(target=kwargs.get(ATTR_TARGET, self._chat_id)) + service_data = {ATTR_TARGET: kwargs.get(ATTR_TARGET, self._chat_id)} if ATTR_TITLE in kwargs: service_data.update({ATTR_TITLE: kwargs.get(ATTR_TITLE)}) if message: diff --git a/homeassistant/components/switch/flux.py b/homeassistant/components/switch/flux.py index 793d6ab91d01..c541c37b5e77 100644 --- a/homeassistant/components/switch/flux.py +++ b/homeassistant/components/switch/flux.py @@ -13,10 +13,12 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.light import ( - is_on, DOMAIN as LIGHT_DOMAIN, VALID_TRANSITION, ATTR_TRANSITION) + is_on, ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_TRANSITION, + ATTR_WHITE_VALUE, ATTR_XY_COLOR, DOMAIN as LIGHT_DOMAIN, VALID_TRANSITION) from homeassistant.components.switch import DOMAIN, SwitchDevice from homeassistant.const import ( - CONF_NAME, CONF_PLATFORM, CONF_LIGHTS, CONF_MODE, SERVICE_TURN_ON) + ATTR_ENTITY_ID, CONF_NAME, CONF_PLATFORM, CONF_LIGHTS, CONF_MODE, + SERVICE_TURN_ON) from homeassistant.helpers.event import track_time_change from homeassistant.helpers.sun import get_astral_event_date from homeassistant.util import slugify @@ -70,12 +72,12 @@ def set_lights_xy(hass, lights, x_val, y_val, brightness, transition): for light in lights: if is_on(hass, light): hass.services.call( - LIGHT_DOMAIN, SERVICE_TURN_ON, dict( - xy_color=[x_val, y_val], - brightness=brightness, - transition=transition, - white_value=brightness, - entity_id=light)) + LIGHT_DOMAIN, SERVICE_TURN_ON, { + ATTR_XY_COLOR: [x_val, y_val], + ATTR_BRIGHTNESS: brightness, + ATTR_TRANSITION: transition, + ATTR_WHITE_VALUE: brightness, + ATTR_ENTITY_ID: light}) def set_lights_temp(hass, lights, mired, brightness, transition): @@ -83,11 +85,11 @@ def set_lights_temp(hass, lights, mired, brightness, transition): for light in lights: if is_on(hass, light): hass.services.call( - LIGHT_DOMAIN, SERVICE_TURN_ON, dict( - color_temp=int(mired), - brightness=brightness, - transition=transition, - entity_id=light)) + LIGHT_DOMAIN, SERVICE_TURN_ON, { + ATTR_COLOR_TEMP: int(mired), + ATTR_BRIGHTNESS: brightness, + ATTR_TRANSITION: transition, + ATTR_ENTITY_ID: light}) def set_lights_rgb(hass, lights, rgb, transition): @@ -95,10 +97,10 @@ def set_lights_rgb(hass, lights, rgb, transition): for light in lights: if is_on(hass, light): hass.services.call( - LIGHT_DOMAIN, SERVICE_TURN_ON, dict( - rgb_color=rgb, - transition=transition, - entity_id=light)) + LIGHT_DOMAIN, SERVICE_TURN_ON, { + ATTR_RGB_COLOR: rgb, + ATTR_TRANSITION: transition, + ATTR_ENTITY_ID: light}) def setup_platform(hass, config, add_entities, discovery_info=None):