Пример #1
0
async def test_reading_yaml_config(hass, yaml_devices):
    """Test the rendering of the YAML configuration."""
    dev_id = 'test'
    device = device_tracker.Device(hass,
                                   timedelta(seconds=180),
                                   True,
                                   dev_id,
                                   'AB:CD:EF:GH:IJ',
                                   'Test name',
                                   picture='http://test.picture',
                                   hide_if_away=True,
                                   icon='mdi:kettle')
    device_tracker.update_config(yaml_devices, dev_id, device)
    with assert_setup_component(1, device_tracker.DOMAIN):
        assert await async_setup_component(hass, device_tracker.DOMAIN,
                                           TEST_PLATFORM)
    config = (await device_tracker.async_load_config(yaml_devices, hass,
                                                     device.consider_home))[0]
    assert device.dev_id == config.dev_id
    assert device.track == config.track
    assert device.mac == config.mac
    assert device.config_picture == config.config_picture
    assert device.away_hide == config.away_hide
    assert device.consider_home == config.consider_home
    assert device.icon == config.icon
Пример #2
0
    def test_group_all_devices(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       0,
                                       True,
                                       dev_id,
                                       None,
                                       away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        self.assertTrue(
            device_tracker.setup(
                self.hass, {device_tracker.DOMAIN: {
                    CONF_PLATFORM: 'test'
                }}))

        state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
        self.assertIsNotNone(state)
        self.assertEqual(STATE_NOT_HOME, state.state)
        self.assertSequenceEqual((entity_id, ),
                                 state.attributes.get(ATTR_ENTITY_ID))
Пример #3
0
 def test_reading_yaml_config(self):
     """Test the rendering of the YAML configuration."""
     dev_id = 'test'
     device = device_tracker.Device(self.hass,
                                    timedelta(seconds=180),
                                    True,
                                    dev_id,
                                    'AB:CD:EF:GH:IJ',
                                    'Test name',
                                    picture='http://test.picture',
                                    hide_if_away=True,
                                    icon='mdi:kettle')
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     with assert_setup_component(1, device_tracker.DOMAIN):
         assert setup_component(self.hass, device_tracker.DOMAIN,
                                TEST_PLATFORM)
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
     self.assertEqual(device.vendor, config.vendor)
     self.assertEqual(device.icon, config.icon)
Пример #4
0
    def test_entity_attributes(self):
        """Test the entity attributes."""
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'Paulus'
        picture = 'http://placehold.it/200x200'
        icon = 'mdi:kettle'

        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       True,
                                       dev_id,
                                       None,
                                       friendly_name,
                                       picture,
                                       hide_if_away=True,
                                       icon=icon)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        with assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN,
                                   TEST_PLATFORM)

        attrs = self.hass.states.get(entity_id).attributes

        self.assertEqual(friendly_name, attrs.get(ATTR_FRIENDLY_NAME))
        self.assertEqual(icon, attrs.get(ATTR_ICON))
        self.assertEqual(picture, attrs.get(ATTR_ENTITY_PICTURE))
Пример #5
0
    def test_group_all_devices(self):
        """Test grouping of devices."""
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       True,
                                       dev_id,
                                       None,
                                       hide_if_away=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        with assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN,
                                   TEST_PLATFORM)
            self.hass.block_till_done()

        state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
        self.assertIsNotNone(state)
        self.assertEqual(STATE_NOT_HOME, state.state)
        self.assertSequenceEqual((entity_id, ),
                                 state.attributes.get(ATTR_ENTITY_ID))
Пример #6
0
def setUpModule():
    """Write a device tracker known devices file to be used."""
    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH, 'device_1', device_tracker.Device(
            None, None, True, 'device_1', 'DEV1',
            picture='http://example.com/dev1.jpg'))

    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH, 'device_2', device_tracker.Device(
            None, None, True, 'device_2', 'DEV2',
            picture='http://example.com/dev2.jpg'))
def setUpModule():   # pylint: disable=invalid-name
    """Write a device tracker known devices file to be used."""
    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH, 'device_1', device_tracker.Device(
            None, None, True, 'device_1', 'DEV1',
            picture='http://example.com/dev1.jpg'))

    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH, 'device_2', device_tracker.Device(
            None, None, True, 'device_2', 'DEV2',
            picture='http://example.com/dev2.jpg'))
Пример #8
0
    def test_device_hidden(self):
        """Test hidden devices."""
        dev_id = "test_entity"
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(self.hass, timedelta(seconds=180), True, dev_id, None, hide_if_away=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component("device_tracker.test").SCANNER
        scanner.reset()

        self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, TEST_PLATFORM))

        self.assertTrue(self.hass.states.get(entity_id).attributes.get(ATTR_HIDDEN))
