Fix device_tracker service call & cleanup (#17173)
* Bugfix group service - device_tracker * Cleanup
This commit is contained in:
1 parent
a66db59359
commit
07d90c6c55
5 files changed
+51
-43
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user