mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Update to group component to properly handle zone changes in tracked devices (#2631)
* pep8 fixes for group and test * update to pass linting * docstring fix. * reduced length of docstring on test.
This commit is contained in:
parent
bce4be88dc
commit
6a3c5b093b
@ -304,8 +304,9 @@ class Group(Entity):
|
|||||||
if gr_on is None:
|
if gr_on is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if tr_state is None or (gr_state == gr_on and
|
if tr_state is None or ((gr_state == gr_on and
|
||||||
tr_state.state == gr_off):
|
tr_state.state == gr_off) or
|
||||||
|
tr_state.state not in (gr_on, gr_off)):
|
||||||
if states is None:
|
if states is None:
|
||||||
states = self._tracking_states
|
states = self._tracking_states
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import unittest
|
|||||||
from homeassistant.bootstrap import _setup_component
|
from homeassistant.bootstrap import _setup_component
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ON, STATE_OFF, STATE_HOME, STATE_UNKNOWN, ATTR_ICON, ATTR_HIDDEN,
|
STATE_ON, STATE_OFF, STATE_HOME, STATE_UNKNOWN, ATTR_ICON, ATTR_HIDDEN,
|
||||||
ATTR_ASSUMED_STATE, )
|
ATTR_ASSUMED_STATE, STATE_NOT_HOME, )
|
||||||
import homeassistant.components.group as group
|
import homeassistant.components.group as group
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
@ -294,3 +294,17 @@ class TestComponentsGroup(unittest.TestCase):
|
|||||||
|
|
||||||
state = self.hass.states.get(test_group.entity_id)
|
state = self.hass.states.get(test_group.entity_id)
|
||||||
self.assertIsNone(state.attributes.get(ATTR_ASSUMED_STATE))
|
self.assertIsNone(state.attributes.get(ATTR_ASSUMED_STATE))
|
||||||
|
|
||||||
|
def test_group_updated_after_device_tracker_zone_change(self):
|
||||||
|
"""Test group state when device tracker in group changes zone."""
|
||||||
|
self.hass.states.set('device_tracker.Adam', STATE_HOME)
|
||||||
|
self.hass.states.set('device_tracker.Eve', STATE_NOT_HOME)
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
group.Group(
|
||||||
|
self.hass, 'peeps',
|
||||||
|
['device_tracker.Adam', 'device_tracker.Eve'])
|
||||||
|
self.hass.states.set('device_tracker.Adam', 'cool_state_not_home')
|
||||||
|
self.hass.pool.block_till_done()
|
||||||
|
self.assertEqual(STATE_NOT_HOME,
|
||||||
|
self.hass.states.get(
|
||||||
|
group.ENTITY_ID_FORMAT.format('peeps')).state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user