Exemplo n.º 1
0
    def test_get_entity_ids_with_domain_filter(self):
        """Test if get_entity_ids works with a domain_filter."""
        self.hass.states.set("switch.AC", STATE_OFF)

        mixed_group = group.Group.create_group(self.hass, "mixed_group", ["light.Bowl", "switch.AC"], False)

        self.assertEqual(["switch.ac"], group.get_entity_ids(self.hass, mixed_group.entity_id, domain_filter="switch"))
Exemplo n.º 2
0
    def test_get_entity_ids(self):
        """Test get_entity_ids method."""
        self.hass.states.set("light.Bowl", STATE_ON)
        self.hass.states.set("light.Ceiling", STATE_OFF)
        test_group = group.Group.create_group(self.hass, "init_group", ["light.Bowl", "light.Ceiling"], False)

        self.assertEqual(["light.bowl", "light.ceiling"], sorted(group.get_entity_ids(self.hass, test_group.entity_id)))
Exemplo n.º 3
0
    def _resolve_group(self, group_entity_id) -> None:
        """Resolve a group.

        Will only be called if group is an entry point.
        """
        for entity_id in group.get_entity_ids(self.hass, group_entity_id):
            self._add_or_resolve("entity", entity_id)
Exemplo n.º 4
0
    def test_get_entity_ids(self):
        """ Test get_entity_ids method. """
        # Get entity IDs from our group
        self.assertEqual(
            sorted(['light.Ceiling', 'light.Bowl']),
            sorted(group.get_entity_ids(self.hass, self.group_name)))

        # Test domain_filter
        self.assertEqual(['switch.AC'],
                         group.get_entity_ids(self.hass,
                                              self.mixed_group_name,
                                              domain_filter="switch"))

        # Test with non existing group name
        self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))

        # Test with non-group state
        self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
Exemplo n.º 5
0
    def test_get_entity_ids(self):
        """Test get_entity_ids method."""
        self.hass.states.set('light.Bowl', STATE_ON)
        self.hass.states.set('light.Ceiling', STATE_OFF)
        test_group = group.Group.create_group(
            self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False)

        assert ['light.bowl', 'light.ceiling'] == \
            sorted(group.get_entity_ids(self.hass, test_group.entity_id))
    def test_get_entity_ids(self):
        """ Test get_entity_ids method. """
        # Get entity IDs from our group
        self.assertEqual(
            sorted(['light.Ceiling', 'light.Bowl']),
            sorted(group.get_entity_ids(self.hass, self.group_name)))

        # Test domain_filter
        self.assertEqual(
            ['switch.AC'],
            group.get_entity_ids(
                self.hass, self.mixed_group_name, domain_filter="switch"))

        # Test with non existing group name
        self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))

        # Test with non-group state
        self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
Exemplo n.º 7
0
    def test_get_entity_ids(self):
        """Test get_entity_ids method."""
        self.hass.states.set("light.Bowl", STATE_ON)
        self.hass.states.set("light.Ceiling", STATE_OFF)
        test_group = group.Group.create_group(self.hass, "init_group",
                                              ["light.Bowl", "light.Ceiling"],
                                              False)

        assert ["light.bowl", "light.ceiling"] == sorted(
            group.get_entity_ids(self.hass, test_group.entity_id))
Exemplo n.º 8
0
    def test_get_entity_ids(self):
        """Test get_entity_ids method."""
        self.hass.states.set('light.Bowl', STATE_ON)
        self.hass.states.set('light.Ceiling', STATE_OFF)
        test_group = group.Group.create_group(
            self.hass, 'init_group', ['light.Bowl', 'light.Ceiling'], False)

        self.assertEqual(
            ['light.bowl', 'light.ceiling'],
            sorted(group.get_entity_ids(self.hass, test_group.entity_id)))
Exemplo n.º 9
0
    def test_get_entity_ids_with_domain_filter(self):
        """Test if get_entity_ids works with a domain_filter."""
        self.hass.states.set('switch.AC', STATE_OFF)

        mixed_group = group.Group.create_group(
            self.hass, 'mixed_group', ['light.Bowl', 'switch.AC'], False)

        assert ['switch.ac'] == \
            group.get_entity_ids(
                self.hass, mixed_group.entity_id, domain_filter="switch")
