52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""Platform for light integration."""
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from .discover_gateways import start_discovery_client
|
|
import voluptuous as vol
|
|
|
|
from pprint import pformat
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
|
from homeassistant.components.sensor import SensorEntity
|
|
from homeassistant.const import CONF_NAME, CONF_MAC
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
from homeassistant.helpers.typing import ConfigType
|
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
|
|
|
_LOGGER = logging.getLogger("atc_mi_thermometer_gateway")
|
|
|
|
|
|
def setup_platform(
|
|
hass: HomeAssistant,
|
|
config: ConfigType,
|
|
add_entities: AddEntitiesCallback,
|
|
discovery_info: DiscoveryInfoType | None = None):
|
|
|
|
_LOGGER.info(pformat(config))
|
|
gateway = start_discovery_client()
|
|
|
|
add_entities([Gateway(ip=gateway[0])])
|
|
|
|
|
|
class Gateway(SensorEntity):
|
|
def __init__(self, ip:str):
|
|
self._ip = ip
|
|
self._online = False
|
|
self._discovered_devices = []
|
|
|
|
@property
|
|
def ip(self):
|
|
return self._ip
|
|
|
|
@property
|
|
def online(self):
|
|
return self._online
|
|
|
|
@property
|
|
def discovered_devices(self):
|
|
return self._discovered_devices
|