Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed all TODO's, commented debug code and code that is not used at… #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions custom_components/neerslag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from .const import DOMAIN

# TODO List the platforms that you want to support.
# For your initial PR, limit it to 1 platform.
PLATFORMS = ["sensor"]

_LOGGER = logging.getLogger(__name__)
Expand All @@ -19,10 +17,6 @@ async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry
"""Handle options update."""

_LOGGER.info("----------------This is being executed-------options_update_listener----------------")
# await hass.config_entries.async_remove(config_entry.entry_id)
# rr = hass.config_entries.async_entries(DOMAIN)
# hass.config_entries.async_update_entry(config_entry, data=config_entry.options)
# await hass.config_entries.async_reload(config_entry.entry_id)
hass.config_entries.async_update_entry(config_entry, data=config_entry.options)


Expand All @@ -37,15 +31,13 @@ async def async_setup(hass: HomeAssistant, config_entry: dict):
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up Neerslag Sensor (Buienalarm / Buienradar) from a config entry."""

# hass.states.async_set("neerslag_sensor.useBuienalarm", ConfigEntry.)

# TODO Store an API object for your platforms to access
# hass.data[DOMAIN][entry.entry_id] = MyApi(...)
hass.data[DOMAIN][config_entry.entry_id] = {}

hass_data = dict(config_entry.data)

# Registers update listener to update config entry when options are updated.
unsub_options_update_listener = config_entry.add_update_listener(options_update_listener)

# Store a reference to the unsubscribe function to cleanup if an entry is unloaded.
hass_data["unsub_options_update_listener"] = unsub_options_update_listener
hass.data[DOMAIN][config_entry.entry_id] = hass_data
Expand All @@ -60,7 +52,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):

async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
# Remove options_update_listener.

_LOGGER.info("REMOVE ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")

"""Unload a config entry."""
Expand Down
34 changes: 1 addition & 33 deletions custom_components/neerslag/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

_LOGGER = logging.getLogger(__name__)

# TODO adjust the data schema to the data that you need
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Optional("buienalarm", default=False): bool,
vol.Optional("buienalarmLatitude", description={"suggested_value": "55.000"}): str,
vol.Optional("buienalarmLongitude", description={"suggested_value": "5.000"}): str,
Expand All @@ -27,23 +26,6 @@ async def validate_input(hass: core.HomeAssistant, data):

Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
"""
# TODO validate the data can be used to set up a connection.

# If your PyPI package is not built with async, pass your methods
# to the executor:
# await hass.async_add_executor_job(
# your_validate_func, data["username"], data["password"]
# )

# hub = PlaceholderHub(data["host"])

# if not await hub.authenticate(data["username"], data["password"]):
# raise InvalidAuth

# If you cannot connect:
# throw CannotConnect
# If the authentication is wrong:
# InvalidAuth

# Return info that you want to store in the config entry.
return {"title": "Neerslag"}
Expand All @@ -53,7 +35,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Neerslag Sensor (Buienalarm / Buienradar)."""

VERSION = 1
# TODO pick one of the available connection classes in homeassistant/config_entries.py

CONNECTION_CLASS = config_entries.CONN_CLASS_UNKNOWN

async def async_step_user(self, user_input=None):
Expand All @@ -72,11 +54,8 @@ async def async_step_user(self, user_input=None):
errors = {}

try:
# info = await validate_input(self.hass, user_input)
title = "Neerslag App"
data = user_input
# _LOGGER.info("Dit wordt nu uitgevoerd...........")
# _LOGGER.info(data)

except CannotConnect:
errors["base"] = "cannot_connect"
Expand Down Expand Up @@ -106,10 +85,6 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:

async def async_step_init(self, user_input=None):

# _LOGGER.info("HIER>>>")
# _LOGGER.info(self.config_entry.data.get("buienalarmLatitude"))
# _LOGGER.info(self.config_entry.data.get("buienalarm"))
# _LOGGER.info(self.config_entry.data.get("NeerslagSensorUseHAforLocation"))
testtest = vol.Schema({vol.Optional("buienalarm", default=self.config_entry.data.get("buienalarm")): bool,
vol.Optional("buienalarmLatitude", default=self.config_entry.data.get("buienalarmLatitude")): str,
vol.Optional("buienalarmLongitude", default=self.config_entry.data.get("buienalarmLongitude")): str,
Expand All @@ -119,15 +94,8 @@ async def async_step_init(self, user_input=None):
vol.Optional("NeerslagSensorUseHAforLocation", default=self.config_entry.data.get("NeerslagSensorUseHAforLocation")): bool
})

# _LOGGER.info("----->>>>---------------")
# _LOGGER.info(self.config_entry.options)
# _LOGGER.info(self.config_entry.data)
# _LOGGER.info("------<<<<--------------")
"""Manage the options."""
if user_input is not None:
# _LOGGER.info(user_input)
# _LOGGER.info("<><><><><><><><><><>")
# self.config_entry.data = user_input
return self.async_create_entry(title="", data=user_input)

return self.async_show_form(
Expand Down
Loading