本文整理汇总了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
示例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
示例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
示例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)
示例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)