Esempio n. 1
1
def wake_up(hass, now):
    """
    Turn it on in the morning (7 AM) if there are people home and
    it is not already on.
    """
    if not TARGET_ID:
        return

    if device_tracker.is_on(hass) and not core.is_on(hass, TARGET_ID):
        _LOGGER.info('People home at 7AM, turning it on')
        core.turn_on(hass, TARGET_ID)
Esempio n. 2
0
    def track_devices(entity_id, old_state, new_state):
        """ Called when the group.all devices change state. """

        # If anyone comes home and the core is not on, turn it on.
        if new_state.state == STATE_HOME and not core.is_on(hass, target_id):

            core.turn_on(hass, target_id)

        # If all people leave the house and the core is on, turn it off
        elif new_state.state == STATE_NOT_HOME and core.is_on(hass, target_id):

            core.turn_off(hass, target_id)
Esempio n. 3
0
    def track_devices(entity_id, old_state, new_state):
        """ Called when the group.all devices change state. """

        # If anyone comes home and the core is not on, turn it on.
        if new_state.state == STATE_HOME and not core.is_on(hass, target_id):

            core.turn_on(hass, target_id)

        # If all people leave the house and the core is on, turn it off
        elif new_state.state == STATE_NOT_HOME and core.is_on(hass, target_id):

            core.turn_off(hass, target_id)
Esempio n. 4
0
def track_devices(hass, entity_id, old_state, new_state):
    """Called when the group.all devices change state."""
    # If the target id is not set, return
    if not TARGET_ID:
        return

    # If anyone comes home and the entity is not on, turn it on.
    if new_state.state == STATE_HOME and not core.is_on(hass, TARGET_ID):

        core.turn_on(hass, TARGET_ID)

    # If all people leave the house and the entity is on, turn it off.
    elif new_state.state == STATE_NOT_HOME and core.is_on(hass, TARGET_ID):

        core.turn_off(hass, TARGET_ID)
Esempio n. 5
0
    def wake_up(now):
        """ Turn it on in the morning if there are people home and
            it is not already on. """

        if device_tracker.is_on(hass) and not core.is_on(hass, target_id):
            _LOGGER.info('People home at 7AM, turning it on')
            core.turn_on(hass, target_id)
Esempio n. 6
0
def handle_light_toggle(hass, service):
    target_ids = service.data[ATTR_ENTITY_ID]
    for target_id in target_ids:
        if core.is_on(hass, target_id):
            core.turn_off(hass, target_id)
        else:
            core.turn_on(hass, target_id)
Esempio n. 7
0
    def wake_up(now):
        """ Turn it on in the morning if there are people home and
            it is not already on. """

        if device_tracker.is_on(hass) and not core.is_on(hass, target_id):
            _LOGGER.info('People home at 7AM, turning it on')
            core.turn_on(hass, target_id)
Esempio n. 8
0
def all_lights_off(hass, entity_id, old_state, new_state):
    """If all lights turn off, turn off."""
    if not TARGET_ID:
        return

    if core.is_on(hass, TARGET_ID):
        _LOGGER.info('All lights have been turned off, turning it off')
        core.turn_off(hass, TARGET_ID)
Esempio n. 9
0
def wake_up(hass, now):
    """
    Turn it on in the morning (7 AM) if there are people home and
    it is not already on.
    """
    if not TARGET_ID:
        return

    if device_tracker.is_on(hass) and not core.is_on(hass, TARGET_ID):
        _LOGGER.info('People home at 7AM, turning it on')
        core.turn_on(hass, TARGET_ID)
Esempio n. 10
0
    def flash_service(call):
        """ Service that will turn the target off for 10 seconds
            if on and vice versa. """

        if core.is_on(hass, target_id):
            core.turn_off(hass, target_id)

            time.sleep(10)

            core.turn_on(hass, target_id)

        else:
            core.turn_on(hass, target_id)

            time.sleep(10)

            core.turn_off(hass, target_id)
