diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index 1515ce33c6e..ceba82cf544 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -12,6 +12,8 @@ from homeassistant.const import ( ATTR_STATE, CONF_DEVICE, CONF_DEVICES, + CONF_HOST, + CONF_PORT, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, POWER_WATT, @@ -80,17 +82,21 @@ RFX_DEVICES = {} _LOGGER = logging.getLogger(__name__) DATA_RFXOBJECT = "rfxobject" -CONFIG_SCHEMA = vol.Schema( +BASE_SCHEMA = vol.Schema( { - DOMAIN: vol.Schema( - { - vol.Required(CONF_DEVICE): cv.string, - vol.Optional(CONF_DEBUG, default=False): cv.boolean, - vol.Optional(CONF_DUMMY, default=False): cv.boolean, - } - ) - }, - extra=vol.ALLOW_EXTRA, + vol.Optional(CONF_DEBUG, default=False): cv.boolean, + vol.Optional(CONF_DUMMY, default=False): cv.boolean, + } +) + +DEVICE_SCHEMA = BASE_SCHEMA.extend({vol.Required(CONF_DEVICE): cv.string}) + +PORT_SCHEMA = BASE_SCHEMA.extend( + {vol.Required(CONF_PORT): cv.port, vol.Optional(CONF_HOST): cv.string} +) + +CONFIG_SCHEMA = vol.Schema( + {DOMAIN: vol.Any(DEVICE_SCHEMA, PORT_SCHEMA)}, extra=vol.ALLOW_EXTRA ) @@ -115,7 +121,9 @@ def setup(hass, config): for subscriber in RECEIVED_EVT_SUBSCRIBERS: subscriber(event) - device = config[DOMAIN][ATTR_DEVICE] + device = config[DOMAIN].get(ATTR_DEVICE) + host = config[DOMAIN].get(CONF_HOST) + port = config[DOMAIN].get(CONF_PORT) debug = config[DOMAIN][ATTR_DEBUG] dummy_connection = config[DOMAIN][ATTR_DUMMY] @@ -123,6 +131,14 @@ def setup(hass, config): rfx_object = rfxtrxmod.Connect( device, None, debug=debug, transport_protocol=rfxtrxmod.DummyTransport2 ) + elif port is not None: + # If port is set then we create a TCP connection + rfx_object = rfxtrxmod.Connect( + (host, port), + None, + debug=debug, + transport_protocol=rfxtrxmod.PyNetworkTransport, + ) else: rfx_object = rfxtrxmod.Connect(device, None, debug=debug) diff --git a/homeassistant/components/rfxtrx/manifest.json b/homeassistant/components/rfxtrx/manifest.json index a75a8ba9eb1..e26ceb7ef57 100644 --- a/homeassistant/components/rfxtrx/manifest.json +++ b/homeassistant/components/rfxtrx/manifest.json @@ -3,7 +3,7 @@ "name": "Rfxtrx", "documentation": "https://www.home-assistant.io/integrations/rfxtrx", "requirements": [ - "pyRFXtrx==0.23" + "pyRFXtrx==0.24" ], "dependencies": [], "codeowners": [ diff --git a/requirements_all.txt b/requirements_all.txt index b92a5b952eb..09498704259 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1073,7 +1073,7 @@ pyHS100==0.3.5 pyMetno==0.4.6 # homeassistant.components.rfxtrx -pyRFXtrx==0.23 +pyRFXtrx==0.24 # homeassistant.components.switchmate # pySwitchmate==0.4.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index af8bbbbc107..484bbd23a43 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -371,7 +371,7 @@ pyHS100==0.3.5 pyMetno==0.4.6 # homeassistant.components.rfxtrx -pyRFXtrx==0.23 +pyRFXtrx==0.24 # homeassistant.components.nextbus py_nextbusnext==0.1.4