diff --git a/.coveragerc b/.coveragerc index 600701d792b..7f519f8970a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -94,6 +94,7 @@ omit = homeassistant/components/bom/sensor.py homeassistant/components/bom/weather.py homeassistant/components/braviatv/media_player.py + homeassistant/components/broadlink/remote.py homeassistant/components/broadlink/sensor.py homeassistant/components/broadlink/switch.py homeassistant/components/brottsplatskartan/sensor.py diff --git a/CODEOWNERS b/CODEOWNERS index cb86e5c0c90..e859a9d0eac 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -50,7 +50,7 @@ homeassistant/components/bizkaibus/* @UgaitzEtxebarria homeassistant/components/blink/* @fronzbot homeassistant/components/bmw_connected_drive/* @gerard33 homeassistant/components/braviatv/* @robbiet480 -homeassistant/components/broadlink/* @danielhiversen +homeassistant/components/broadlink/* @danielhiversen @felipediel homeassistant/components/brunt/* @eavanvalkenburg homeassistant/components/bt_smarthub/* @jxwolstenholme homeassistant/components/buienradar/* @mjj4791 @ties diff --git a/homeassistant/components/broadlink/__init__.py b/homeassistant/components/broadlink/__init__.py index 589da62feaa..521cd68780c 100644 --- a/homeassistant/components/broadlink/__init__.py +++ b/homeassistant/components/broadlink/__init__.py @@ -1,7 +1,9 @@ """The broadlink component.""" import asyncio from base64 import b64decode, b64encode +from binascii import unhexlify import logging +import re import socket from datetime import timedelta @@ -27,6 +29,31 @@ def data_packet(value): return b64decode(value) +def hostname(value): + """Validate a hostname.""" + host = str(value).lower() + if len(host) > 253: + raise ValueError + if host[-1] == ".": + host = host[:-1] + allowed = re.compile(r"(?!-)[a-z\d-]{1,63}(?