本文整理汇总了Python中homeassistant.const.CONF_HOST属性的典型用法代码示例。如果您正苦于以下问题:Python const.CONF_HOST属性的具体用法?Python const.CONF_HOST怎么用?Python const.CONF_HOST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类homeassistant.const
的用法示例。
在下文中一共展示了const.CONF_HOST属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Awesome Light platform."""
# Assign configuration variables.
# The configuration check takes care they are present.
host = config[CONF_HOST]
username = config[CONF_USERNAME]
password = config.get(CONF_PASSWORD)
# Setup connection with devices/cloud
hub = awesomelights.Hub(host, username, password)
# Verify that passed in configuration works
if not hub.is_valid_login():
_LOGGER.error("Could not connect to AwesomeLight hub")
return
# Add devices
add_entities(AwesomeLight(light) for light in hub.lights())
示例2: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Configure the platform."""
if discovery_info is None:
return
bridge = Caseta(discovery_info[CONF_HOST])
await bridge.open()
data = CasetaData(bridge)
devices = [
CasetaSwitch(switch, data, discovery_info[CONF_MAC])
for switch in discovery_info[CONF_DEVICES]
]
data.set_devices(devices)
async_add_devices(devices, True)
# register callbacks
bridge.register(data.read_output)
# start bridge main loop
bridge.start(hass)
示例3: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Configure the platform."""
if discovery_info is None:
return
bridge = Caseta(discovery_info[CONF_HOST])
await bridge.open()
data = CasetaData(bridge, hass)
devices = [
CasetaCover(cover, data, discovery_info[CONF_MAC])
for cover in discovery_info[CONF_DEVICES]
]
data.set_devices(devices)
async_add_devices(devices)
# register callbacks
bridge.register(data.read_output)
# start bridge main loop
bridge.start(hass)
示例4: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Configure the platform."""
if discovery_info is None:
return
bridge = Caseta(discovery_info[CONF_HOST])
yield from bridge.open()
data = CasetaData(bridge)
devices = [
CasetaFan(fan, data, discovery_info[CONF_MAC])
for fan in discovery_info[CONF_DEVICES]
]
data.set_devices(devices)
async_add_devices(devices, True)
# register callbacks
bridge.register(data.read_output)
# start bridge main loop
bridge.start(hass)
示例5: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Configure the platform."""
if discovery_info is None:
return
bridge = Caseta(discovery_info[CONF_HOST])
await bridge.open()
data = CasetaData(bridge, hass)
devices = [
CasetaScene(scene, data, discovery_info[CONF_MAC])
for scene in discovery_info[CONF_DEVICES]
]
data.set_devices(devices)
async_add_devices(devices)
# register callbacks
bridge.register(data.read_output)
# start bridge main loop
bridge.start(hass)
示例6: async_setup
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup(hass, config):
"""Initialize the component and loads the integration report."""
if CONF_BRIDGES in config[DOMAIN]:
for bridge in config[DOMAIN][CONF_BRIDGES]:
host = bridge[CONF_HOST]
# get the file name for the JSON integration report
fname = get_config_file(hass, host)
# check if the file exists
if not os.path.exists(fname) or not os.path.isfile(fname):
_LOGGER.info(
"Integration Report for host %s not found at location %s",
host,
fname,
)
hass.async_add_job(request_configuration, hass, config, host, bridge)
else:
_LOGGER.debug("Loading Integration Report %s", fname)
await async_setup_bridge(hass, config, fname, bridge)
return True
示例7: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Configure the platform."""
if discovery_info is None:
return
bridge = Caseta(discovery_info[CONF_HOST])
await bridge.open()
data = CasetaData(bridge, hass)
devices = [
CasetaPicoRemote(pico, data, discovery_info[CONF_MAC])
for pico in discovery_info[CONF_DEVICES]
]
data.set_devices(devices)
async_add_devices(devices)
# register callbacks
bridge.register(data.read_output)
# start bridge main loop
bridge.start(hass)
# pylint: disable=too-many-instance-attributes
示例8: __init__
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def __init__(self, hass, conf, name):
from pytz import timezone
self._name = name
self.conf_dir = str(hass.config.path()) + '/'
self._dir = conf.get(CONF_IMG_CACHE)
if self._name:
self._dir = self._dir + self._name.replace(' ', '_') + '/'
self.img = '{0}{1}{2}{3}{4}.jpg'.format(
self.conf_dir, {}, self._dir, {}, {})
self.img_url = '{0}{1}{2}{3}.jpg'.format({}, self._dir, {}, {})
self._tz = timezone(str(hass.config.time_zone))
self.cert = conf.get(CONF_SSL_CERT)
self.ssl = 's' if conf.get(CONF_SSL) or self.cert else ''
self.token = conf.get(CONF_TOKEN)
self.server_name = conf.get(CONF_SERVER)
self.max_items = int(conf.get(CONF_MAX))
self.dl_images = conf.get(CONF_DL_IMAGES)
self.on_deck = conf.get(CONF_ON_DECK)
self.sections = conf.get(CONF_SECTION_TYPES)
self.excludes = conf.get(CONF_EXCLUDE_KEYWORDS)
self.resolution = conf.get(CONF_RESOLUTION)
if self.server_name:
_LOGGER.warning(
"Plex Recently Added: The server_name option has been removed. Use host and port options instead.")
return
else:
self.server_ip = conf.get(CONF_HOST)
self.local_ip = conf.get(CONF_HOST)
self.port = conf.get(CONF_PORT)
self.url_elements = [self.ssl, self.server_ip, self.local_ip,
self.port, self.token, self.cert, self.dl_images]
self.change_detected = False
self._state = None
self.card_json = []
self.api_json = []
self.data = [{1}]
示例9: async_setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the Sonoff LAN Mode Switch platform."""
host = config.get(CONF_HOST)
name = config.get(CONF_NAME)
icon = config.get(CONF_ICON)
async_add_entities([HassSonoffSwitch(hass, host, name, icon)], True)
示例10: validate_input
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def validate_input(hass, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
try:
wiser = await hass.async_add_executor_job(
wiserHub, data[CONF_HOST], data[CONF_PASSWORD]
)
wiser_id = await hass.async_add_executor_job(wiser.getWiserHubName)
except WiserHubTimeoutException:
raise CannotConnect
except WiserHubAuthenticationException:
raise InvalidAuth
except WiserRESTException:
raise UnknownError
except requests.exceptions.ConnectionError:
raise CannotConnect
except RuntimeError:
raise UnknownError
unique_id = str(f"{DOMAIN}-{wiser_id}")
name = wiser_id
return {"title": name, "unique_id": unique_id}
示例11: setup_platform
# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the demo switches."""
host = config.get(CONF_HOST)
mode = config.get(CONF_MODE)
prefix = config.get(CONF_PREFIX)
if host == None:
_Log.error('pls enter host ip address!')
return False
# def SendControlCommand(call):
# code = call.data.get('code')
# _Log.info(code)
# hass.states.set('WuKong.Send_Control_Command', code)
service = WuKongService(hass,host,mode)
hass.services.register(DOMAIN, 'Send_Control_Command', service.SendControlCommand)
hass.services.register(DOMAIN, 'Send_Open_Command', service.SendOpenCommand)
hass.services.register(DOMAIN, 'Send_Install_Command', service.SendInstallCommand)
hass.services.register(DOMAIN, 'Send_Clean_Command', service.SendCleanCommand)
hass.services.register(DOMAIN, 'Send_Command_Queue', service.SendCommandQueue)
hass.services.register(DOMAIN, 'Send_Connect_Command', service.SendConnectCommand)
add_devices_callback([
WuKongSwitch(hass, host, prefix, 'tv_ctl_up', False, 'mdi:arrow-up-bold-circle', True, mode,19),
WuKongSwitch(hass, host, prefix, 'tv_ctl_down', False, 'mdi:arrow-down-bold-circle', True, mode,20),
WuKongSwitch(hass, host, prefix, 'tv_ctl_left', False, 'mdi:arrow-left-bold-circle', True, mode,21),
WuKongSwitch(hass, host, prefix, 'tv_ctl_right', False, 'mdi:arrow-right-bold-circle', True, mode,22),
WuKongSwitch(hass, host, prefix, 'tv_ctl_home', False, 'mdi:home', True, mode,3),
WuKongSwitch(hass, host, prefix, 'tv_ctl_back', False, 'mdi:backup-restore', True, mode,4),
WuKongSwitch(hass, host, prefix, 'tv_ctl_ok', False, 'mdi:adjust', True, mode,23),
WuKongSwitch(hass, host, prefix, 'tv_ctl_volup', False, 'mdi:volume-high', True, mode,24),
WuKongSwitch(hass, host, prefix, 'tv_ctl_voldown', False, 'mdi:volume-medium', True, mode,25),
WuKongSwitch(hass, host, prefix, 'tv_ctl_power', False, 'mdi:power', True, mode, 26),
WuKongSwitch(hass, host, prefix, 'tv_ctl_menu', False, 'mdi:menu', True, mode, 82),
WuKongSwitch(hass, host, prefix, 'tv_ctl_1', False, 'mdi:numeric-1-box', True, mode,8),
WuKongSwitch(hass, host, prefix, 'tv_ctl_2', False, 'mdi:numeric-2-box', True, mode,9),
WuKongSwitch(hass, host, prefix, 'tv_ctl_3', False, 'mdi:numeric-3-box', True, mode,10),
WuKongSwitch(hass, host, prefix, 'tv_ctl_4', False, 'mdi:numeric-4-box', True, mode,11),
WuKongSwitch(hass, host, prefix, 'tv_ctl_5', False, 'mdi:numeric-5-box', True, mode,12),
WuKongSwitch(hass, host, prefix, 'tv_ctl_6', False, 'mdi:numeric-6-box', True, mode,13),
WuKongSwitch(hass, host, prefix, 'tv_ctl_7', False, 'mdi:numeric-7-box', True, mode,14),
WuKongSwitch(hass, host, prefix, 'tv_ctl_8', False, 'mdi:numeric-8-box', True, mode,15),
WuKongSwitch(hass, host, prefix, 'tv_ctl_9', False, 'mdi:numeric-9-box', True, mode,16),
WuKongSwitch(hass, host, prefix, 'tv_ctl_0', False, 'mdi:numeric-0-box', True, mode,7),
WuKongSwitch(hass, host, prefix, 'tv_ctl_clean', False, 'mdi:notification-clear-all', True, mode,999),
])