def setUpModule():
    """Write a device tracker known devices file to be used."""
    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH,
        "device_1",
        device_tracker.Device(None, None, True, "device_1", "DEV1", picture="http://example.com/dev1.jpg"),
    )

    device_tracker.update_config(
        KNOWN_DEV_YAML_PATH,
        "device_2",
        device_tracker.Device(None, None, True, "device_2", "DEV2", picture="http://example.com/dev2.jpg"),
    )
Пример #10
0
 def test_reading_yaml_config(self):
     dev_id = 'test'
     device = device_tracker.Device(self.hass, timedelta(seconds=180), True,
                                    dev_id, 'AB:CD:EF:GH:IJ', 'Test name',
                                    'http://test.picture', True)
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     self.assertTrue(device_tracker.setup(self.hass, {}))
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
Пример #11
0
 def test_reading_yaml_config(self):
     dev_id = 'test'
     device = device_tracker.Device(
         self.hass, timedelta(seconds=180), True, dev_id, 'AB:CD:EF:GH:IJ',
         'Test name', 'http://test.picture', True)
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     self.assertTrue(device_tracker.setup(self.hass, {}))
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
Пример #12
0
    def test_group_all_devices(self):
        """Test grouping of devices."""
        dev_id = "test_entity"
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(self.hass, timedelta(seconds=180), True, dev_id, None, hide_if_away=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component("device_tracker.test").SCANNER
        scanner.reset()

        self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, TEST_PLATFORM))

        state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
        self.assertIsNotNone(state)
        self.assertEqual(STATE_NOT_HOME, state.state)
        self.assertSequenceEqual((entity_id,), state.attributes.get(ATTR_ENTITY_ID))
Пример #13
0
    def test_device_hidden(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        self.assertTrue(device_tracker.setup(self.hass, {
            device_tracker.DOMAIN: {CONF_PLATFORM: 'test'}}))

        self.assertTrue(self.hass.states.get(entity_id)
                            .attributes.get(ATTR_HIDDEN))
Пример #14
0
 def test_reading_yaml_config(self):
     """Test the rendering of the YAML configuration."""
     dev_id = 'test'
     device = device_tracker.Device(
         self.hass, timedelta(seconds=180), True, dev_id,
         'AB:CD:EF:GH:IJ', 'Test name', picture='http://test.picture',
         away_hide=True)
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM))
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
Пример #15
0
    def test_device_hidden(self):
        """Test hidden devices."""
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            hide_if_away=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
                                        TEST_PLATFORM))

        self.assertTrue(self.hass.states.get(entity_id)
                        .attributes.get(ATTR_HIDDEN))
Пример #16
0
async def test_device_hidden(hass, yaml_devices):
    """Test hidden devices."""
    dev_id = 'test_entity'
    entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
    device = device_tracker.Device(
        hass, timedelta(seconds=180), True, dev_id, None,
        hide_if_away=True)
    device_tracker.update_config(yaml_devices, dev_id, device)

    scanner = get_component(hass, 'device_tracker.test').SCANNER
    scanner.reset()

    with assert_setup_component(1, device_tracker.DOMAIN):
        assert await async_setup_component(hass, device_tracker.DOMAIN,
                                           TEST_PLATFORM)

    assert hass.states.get(entity_id).attributes.get(ATTR_HIDDEN)
Пример #17
0
    def test_entity_attributes(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'Paulus'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            friendly_name, picture, away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        self.assertTrue(device_tracker.setup(self.hass, {}))

        attrs = self.hass.states.get(entity_id).attributes

        self.assertEqual(friendly_name, attrs.get(ATTR_FRIENDLY_NAME))
        self.assertEqual(picture, attrs.get(ATTR_ENTITY_PICTURE))
Пример #18
0
    def test_entity_attributes(self):
        """Test the entity attributes."""
        dev_id = "test_entity"
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = "Paulus"
        picture = "http://placehold.it/200x200"

        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None, friendly_name, picture, hide_if_away=True
        )
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, TEST_PLATFORM))

        attrs = self.hass.states.get(entity_id).attributes

        self.assertEqual(friendly_name, attrs.get(ATTR_FRIENDLY_NAME))
        self.assertEqual(picture, attrs.get(ATTR_ENTITY_PICTURE))