Esempio n. 11
0
    def flash_service(call):
        """ Service that will turn the target off for 10 seconds
            if on and vice versa. """

        if core.is_on(hass, target_id):
            core.turn_off(hass, target_id)

            time.sleep(10)

            core.turn_on(hass, target_id)

        else:
            core.turn_on(hass, target_id)

            time.sleep(10)

            core.turn_off(hass, target_id)
Esempio n. 12
0
def flash_service(hass, call):
    """
    Service that will turn the target off for 10 seconds if on and vice versa.
    """
    if not TARGET_ID:
        return

    if core.is_on(hass, TARGET_ID):
        core.turn_off(hass, TARGET_ID)

        time.sleep(10)

        core.turn_on(hass, TARGET_ID)

    else:
        core.turn_on(hass, TARGET_ID)

        time.sleep(10)

        core.turn_off(hass, TARGET_ID)
Esempio n. 13
0
def flash_service(hass, call):
    """
    Service that will turn the target off for 10 seconds if on and vice versa.
    """
    if not TARGET_ID:
        return

    if core.is_on(hass, TARGET_ID):
        core.turn_off(hass, TARGET_ID)

        time.sleep(10)

        core.turn_on(hass, TARGET_ID)

    else:
        core.turn_on(hass, TARGET_ID)

        time.sleep(10)

        core.turn_off(hass, TARGET_ID)
Esempio n. 14
0
 def test_is_on(self):
     """Test is_on method."""
     self.assertTrue(comps.is_on(self.hass, 'light.Bowl'))
     self.assertFalse(comps.is_on(self.hass, 'light.Ceiling'))
     self.assertTrue(comps.is_on(self.hass))
     self.assertFalse(comps.is_on(self.hass, 'non_existing.entity'))
Esempio n. 15
0
    def all_lights_off(entity_id, old_state, new_state):
        """ If all lights turn off, turn off. """

        if core.is_on(hass, target_id):
            _LOGGER.info('All lights have been turned off, turning it off')
            core.turn_off(hass, target_id)
Esempio n. 16
0
 def test_is_on(self):
     """Test is_on method."""
     assert comps.is_on(self.hass, "light.Bowl")
     assert not comps.is_on(self.hass, "light.Ceiling")
     assert comps.is_on(self.hass)
     assert not comps.is_on(self.hass, "non_existing.entity")
Esempio n. 17
0
 def test_is_on(self):
     """Test is_on method."""
     assert comps.is_on(self.hass, 'light.Bowl')
     assert not comps.is_on(self.hass, 'light.Ceiling')
     assert comps.is_on(self.hass)
     assert not comps.is_on(self.hass, 'non_existing.entity')
Esempio n. 18
0
 def test_is_on(self):
     """Test is_on method."""
     self.assertTrue(comps.is_on(self.hass, "light.Bowl"))
     self.assertFalse(comps.is_on(self.hass, "light.Ceiling"))
     self.assertTrue(comps.is_on(self.hass))
Esempio n. 19
0
    def all_lights_off(entity_id, old_state, new_state):
        """ If all lights turn off, turn off. """

        if core.is_on(hass, target_id):
            _LOGGER.info('All lights have been turned off, turning it off')
            core.turn_off(hass, target_id)
Esempio n. 20
0
 def test_is_on(self):
     """ Test is_on method. """
     self.assertTrue(comps.is_on(self.hass, 'light.Bowl'))
     self.assertFalse(comps.is_on(self.hass, 'light.Ceiling'))
     self.assertTrue(comps.is_on(self.hass))
Esempio n. 21
0
 def test_is_on(self):
     """Test is_on method."""
     assert comps.is_on(self.hass, 'light.Bowl')
     assert not comps.is_on(self.hass, 'light.Ceiling')
     assert comps.is_on(self.hass)
     assert not comps.is_on(self.hass, 'non_existing.entity')