1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Scene bugfixes and UI improvements

This commit is contained in:
Paulus Schoutsen
2015-03-16 23:32:18 -07:00
parent b459a29947
commit 1245af356b
10 changed files with 69 additions and 37 deletions

View File

@@ -8,8 +8,8 @@ import logging
from datetime import datetime
from homeassistant import State
from homeassistant.const import STATE_ON, STATE_OFF
import homeassistant.components as core_components
from homeassistant.const import (
STATE_ON, STATE_OFF, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID)
_LOGGER = logging.getLogger(__name__)
@@ -33,7 +33,7 @@ class TrackStates(object):
self.states.extend(self.hass.states.get_since(self.now))
def reproduce_state(hass, states):
def reproduce_state(hass, states, blocking=False):
""" Takes in a state and will try to have the entity reproduce it. """
if isinstance(states, State):
states = [states]
@@ -45,8 +45,14 @@ def reproduce_state(hass, states):
continue
if state.state == STATE_ON:
core_components.turn_on(hass, state.entity_id, **state.attributes)
service = SERVICE_TURN_ON
elif state.state == STATE_OFF:
core_components.turn_off(hass, state.entity_id, **state.attributes)
service = SERVICE_TURN_OFF
else:
_LOGGER.warning("Unable to reproduce state for %s", state)
continue
service_data = dict(state.attributes)
service_data[ATTR_ENTITY_ID] = state.entity_id
hass.services.call(state.domain, service, service_data, blocking)