Пример #19
0
    def test_group_all_devices(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        self.assertTrue(device_tracker.setup(self.hass, {
            device_tracker.DOMAIN: {CONF_PLATFORM: 'test'}}))

        state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
        self.assertIsNotNone(state)
        self.assertEqual(STATE_NOT_HOME, state.state)
        self.assertSequenceEqual((entity_id,),
                                 state.attributes.get(ATTR_ENTITY_ID))
Пример #20
0
 def test_reading_yaml_config(self):
     """Test the rendering of the YAML configuration."""
     dev_id = 'test'
     device = device_tracker.Device(
         self.hass, timedelta(seconds=180), True, dev_id,
         'AB:CD:EF:GH:IJ', 'Test name', picture='http://test.picture',
         hide_if_away=True, icon='mdi:kettle')
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     with assert_setup_component(1, device_tracker.DOMAIN):
         assert setup_component(self.hass, device_tracker.DOMAIN,
                                TEST_PLATFORM)
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     assert device.dev_id == config.dev_id
     assert device.track == config.track
     assert device.mac == config.mac
     assert device.config_picture == config.config_picture
     assert device.away_hide == config.away_hide
     assert device.consider_home == config.consider_home
     assert device.icon == config.icon
Пример #21
0
async def test_device_hidden(hass, yaml_devices):
    """Test hidden devices."""
    dev_id = 'test_entity'
    entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
    device = device_tracker.Device(hass,
                                   timedelta(seconds=180),
                                   True,
                                   dev_id,
                                   None,
                                   hide_if_away=True)
    device_tracker.update_config(yaml_devices, dev_id, device)

    scanner = getattr(hass.components, 'test.device_tracker').SCANNER
    scanner.reset()

    with assert_setup_component(1, device_tracker.DOMAIN):
        assert await async_setup_component(hass, device_tracker.DOMAIN,
                                           TEST_PLATFORM)

    assert hass.states.get(entity_id).attributes.get(ATTR_HIDDEN)
Пример #22
0
    def test_group_all_devices(self):
        """Test grouping of devices."""
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            hide_if_away=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component(self.hass, 'device_tracker.test').SCANNER
        scanner.reset()

        with assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN,
                                   TEST_PLATFORM)
            self.hass.block_till_done()

        state = self.hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
        assert state is not None
        assert STATE_NOT_HOME == state.state
        assert (entity_id,) == state.attributes.get(ATTR_ENTITY_ID)
Пример #23
0
 def test_reading_yaml_config(self):
     """Test the rendering of the YAML configuration."""
     dev_id = 'test'
     device = device_tracker.Device(self.hass,
                                    timedelta(seconds=180),
                                    True,
                                    dev_id,
                                    'AB:CD:EF:GH:IJ',
                                    'Test name',
                                    picture='http://test.picture',
                                    away_hide=True)
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     self.assertTrue(device_tracker.setup(self.hass, TEST_PLATFORM))
     config = device_tracker.load_config(self.yaml_devices, self.hass,
                                         device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
Пример #24
0
    def test_entity_attributes(self):
        """Test the entity attributes."""
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'Paulus'
        picture = 'http://placehold.it/200x200'
        icon = 'mdi:kettle'

        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), True, dev_id, None,
            friendly_name, picture, hide_if_away=True, icon=icon)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        with assert_setup_component(1, device_tracker.DOMAIN):
            assert setup_component(self.hass, device_tracker.DOMAIN,
                                   TEST_PLATFORM)

        attrs = self.hass.states.get(entity_id).attributes

        assert friendly_name == attrs.get(ATTR_FRIENDLY_NAME)
        assert icon == attrs.get(ATTR_ICON)
        assert picture == attrs.get(ATTR_ENTITY_PICTURE)
