Add bind_hass to components (#8502)
* Add bind_hass to components * Add bind_hass to group
This commit is contained in:
parent
d3be056d15
commit
d29bdddaa7
24 changed files with 138 additions and 0 deletions
|
@ -148,12 +148,14 @@ def extract_info(state):
|
|||
return params
|
||||
|
||||
|
||||
@bind_hass
|
||||
def is_on(hass, entity_id=None):
|
||||
"""Return if the lights are on based on the statemachine."""
|
||||
entity_id = entity_id or ENTITY_ID_ALL_LIGHTS
|
||||
return hass.states.is_state(entity_id, STATE_ON)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def turn_on(hass, entity_id=None, transition=None, brightness=None,
|
||||
brightness_pct=None, rgb_color=None, xy_color=None,
|
||||
color_temp=None, kelvin=None, white_value=None,
|
||||
|
@ -193,12 +195,14 @@ def async_turn_on(hass, entity_id=None, transition=None, brightness=None,
|
|||
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data))
|
||||
|
||||
|
||||
@bind_hass
|
||||
def turn_off(hass, entity_id=None, transition=None):
|
||||
"""Turn all or specified light off."""
|
||||
hass.add_job(async_turn_off, hass, entity_id, transition)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_turn_off(hass, entity_id=None, transition=None):
|
||||
"""Turn all or specified light off."""
|
||||
data = {
|
||||
|
@ -212,6 +216,7 @@ def async_turn_off(hass, entity_id=None, transition=None):
|
|||
DOMAIN, SERVICE_TURN_OFF, data))
|
||||
|
||||
|
||||
@bind_hass
|
||||
def toggle(hass, entity_id=None, transition=None):
|
||||
"""Toggle all or specified light."""
|
||||
data = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue