def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Greenwave Reality Platform.""" import greenwavereality as greenwave import os host = config.get(CONF_HOST) tokenfile = hass.config.path(".greenwave") if config.get(CONF_VERSION) == 3: if os.path.exists(tokenfile): with open(tokenfile) as tokenfile: token = tokenfile.read() else: try: token = greenwave.grab_token(host, "hass", "homeassistant") except PermissionError: _LOGGER.error("The Gateway Is Not In Sync Mode") raise with open(tokenfile, "w+") as tokenfile: tokenfile.write(token) else: token = None bulbs = greenwave.grab_bulbs(host, token) add_entities( GreenwaveLight(device, host, token, GatewayData(host, token)) for device in bulbs.values())
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the Greenwave Reality Platform.""" host = config.get(CONF_HOST) tokenfilename = hass.config.path(".greenwave") if config.get(CONF_VERSION) == 3: if os.path.exists(tokenfilename): with open(tokenfilename, encoding="utf8") as tokenfile: token = tokenfile.read() else: try: token = greenwave.grab_token(host, "hass", "homeassistant") except PermissionError: _LOGGER.error("The Gateway Is Not In Sync Mode") raise with open(tokenfilename, "w+", encoding="utf8") as tokenfile: tokenfile.write(token) else: token = None bulbs = greenwave.grab_bulbs(host, token) add_entities( GreenwaveLight(device, host, token, GatewayData(host, token)) for device in bulbs.values())
def __init__(self, host, token): """Initialize the data object.""" import greenwavereality as greenwave self._host = host self._token = token self._greenwave = greenwave.grab_bulbs(host, token)
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Greenwave Reality Platform.""" import greenwavereality as greenwave import os host = config.get(CONF_HOST) tokenfile = hass.config.path('.greenwave') if config.get(CONF_VERSION) == 3: if os.path.exists(tokenfile): tokenfile = open(tokenfile) token = tokenfile.read() tokenfile.close() else: try: token = greenwave.grab_token(host, 'hass', 'homeassistant') except PermissionError: _LOGGER.error('The Gateway Is Not In Sync Mode') raise tokenfile = open(tokenfile, "w+") tokenfile.write(token) tokenfile.close() else: token = None bulbs = greenwave.grab_bulbs(host, token) add_devices(GreenwaveLight(device, host, token, GatewayData(host, token)) for device in bulbs.values())
def update(self): """Get the latest data from the gateway.""" self._greenwave = greenwave.grab_bulbs(self._host, self._token) return self._greenwave
def update(self): """Get the latest data from the gateway.""" import greenwavereality as greenwave self._greenwave = greenwave.grab_bulbs(self._host, self._token) return self._greenwave
def __init__(self, host, token): """Initialize the data object.""" import greenwavereality as greenwave self._host = host self._token = token self._greenwave = greenwave.grab_bulbs(host, token)