當前位置: 首頁>>代碼示例>>Python>>正文


Python Entity.hass方法代碼示例

本文整理匯總了Python中homeassistant.helpers.entity.Entity.hass方法的典型用法代碼示例。如果您正苦於以下問題:Python Entity.hass方法的具體用法?Python Entity.hass怎麽用?Python Entity.hass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在homeassistant.helpers.entity.Entity的用法示例。


在下文中一共展示了Entity.hass方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _compute_state

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
    def _compute_state(self, config):
        run_coroutine_threadsafe(
            config_util.async_process_ha_core_config(self.hass, config),
            self.hass.loop).result()

        entity = Entity()
        entity.entity_id = 'test.test'
        entity.hass = self.hass
        entity.schedule_update_ha_state()

        self.hass.block_till_done()

        return self.hass.states.get('test.test')
開發者ID:chilicheech,項目名稱:home-assistant,代碼行數:15,代碼來源:test_config.py

示例2: test_entity_customization

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
    def test_entity_customization(self):
        """Test entity customization through configuration."""
        config = {CONF_LATITUDE: 50,
                  CONF_LONGITUDE: 50,
                  CONF_NAME: 'Test',
                  CONF_CUSTOMIZE: {'test.test': {'hidden': True}}}

        bootstrap.process_ha_core_config(self.hass, config)

        entity = Entity()
        entity.entity_id = 'test.test'
        entity.hass = self.hass
        entity.update_ha_state()

        state = self.hass.states.get('test.test')

        assert state.attributes['hidden']
開發者ID:1lann,項目名稱:home-assistant,代碼行數:19,代碼來源:test_bootstrap.py

示例3: test_entity_customization

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
    def test_entity_customization(self):
        """ Test entity customization through config """
        config = {CONF_LATITUDE: 50,
                  CONF_LONGITUDE: 50,
                  CONF_NAME: 'Test',
                  CONF_CUSTOMIZE: {'test.test': {'hidden': True}}}

        hass = get_test_home_assistant()

        bootstrap.process_ha_core_config(hass, config)

        entity = Entity()
        entity.entity_id = 'test.test'
        entity.hass = hass
        entity.update_ha_state()

        state = hass.states.get('test.test')

        self.assertTrue(state.attributes['hidden'])
        hass.stop()
開發者ID:100dayproject,項目名稱:home-assistant,代碼行數:22,代碼來源:test_bootstrap.py

示例4: test_entity_customization

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
    def test_entity_customization(self):
        """Test entity customization through configuration."""
        self.hass = get_test_home_assistant()

        config = {CONF_LATITUDE: 50,
                  CONF_LONGITUDE: 50,
                  CONF_NAME: 'Test',
                  CONF_CUSTOMIZE: {'test.test': {'hidden': True}}}

        config_util.process_ha_core_config(self.hass, config)

        entity = Entity()
        entity.entity_id = 'test.test'
        entity.hass = self.hass
        entity.update_ha_state()

        self.hass.block_till_done()

        state = self.hass.states.get('test.test')

        assert state.attributes['hidden']
開發者ID:krzynio,項目名稱:home-assistant,代碼行數:23,代碼來源:test_config.py

示例5: test_entity_customization

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
    def test_entity_customization(self):
        """Test entity customization through configuration."""
        config = {CONF_LATITUDE: 50,
                  CONF_LONGITUDE: 50,
                  CONF_NAME: 'Test',
                  CONF_CUSTOMIZE: {'test.test': {'hidden': True}}}

        run_coroutine_threadsafe(
            config_util.async_process_ha_core_config(self.hass, config),
            self.hass.loop).result()

        entity = Entity()
        entity.entity_id = 'test.test'
        entity.hass = self.hass
        entity.update_ha_state()

        self.hass.block_till_done()

        state = self.hass.states.get('test.test')

        assert state.attributes['hidden']
開發者ID:DavidLP,項目名稱:home-assistant,代碼行數:23,代碼來源:test_config.py

示例6: test_merge_customize

# 需要導入模塊: from homeassistant.helpers.entity import Entity [as 別名]
# 或者: from homeassistant.helpers.entity.Entity import hass [as 別名]
def test_merge_customize(hass):
    """Test loading core config onto hass object."""
    core_config = {
        'latitude': 60,
        'longitude': 50,
        'elevation': 25,
        'name': 'Huis',
        CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL,
        'time_zone': 'GMT',
        'customize': {'a.a': {'friendly_name': 'A'}},
        'packages': {'pkg1': {'homeassistant': {'customize': {
            'b.b': {'friendly_name': 'BB'}}}}},
    }
    yield from config_util.async_process_ha_core_config(hass, core_config)

    entity = Entity()
    entity.entity_id = 'b.b'
    entity.hass = hass
    yield from entity.async_update_ha_state()

    state = hass.states.get('b.b')
    assert state is not None
    assert state.attributes['friendly_name'] == 'BB'
開發者ID:Teagan42,項目名稱:home-assistant,代碼行數:25,代碼來源:test_config.py


注:本文中的homeassistant.helpers.entity.Entity.hass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。