Exemplo n.º 10
0
    def test_get_entity_ids_with_domain_filter(self):
        """Test if get_entity_ids works with a domain_filter."""
        self.hass.states.set("switch.AC", STATE_OFF)

        mixed_group = group.Group.create_group(self.hass, "mixed_group",
                                               ["light.Bowl", "switch.AC"],
                                               False)

        assert ["switch.ac"] == group.get_entity_ids(self.hass,
                                                     mixed_group.entity_id,
                                                     domain_filter="switch")
Exemplo n.º 11
0
    def test_get_entity_ids_with_domain_filter(self):
        """Test if get_entity_ids works with a domain_filter."""
        self.hass.states.set('switch.AC', STATE_OFF)

        mixed_group = group.Group(self.hass, 'mixed_group',
                                  ['light.Bowl', 'switch.AC'], False)

        self.assertEqual(['switch.ac'],
                         group.get_entity_ids(self.hass,
                                              mixed_group.entity_id,
                                              domain_filter="switch"))
Exemplo n.º 12
0
async def test_get_entity_ids_with_domain_filter(hass):
    """Test if get_entity_ids works with a domain_filter."""
    hass.states.async_set("switch.AC", STATE_OFF)

    assert await async_setup_component(hass, "group", {})

    mixed_group = await group.Group.async_create_group(
        hass, "mixed_group", ["light.Bowl", "switch.AC"], False)

    assert ["switch.ac"] == group.get_entity_ids(hass,
                                                 mixed_group.entity_id,
                                                 domain_filter="switch")
Exemplo n.º 13
0
async def test_get_entity_ids(hass):
    """Test get_entity_ids method."""
    hass.states.async_set("light.Bowl", STATE_ON)
    hass.states.async_set("light.Ceiling", STATE_OFF)

    assert await async_setup_component(hass, "group", {})

    test_group = await group.Group.async_create_group(
        hass, "init_group", ["light.Bowl", "light.Ceiling"], False)

    assert ["light.bowl", "light.ceiling"
            ] == sorted(group.get_entity_ids(hass, test_group.entity_id))
Exemplo n.º 14
0
def setup(hass, config):

    # state listener: pass in entity that changed
    def state_changed(entity_id, old_state, new_state):
        _LOGGER.debug(f"{dbg()}:{entity_id} changed state: {new_state}")
        hass.data[ENERGY_ASSET_DOMAIN].add_dirty_list(entity_id)
        hass.data[ENERGY_ASSET_DOMAIN].update_asset(entity_id, new_state.attributes)

    _LOGGER.debug(f"{dbg()}:Entities: {group.get_entity_ids(hass, 'group.all_switches')}")

    # register the state change listener: pass in the entities to observer and the callback listener
    # will listen on the event bus and filter for the entities we care about
    track_state_change(hass, group.get_entity_ids(hass, 'group.all_switches'), state_changed)

    return True  # show that the component loaded successfully
Exemplo n.º 15
0
 def test_get_entity_ids_with_non_existing_group_name(self):
     """Test get_entity_ids with a non existing group."""
     assert [] == group.get_entity_ids(self.hass, 'non_existing')
Exemplo n.º 16
0
 def test_get_entity_ids_with_non_group_state(self):
     """Test get_entity_ids with a non group state."""
     self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
Exemplo n.º 17
0
 def test_get_entity_ids_with_non_existing_group_name(self):
     """Test get_entity_ids with a non existing group."""
     self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))
Exemplo n.º 18
0
 def test_get_entity_ids_with_non_group_state(self):
     """Test get_entity_ids with a non group state."""
     self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
Exemplo n.º 19
0
 def test_get_entity_ids_with_non_existing_group_name(self):
     """Test get_entity_ids with a non existing group."""
     self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))
Exemplo n.º 20
0
 def test_get_entity_ids_with_non_existing_group_name(self):
     """Test get_entity_ids with a non existing group."""
     assert [] == group.get_entity_ids(self.hass, "non_existing")
Exemplo n.º 21
0
 def test_get_entity_ids_with_non_group_state(self):
     """Test get_entity_ids with a non group state."""
     assert [] == group.get_entity_ids(self.hass, 'switch.AC')
Exemplo n.º 22
0
 def test_get_entity_ids_with_non_group_state(self):
     """Test get_entity_ids with a non group state."""
     assert [] == group.get_entity_ids(self.hass, "switch.AC")
Exemplo n.º 23
0
 def test_get_entity_ids(self):
     """ Test get_entity_ids method. """
     self.assertEqual(
         ['light.bowl', 'light.ceiling'],
         sorted(group.get_entity_ids(self.hass, self.group_entity_id)))