Skip to content
Closed
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
5 changes: 1 addition & 4 deletions homeassistant/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@
ATTR_FLASH: vol.In([FLASH_SHORT, FLASH_LONG]),
})

LIGHT_TOGGLE_SCHEMA = vol.Schema({
ATTR_ENTITY_ID: cv.entity_ids,
ATTR_TRANSITION: VALID_TRANSITION,
})
LIGHT_TOGGLE_SCHEMA = LIGHT_TURN_ON_SCHEMA
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove this, extend your Schema.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the schema from turn_on


PROFILE_SCHEMA = vol.Schema(
vol.ExactSequence((str, cv.small_float, cv.small_float, cv.byte))
Expand Down
40 changes: 40 additions & 0 deletions homeassistant/components/light/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,46 @@ toggle:
description: Duration in seconds it takes to get to next state
example: 60

rgb_color:
Copy link
Copy Markdown
Member

@pvizeli pvizeli Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't copy stuff. Make a comment of possibility

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should I do this?

description: Color for the light in RGB-format
example: '[255, 100, 100]'

color_name:
description: A human readable color name
example: 'red'

xy_color:
description: Color for the light in XY-format
example: '[0.52, 0.43]'

color_temp:
description: Color temperature for the light in mireds (154-500)
example: '250'

white_value:
description: Number between 0..255 indicating level of white
example: '250'

brightness:
description: Number between 0..255 indicating brightness
example: 120

profile:
description: Name of a light profile to use
example: relax

flash:
description: If the light should flash
values:
- short
- long

effect:
description: Light effect
values:
- colorloop
- random

hue_activate_scene:
description: Activate a hue scene stored in the hue hub

Expand Down
13 changes: 7 additions & 6 deletions homeassistant/helpers/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,20 @@ def async_turn_off(self, **kwargs):
return self.hass.loop.run_in_executor(
None, ft.partial(self.turn_off, **kwargs))

def toggle(self) -> None:
def toggle(self, **kwargs) -> None:
"""Toggle the entity."""
if self.is_on:
self.turn_off()
self.turn_off(**kwargs)
else:
self.turn_on()
self.turn_on(**kwargs)

def async_toggle(self):
def async_toggle(self, **kwargs):
"""Toggle the entity.

This method must be run in the event loop and returns a coroutine.
"""
if self.is_on:
return self.async_turn_off()
return self.async_turn_off(**kwargs)
else:
return self.async_turn_on()
return self.async_turn_on(**kwargs)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line at end of file