From e063a1303f824568efdc5652d455739abcef33be Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Mon, 31 May 2021 16:07:55 +0000 Subject: [PATCH] Removed custom ondilo stuff, since official version available --- config_creation/manual_config.yaml | 4 -- custom_components/ondilo/__init__.py | 78 ------------------------- custom_components/ondilo/config_flow.py | 35 ----------- custom_components/ondilo/const.py | 4 -- custom_components/ondilo/manifest.json | 10 ---- custom_components/ondilo/sensor.py | 52 ----------------- 6 files changed, 183 deletions(-) delete mode 100644 custom_components/ondilo/__init__.py delete mode 100644 custom_components/ondilo/config_flow.py delete mode 100644 custom_components/ondilo/const.py delete mode 100644 custom_components/ondilo/manifest.json delete mode 100644 custom_components/ondilo/sensor.py diff --git a/config_creation/manual_config.yaml b/config_creation/manual_config.yaml index 81cbb49..c6052df 100644 --- a/config_creation/manual_config.yaml +++ b/config_creation/manual_config.yaml @@ -16,10 +16,6 @@ updater: #input_text: -ondilo: - username: customer_api - password: !secret ondilo_pw - # Uncomment this if you are using SSL/TLS, running in Docker container, etc. http: base_url: https://ha.bauer.tech diff --git a/custom_components/ondilo/__init__.py b/custom_components/ondilo/__init__.py deleted file mode 100644 index 62b10a5..0000000 --- a/custom_components/ondilo/__init__.py +++ /dev/null @@ -1,78 +0,0 @@ -import asyncio -import logging - -import voluptuous as vol - -from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_USERNAME, CONF_PASSWORD -from homeassistant.core import HomeAssistant -from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv - -from . import config_flow -from .const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN - -_LOGGER = logging.getLogger(__name__) - -CONFIG_SCHEMA = vol.Schema( - { - DOMAIN: vol.Schema( - { - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, - } - ) - }, - extra=vol.ALLOW_EXTRA, -) - -PLATFORMS = ["sensor"] - - -async def async_setup(hass: HomeAssistant, config: dict): - """Set up the ondilo component.""" - hass.data[DOMAIN] = {} - print("Init1") - if DOMAIN not in config: - print("Init early out") - return True - - config_flow.OndiloFlowHandler.async_register_implementation( - hass, - config_entry_oauth2_flow.LocalOAuth2Implementation( - hass, - DOMAIN, - config[DOMAIN][CONF_USERNAME], - config[DOMAIN][CONF_PASSWORD], - OAUTH2_AUTHORIZE, - OAUTH2_TOKEN, - ), - ) - print("init finish") - return True - - -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): - """Set up ondilo from a config entry.""" - implementation = await config_entry_oauth2_flow.async_get_config_entry_implementation( - hass, entry - ) - session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) - hass.data[DOMAIN] = {"session": session} - hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, "sensor")) - return True - - -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): - """Unload a config entry.""" - unload_ok = all( - await asyncio.gather( - *[ - hass.config_entries.async_forward_entry_unload(entry, component) - for component in PLATFORMS - ] - ) - ) - if unload_ok: - hass.data[DOMAIN] = {} - - return unload_ok diff --git a/custom_components/ondilo/config_flow.py b/custom_components/ondilo/config_flow.py deleted file mode 100644 index 0c66be0..0000000 --- a/custom_components/ondilo/config_flow.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Config flow for Ondilo.""" -import logging - -from homeassistant import config_entries -from homeassistant.helpers import config_entry_oauth2_flow - -from .const import DOMAIN - -_LOGGER = logging.getLogger(__name__) - - -class OndiloFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN): - """Config flow to handle Ondilo OAuth2 authentication.""" - - DOMAIN = DOMAIN - CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL - - @property - def logger(self) -> logging.Logger: - """Return logger.""" - return logging.getLogger(__name__) - - async def async_step_user(self, user_input=None): - """Handle a flow start.""" - print("async_step_user!!") - if self.hass.config_entries.async_entries(DOMAIN): - print("abort because already setup") - return self.async_abort(reason="already_setup") - print("works!") - return await super().async_step_user(user_input) - - async def async_step_homekit(self, homekit_info): - """Handle HomeKit discovery.""" - print("async_step_homekit!!") - return await self.async_step_user() diff --git a/custom_components/ondilo/const.py b/custom_components/ondilo/const.py deleted file mode 100644 index 42f03ae..0000000 --- a/custom_components/ondilo/const.py +++ /dev/null @@ -1,4 +0,0 @@ -DOMAIN = "ondilo" -OAUTH2_AUTHORIZE = "https://interop.ondilo.com/oauth2/authorize" -OAUTH2_TOKEN = "https://interop.ondilo.com/oauth2/token" -URL_API_PREFIX = "https://interop.ondilo.com/api/customer/v1" diff --git a/custom_components/ondilo/manifest.json b/custom_components/ondilo/manifest.json deleted file mode 100644 index 98651de..0000000 --- a/custom_components/ondilo/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "domain": "ondilo", - "name": "Ondilo Pool Monitor", - "documentation": "", - "requirements": [], - "dependencies": [], - "codeowners": ["@mabau"], - "config_flow": true, - "version": "0.1" -} diff --git a/custom_components/ondilo/sensor.py b/custom_components/ondilo/sensor.py deleted file mode 100644 index faab9a9..0000000 --- a/custom_components/ondilo/sensor.py +++ /dev/null @@ -1,52 +0,0 @@ - -from .const import DOMAIN, URL_API_PREFIX -from datetime import timedelta -from homeassistant.helpers.entity import Entity -from homeassistant.util import Throttle -import logging - -MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5) - -_LOGGER = logging.getLogger(__name__) - - -async def api_call(session, url, data={}): - return await session.async_request(method="GET", - url=f"{URL_API_PREFIX}/{url}", - json=data).json() - - -class OndiloData: - def __init__(self, session): - self._session = session - - @Throttle(MIN_TIME_BETWEEN_UPDATES) - async def async_update(self): - pass - - -class PHSensor(Entity): - def __init__(self, data): - self._data = data - - async def async_update(self): - self._data.async_update() - - -class ORPSensor(Entity): - def __init__(self, data): - self._data = data - - async def async_update(self): - self._data.async_update() - - -async def async_setup_entry(hass, entry, async_add_entities): - session = hass.data[DOMAIN]['session'] - res = await api_call(session, "pools") - print(res) - _LOGGER.warn(res) - # data = OndiloData(session) - # get pools - # sensors = [PHSensor(data), ORPSensor(data)] - # async_add_entities(sensors)