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


Python entity.async_generate_entity_id方法代碼示例

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


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

示例1: create_hysen_device

# 需要導入模塊: from homeassistant.helpers import entity [as 別名]
# 或者: from homeassistant.helpers.entity import async_generate_entity_id [as 別名]
def create_hysen_device(device_id,hass,name,
                              broadlink_hysen_climate_device,
                              target_temp_default,target_temp_step,operation_list,
                              sync_clock_time_per_day,get_current_temp_from_sensor_override):
    newhassdevice = None
    entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass)
    
    try:
        if (broadlink_hysen_climate_device.auth() == False):
            raise Exception('broadlink_response_error:','Inital auth failed for device')
        newhassdevice = HASS_Hysen_Climate_Device(entity_id,
                                     hass, name, broadlink_hysen_climate_device,
                                     target_temp_default,target_temp_step,operation_list,
                                     sync_clock_time_per_day,get_current_temp_from_sensor_override)
    except Exception as error:
        _LOGGER.error("Failed to Authenticate with Broadlink Hysen Climate device:%s , %s ",entity_id, error)
    return newhassdevice 
開發者ID:mairas,項目名稱:hysen,代碼行數:19,代碼來源:climate.py

示例2: __init__

# 需要導入模塊: from homeassistant.helpers import entity [as 別名]
# 或者: from homeassistant.helpers.entity import async_generate_entity_id [as 別名]
def __init__(self, hass, slug_id, name, device, entity_config):
        """Initialize the sensor."""
        self.hass = hass
        self._entity_config = entity_config
        self._device = device
        self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, slug_id, hass=hass)
        self._name = name 
開發者ID:TomerFi,項目名稱:home-assistant-custom-components,代碼行數:9,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: from homeassistant.helpers import entity [as 別名]
# 或者: from homeassistant.helpers.entity import async_generate_entity_id [as 別名]
def __init__(self, hass, device_id, friendly_name, unit_of_measurement,
                 state_template, icon_template, entity_id):
        """Initialize the sensor."""
        self.hass = hass
        self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, device_id,
                                                  hass=hass)
        self._name = friendly_name
        self._unit_of_measurement = unit_of_measurement
        self._template = state_template
        self._state = None
        self._icon_template = icon_template
        self._icon = None
        self._entity = entity_id 
開發者ID:pilotak,項目名稱:HomeAssistant-CustomComponents,代碼行數:15,代碼來源:sensor.py

示例4: async_setup_platform

# 需要導入模塊: from homeassistant.helpers import entity [as 別名]
# 或者: from homeassistant.helpers.entity import async_generate_entity_id [as 別名]
def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    name = config.get(CONF_NAME)
    latitude = float(config.get(CONF_LATITUDE, hass.config.latitude))
    longitude = float(config.get(CONF_LONGITUDE, hass.config.longitude))
    api_key = config.get(CONF_API_KEY)
    warnings = config.get(CONF_WARNINGS)
    storms_nearby = config.get(CONF_STORMS_NEARBY)
    scan_interval = config.get(CONF_SCAN_INTERVAL)
    radius = 0
    if storms_nearby is not None:
        radius = storms_nearby.get(CONF_RADIUS)
    sensors = []
    sensor_name = '{} - '.format(name)
    x = convert_to_dm(longitude)
    y = convert_to_dm(latitude)
    updater = BurzeDzisNetDataUpdater(x, y, radius, api_key, scan_interval)
    await updater.async_update()
    for warning_type in warnings:
        uid = '{}_{}'.format(name, warning_type)
        entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, uid, hass=hass)
        sensors.append(BurzeDzisNetWarningsSensor(entity_id, sensor_name, updater, warning_type))
    if storms_nearby is not None:
        uid = '{}_storms_nearby'.format(name)
        entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, uid, hass=hass)
        sensors.append(BurzeDzisNetStormsNearbySensor(entity_id, sensor_name, updater))
    async_add_entities(sensors, True) 
開發者ID:macbury,項目名稱:SmartHouse,代碼行數:28,代碼來源:binary_sensor.py

示例5: __init__

# 需要導入模塊: from homeassistant.helpers import entity [as 別名]
# 或者: from homeassistant.helpers.entity import async_generate_entity_id [as 別名]
def __init__(self, hass, device_id, temperature_entity, humidity_entity,
                 friendly_name, icon_template, entity_picture_template, sensor_type):
        """Initialize the sensor."""
        self.hass = hass
        self.entity_id = async_generate_entity_id(ENTITY_ID_FORMAT, "{}_{}".format(device_id, sensor_type), hass=hass)
        self._name = "{} {}".format(friendly_name, SENSOR_TYPES[sensor_type][1])
        self._unit_of_measurement = SENSOR_TYPES[sensor_type][2]
        self._state = None
        self._device_state_attributes = {}
        self._icon_template = icon_template
        self._entity_picture_template = entity_picture_template
        self._icon = None
        self._entity_picture = None
        self._temperature_entity = temperature_entity
        self._humidity_entity = humidity_entity
        self._device_class = SENSOR_TYPES[sensor_type][0]
        self._sensor_type = sensor_type
        self._temperature = None
        self._humidity = None

        async_track_state_change(
            self.hass, self._temperature_entity, self.temperature_state_listener)

        async_track_state_change(
            self.hass, self._humidity_entity, self.humidity_state_listener)

        temperature_state = hass.states.get(temperature_entity)
        if temperature_state and temperature_state.state != STATE_UNKNOWN:
            self._temperature = float(temperature_state.state)

        humidity_state = hass.states.get(humidity_entity)
        if humidity_state and humidity_state.state != STATE_UNKNOWN:
            self._humidity = float(humidity_state.state) 
開發者ID:dolezsa,項目名稱:thermal_comfort,代碼行數:35,代碼來源:sensor.py


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