mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
light.turn_on/turn_off/is_on use entity_id instead of object_id
This commit is contained in:
parent
cd58147fa7
commit
6ce393856a
@ -30,12 +30,11 @@ def setup(bus, statemachine, light_group=None):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not light_group:
|
light_group = light_group or light.GROUP_NAME_ALL_LIGHTS
|
||||||
light_group = light.GROUP_NAME_ALL_LIGHTS
|
|
||||||
|
|
||||||
# Get the light IDs from the specified group
|
# Get the light IDs from the specified group
|
||||||
light_ids = ha.filter_entity_ids(
|
light_ids = ha.filter_entity_ids(
|
||||||
group.get_entity_ids(statemachine, light_group), light.DOMAIN, True)
|
group.get_entity_ids(statemachine, light_group), light.DOMAIN)
|
||||||
|
|
||||||
if not light_ids:
|
if not light_ids:
|
||||||
logger.error("LightTrigger:No lights found to turn on ")
|
logger.error("LightTrigger:No lights found to turn on ")
|
||||||
|
@ -23,20 +23,19 @@ ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
|||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||||
|
|
||||||
|
|
||||||
def is_on(statemachine, light_id=None):
|
def is_on(statemachine, entity_id=None):
|
||||||
""" Returns if the lights are on based on the statemachine. """
|
""" Returns if the lights are on based on the statemachine. """
|
||||||
entity_id = ENTITY_ID_FORMAT.format(light_id) if light_id \
|
entity_id = entity_id or ENTITY_ID_ALL_LIGHTS
|
||||||
else ENTITY_ID_ALL_LIGHTS
|
|
||||||
|
|
||||||
return statemachine.is_state(entity_id, ha.STATE_ON)
|
return statemachine.is_state(entity_id, ha.STATE_ON)
|
||||||
|
|
||||||
|
|
||||||
def turn_on(bus, light_id=None, transition_seconds=None):
|
def turn_on(bus, entity_id=None, transition_seconds=None):
|
||||||
""" Turns all or specified light on. """
|
""" Turns all or specified light on. """
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
if light_id:
|
if entity_id:
|
||||||
data["light_id"] = light_id
|
data["light_id"] = ha.split_entity_id(entity_id)[1]
|
||||||
|
|
||||||
if transition_seconds:
|
if transition_seconds:
|
||||||
data["transition_seconds"] = transition_seconds
|
data["transition_seconds"] = transition_seconds
|
||||||
@ -44,12 +43,12 @@ def turn_on(bus, light_id=None, transition_seconds=None):
|
|||||||
bus.call_service(DOMAIN, ha.SERVICE_TURN_ON, data)
|
bus.call_service(DOMAIN, ha.SERVICE_TURN_ON, data)
|
||||||
|
|
||||||
|
|
||||||
def turn_off(bus, light_id=None, transition_seconds=None):
|
def turn_off(bus, entity_id=None, transition_seconds=None):
|
||||||
""" Turns all or specified light off. """
|
""" Turns all or specified light off. """
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
if light_id:
|
if entity_id:
|
||||||
data["light_id"] = light_id
|
data["light_id"] = ha.split_entity_id(entity_id)[1]
|
||||||
|
|
||||||
if transition_seconds:
|
if transition_seconds:
|
||||||
data["transition_seconds"] = transition_seconds
|
data["transition_seconds"] = transition_seconds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user