1 """Support for Sky Hub."""
3 from __future__
import annotations
7 from pyskyqhub.skyq_hub
import SkyQHub
8 import voluptuous
as vol
11 DOMAIN
as DEVICE_TRACKER_DOMAIN,
12 PLATFORM_SCHEMA
as DEVICE_TRACKER_PLATFORM_SCHEMA,
21 _LOGGER = logging.getLogger(__name__)
23 PLATFORM_SCHEMA = DEVICE_TRACKER_PLATFORM_SCHEMA.extend(
24 {vol.Optional(CONF_HOST): cv.string}
29 hass: HomeAssistant, config: ConfigType
30 ) -> SkyHubDeviceScanner |
None:
31 """Return a Sky Hub scanner if successful."""
32 host = config[DEVICE_TRACKER_DOMAIN].
get(CONF_HOST,
"192.168.1.254")
34 hub = SkyQHub(websession, host)
36 _LOGGER.debug(
"Initialising Sky Hub")
37 await hub.async_connect()
45 """Class which queries a Sky Hub router."""
48 """Initialise the scanner."""
53 """Scan for new devices and return a list with found device IDs."""
55 return [device.mac
for device
in self.
last_resultslast_results]
58 """Return the name of the given device."""
60 (result.name
for result
in self.
last_resultslast_results
if result.mac == device),
65 """Get extra attributes of a device."""
67 (result
for result
in self.
last_resultslast_results
if result.mac == device),
None
72 return device.asdict()
75 """Ensure the information from the Sky Hub is up to date."""
76 _LOGGER.debug(
"Scanning")
78 if not (data := await self.
_hub_hub.async_get_skyhub_data()):
def async_scan_devices(self)
def async_get_device_name(self, device)
def _async_update_info(self)
def async_get_extra_attributes(self, device)
web.Response get(self, web.Request request, str config_key)
SkyHubDeviceScanner|None async_get_scanner(HomeAssistant hass, ConfigType config)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)