From 1f13809c6d70b557dc105ff2d6f687d77b6712e5 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Wed, 27 Nov 2019 05:23:07 -0500 Subject: [PATCH] Update service domain for lifx from 'light' to 'lifx' (#29136) * update service domain for lifx custom services * fix service name --- homeassistant/components/lifx/light.py | 23 +++--- homeassistant/components/lifx/services.yaml | 77 +++++++++++++++++++ homeassistant/components/light/services.yaml | 78 -------------------- 3 files changed, 90 insertions(+), 88 deletions(-) diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index 50e36e8db0a..7b33e0c1d86 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -60,7 +60,7 @@ MESSAGE_TIMEOUT = 1.0 MESSAGE_RETRIES = 8 UNAVAILABLE_GRACE = 90 -SERVICE_LIFX_SET_STATE = "lifx_set_state" +SERVICE_LIFX_SET_STATE = "set_state" ATTR_INFRARED = "infrared" ATTR_ZONES = "zones" @@ -74,9 +74,9 @@ LIFX_SET_STATE_SCHEMA = LIGHT_TURN_ON_SCHEMA.extend( } ) -SERVICE_EFFECT_PULSE = "lifx_effect_pulse" -SERVICE_EFFECT_COLORLOOP = "lifx_effect_colorloop" -SERVICE_EFFECT_STOP = "lifx_effect_stop" +SERVICE_EFFECT_PULSE = "effect_pulse" +SERVICE_EFFECT_COLORLOOP = "effect_colorloop" +SERVICE_EFFECT_STOP = "effect_stop" ATTR_POWER_ON = "power_on" ATTR_PERIOD = "period" @@ -282,7 +282,7 @@ class LIFXManager: SERVICE_EFFECT_PULSE, SERVICE_EFFECT_COLORLOOP, ]: - self.hass.services.async_remove(DOMAIN, service) + self.hass.services.async_remove(LIFX_DOMAIN, service) def register_set_state(self): """Register the LIFX set_state service call.""" @@ -298,7 +298,7 @@ class LIFXManager: await asyncio.wait(tasks) self.hass.services.async_register( - DOMAIN, + LIFX_DOMAIN, SERVICE_LIFX_SET_STATE, service_handler, schema=LIFX_SET_STATE_SCHEMA, @@ -314,21 +314,24 @@ class LIFXManager: await self.start_effect(entities, service.service, **service.data) self.hass.services.async_register( - DOMAIN, + LIFX_DOMAIN, SERVICE_EFFECT_PULSE, service_handler, schema=LIFX_EFFECT_PULSE_SCHEMA, ) self.hass.services.async_register( - DOMAIN, + LIFX_DOMAIN, SERVICE_EFFECT_COLORLOOP, service_handler, schema=LIFX_EFFECT_COLORLOOP_SCHEMA, ) self.hass.services.async_register( - DOMAIN, SERVICE_EFFECT_STOP, service_handler, schema=LIFX_EFFECT_STOP_SCHEMA + LIFX_DOMAIN, + SERVICE_EFFECT_STOP, + service_handler, + schema=LIFX_EFFECT_STOP_SCHEMA, ) async def start_effect(self, entities, service, **kwargs): @@ -652,7 +655,7 @@ class LIFXLight(Light): """Start an effect with default parameters.""" service = kwargs[ATTR_EFFECT] data = {ATTR_ENTITY_ID: self.entity_id} - await self.hass.services.async_call(DOMAIN, service, data) + await self.hass.services.async_call(LIFX_DOMAIN, service, data) async def async_update(self): """Update bulb status.""" diff --git a/homeassistant/components/lifx/services.yaml b/homeassistant/components/lifx/services.yaml index e69de29bb2d..ebf2032a9a5 100644 --- a/homeassistant/components/lifx/services.yaml +++ b/homeassistant/components/lifx/services.yaml @@ -0,0 +1,77 @@ +set_state: + description: Set a color/brightness and possibliy turn the light on/off. + fields: + entity_id: + description: Name(s) of entities to set a state on. + example: "light.garage" + "...": + description: All turn_on parameters can be used to specify a color. + infrared: + description: Automatic infrared level (0..255) when light brightness is low. + example: 255 + zones: + description: List of zone numbers to affect (8 per LIFX Z, starts at 0). + example: "[0,5]" + transition: + description: Duration in seconds it takes to get to the final state. + example: 10 + power: + description: Turn the light on (True) or off (False). Leave out to keep the power as it is. + example: True + +effect_pulse: + description: Run a flash effect by changing to a color and back. + fields: + entity_id: + description: Name(s) of entities to run the effect on. + example: "light.kitchen" + mode: + description: "Decides how colors are changed. Possible values: blink, breathe, ping, strobe, solid." + example: strobe + brightness: + description: Number between 0..255 indicating brightness of the temporary color. + example: 120 + color_name: + description: A human readable color name. + example: "red" + rgb_color: + description: The temporary color in RGB-format. + example: "[255, 100, 100]" + period: + description: Duration of the effect in seconds (default 1.0). + example: 3 + cycles: + description: Number of times the effect should run (default 1.0). + example: 2 + power_on: + description: Powered off lights are temporarily turned on during the effect (default True). + example: False + +effect_colorloop: + description: Run an effect with looping colors. + fields: + entity_id: + description: Name(s) of entities to run the effect on. + example: "light.disco1, light.disco2, light.disco3" + brightness: + description: Number between 0 and 255 indicating brightness of the effect. Leave this out to maintain the current brightness of each participating light. + example: 120 + period: + description: Duration (in seconds) between color changes (default 60). + example: 180 + change: + description: Hue movement per period, in degrees on a color wheel (ranges from 0 to 360, default 20). + example: 45 + spread: + description: Maximum hue difference between participating lights, in degrees on a color wheel (ranges from 0 to 360, default 30). + example: 0 + power_on: + description: Powered off lights are temporarily turned on during the effect (default True). + example: False + +effect_stop: + description: Stop a running effect. + fields: + entity_id: + description: Name(s) of entities to stop effects on. Leave out to stop effects everywhere. + example: "light.bedroom" diff --git a/homeassistant/components/light/services.yaml b/homeassistant/components/light/services.yaml index 9173f79f964..439c45962db 100644 --- a/homeassistant/components/light/services.yaml +++ b/homeassistant/components/light/services.yaml @@ -120,84 +120,6 @@ toggle: - colorloop - random -lifx_set_state: - description: Set a color/brightness and possibliy turn the light on/off. - fields: - entity_id: - description: Name(s) of entities to set a state on. - example: "light.garage" - "...": - description: All turn_on parameters can be used to specify a color. - infrared: - description: Automatic infrared level (0..255) when light brightness is low. - example: 255 - zones: - description: List of zone numbers to affect (8 per LIFX Z, starts at 0). - example: "[0,5]" - transition: - description: Duration in seconds it takes to get to the final state. - example: 10 - power: - description: Turn the light on (True) or off (False). Leave out to keep the power as it is. - example: True - -lifx_effect_pulse: - description: Run a flash effect by changing to a color and back. - fields: - entity_id: - description: Name(s) of entities to run the effect on. - example: "light.kitchen" - mode: - description: "Decides how colors are changed. Possible values: blink, breathe, ping, strobe, solid." - example: strobe - brightness: - description: Number between 0..255 indicating brightness of the temporary color. - example: 120 - color_name: - description: A human readable color name. - example: "red" - rgb_color: - description: The temporary color in RGB-format. - example: "[255, 100, 100]" - period: - description: Duration of the effect in seconds (default 1.0). - example: 3 - cycles: - description: Number of times the effect should run (default 1.0). - example: 2 - power_on: - description: Powered off lights are temporarily turned on during the effect (default True). - example: False - -lifx_effect_colorloop: - description: Run an effect with looping colors. - fields: - entity_id: - description: Name(s) of entities to run the effect on. - example: "light.disco1, light.disco2, light.disco3" - brightness: - description: Number between 0 and 255 indicating brightness of the effect. Leave this out to maintain the current brightness of each participating light. - example: 120 - period: - description: Duration (in seconds) between color changes (default 60). - example: 180 - change: - description: Hue movement per period, in degrees on a color wheel (ranges from 0 to 360, default 20). - example: 45 - spread: - description: Maximum hue difference between participating lights, in degrees on a color wheel (ranges from 0 to 360, default 30). - example: 0 - power_on: - description: Powered off lights are temporarily turned on during the effect (default True). - example: False - -lifx_effect_stop: - description: Stop a running effect. - fields: - entity_id: - description: Name(s) of entities to stop effects on. Leave out to stop effects everywhere. - example: "light.bedroom" - xiaomi_miio_set_scene: description: Set a fixed scene. fields: