Xiaomi Gateway: Allow static configuration of a gateway without discovery (#9464)
* Configuration parameter "host" introduced. Will skip the discovery of the host. * Provide a proper default port. Log message reformatted. * PyXiaomiGateway version bumped: The new feature was introduced with v0.4.0. * requirements_all.txt updated. * Native default for config parameter used.
This commit is contained in:
parent
ced642c862
commit
94dcf36d7c
2 changed files with 14 additions and 3 deletions
|
@ -9,7 +9,7 @@ from homeassistant.const import (ATTR_BATTERY_LEVEL, EVENT_HOMEASSISTANT_STOP,
|
|||
CONF_MAC)
|
||||
|
||||
REQUIREMENTS = ['https://github.com/Danielhiversen/PyXiaomiGateway/archive/'
|
||||
'0.3.2.zip#PyXiaomiGateway==0.3.2']
|
||||
'0.4.0.zip#PyXiaomiGateway==0.4.0']
|
||||
|
||||
ATTR_GW_MAC = 'gw_mac'
|
||||
ATTR_RINGTONE_ID = 'ringtone_id'
|
||||
|
@ -39,6 +39,17 @@ def _validate_conf(config):
|
|||
raise vol.Invalid('Invalid key %s.'
|
||||
' Key must be 16 characters', key)
|
||||
res_gw_conf['key'] = key
|
||||
|
||||
host = gw_conf.get('host')
|
||||
if host is not None:
|
||||
res_gw_conf['host'] = host
|
||||
res_gw_conf['port'] = gw_conf.get('port', 9898)
|
||||
|
||||
_LOGGER.warning(
|
||||
'Static address (%s:%s) of the gateway provided. '
|
||||
'Discovery of this host will be skipped.',
|
||||
res_gw_conf['host'], res_gw_conf['port'])
|
||||
|
||||
res_config.append(res_gw_conf)
|
||||
return res_config
|
||||
|
||||
|
@ -89,7 +100,7 @@ def setup(hass, config):
|
|||
_LOGGER.error("No gateway discovered")
|
||||
return False
|
||||
hass.data[PY_XIAOMI_GATEWAY].listen()
|
||||
_LOGGER.debug("Listening for broadcast")
|
||||
_LOGGER.debug("Gateways discovered. Listening for broadcasts")
|
||||
|
||||
for component in ['binary_sensor', 'sensor', 'switch', 'light', 'cover']:
|
||||
discovery.load_platform(hass, component, DOMAIN, {}, config)
|
||||
|
|
|
@ -302,7 +302,7 @@ holidays==0.8.1
|
|||
http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
|
||||
|
||||
# homeassistant.components.xiaomi_aqara
|
||||
https://github.com/Danielhiversen/PyXiaomiGateway/archive/0.3.2.zip#PyXiaomiGateway==0.3.2
|
||||
https://github.com/Danielhiversen/PyXiaomiGateway/archive/0.4.0.zip#PyXiaomiGateway==0.4.0
|
||||
|
||||
# homeassistant.components.sensor.dht
|
||||
# https://github.com/adafruit/Adafruit_Python_DHT/archive/da8cddf7fb629c1ef4f046ca44f42523c9cf2d11.zip#Adafruit_DHT==1.3.2
|
||||
|
|
Loading…
Add table
Reference in a new issue