Пример #25
0
    def test_entity_attributes(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'Paulus'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       True,
                                       dev_id,
                                       None,
                                       friendly_name,
                                       picture,
                                       away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        self.assertTrue(device_tracker.setup(self.hass, {}))

        attrs = self.hass.states.get(entity_id).attributes

        self.assertEqual(friendly_name, attrs.get(ATTR_FRIENDLY_NAME))
        self.assertEqual(picture, attrs.get(ATTR_ENTITY_PICTURE))
Пример #26
0
    def test_device_hidden(self):
        dev_id = 'test_entity'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       True,
                                       dev_id,
                                       None,
                                       away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        scanner = get_component('device_tracker.test').SCANNER
        scanner.reset()

        self.assertTrue(
            device_tracker.setup(
                self.hass, {device_tracker.DOMAIN: {
                    CONF_PLATFORM: 'test'
                }}))

        self.assertTrue(
            self.hass.states.get(entity_id).attributes.get(ATTR_HIDDEN))
Пример #27
0
 def test_reading_yaml_config(self):
     """Test the rendering of the YAML configuration."""
     dev_id = "test"
     device = device_tracker.Device(
         self.hass,
         timedelta(seconds=180),
         True,
         dev_id,
         "AB:CD:EF:GH:IJ",
         "Test name",
         picture="http://test.picture",
         hide_if_away=True,
     )
     device_tracker.update_config(self.yaml_devices, dev_id, device)
     self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN, TEST_PLATFORM))
     config = device_tracker.load_config(self.yaml_devices, self.hass, device.consider_home)[0]
     self.assertEqual(device.dev_id, config.dev_id)
     self.assertEqual(device.track, config.track)
     self.assertEqual(device.mac, config.mac)
     self.assertEqual(device.config_picture, config.config_picture)
     self.assertEqual(device.away_hide, config.away_hide)
     self.assertEqual(device.consider_home, config.consider_home)
Пример #28
0
async def test_group_all_devices(hass, yaml_devices):
    """Test grouping of devices."""
    dev_id = 'test_entity'
    entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
    device = device_tracker.Device(hass,
                                   timedelta(seconds=180),
                                   True,
                                   dev_id,
                                   None,
                                   hide_if_away=True)
    device_tracker.update_config(yaml_devices, dev_id, device)

    scanner = get_component(hass, 'device_tracker.test').SCANNER
    scanner.reset()

    with assert_setup_component(1, device_tracker.DOMAIN):
        assert await async_setup_component(hass, device_tracker.DOMAIN,
                                           TEST_PLATFORM)
        await hass.async_block_till_done()

    state = hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
    assert state is not None
    assert STATE_NOT_HOME == state.state
    assert (entity_id, ) == state.attributes.get(ATTR_ENTITY_ID)
    def setup_method(self, method):
        self.hass = get_test_home_assistant()
        
        self.yaml_devices = self.hass.config.path(device_tracker.YAML_DEVICES)
        
        zone.setup(self.hass, {
            'zone': [
                {
                    'name': 'home',
                    'latitude': 2.1,
                    'longitude': 1.1,
                    'radius': 10,
                },
                {
                    'name': 'work',
                    'latitude': 100,
                    'longitude': 100,
                    'radius': 10,
                },
            ]
        })
        
        dev_id = 'test1'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'test1'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(
            self.hass, 
            timedelta(seconds=180), 
            0, 
            True, 
            dev_id, 
            None,
            friendly_name, 
            picture, 
            away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)
        
        self.hass.states.set(
            'device_tracker.test1', 'not_home',
            {
                'friendly_name': 'test1',
                'latitude': 50,
                'longitude': 50
            })
        
        dev_id = 'test2'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'test2'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(
            self.hass, timedelta(seconds=180), 0, True, dev_id, None,
            friendly_name, picture, away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)
        
        self.hass.states.set(
            'device_tracker.test2', 'not_home',
            {
                'friendly_name': 'test2',
                'latitude': 50,
                'longitude': 50
            })
Пример #30
0
    def setup_method(self, method):
        self.hass = get_test_home_assistant()

        self.yaml_devices = self.hass.config.path(device_tracker.YAML_DEVICES)

        zone.setup(
            self.hass, {
                'zone': [
                    {
                        'name': 'home',
                        'latitude': 2.1,
                        'longitude': 1.1,
                        'radius': 10,
                    },
                    {
                        'name': 'work',
                        'latitude': 100,
                        'longitude': 100,
                        'radius': 10,
                    },
                ]
            })

        dev_id = 'test1'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'test1'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       0,
                                       True,
                                       dev_id,
                                       None,
                                       friendly_name,
                                       picture,
                                       away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        self.hass.states.set('device_tracker.test1', 'not_home', {
            'friendly_name': 'test1',
            'latitude': 50,
            'longitude': 50
        })

        dev_id = 'test2'
        entity_id = device_tracker.ENTITY_ID_FORMAT.format(dev_id)
        friendly_name = 'test2'
        picture = 'http://placehold.it/200x200'

        device = device_tracker.Device(self.hass,
                                       timedelta(seconds=180),
                                       0,
                                       True,
                                       dev_id,
                                       None,
                                       friendly_name,
                                       picture,
                                       away_hide=True)
        device_tracker.update_config(self.yaml_devices, dev_id, device)

        self.hass.states.set('device_tracker.test2', 'not_home', {
            'friendly_name': 'test2',
            'latitude': 50,
            'longitude': 50
        })