Skip to content

Commit a314e54

Browse files
committed
Fixed changing IP
1 parent 88d91cb commit a314e54

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

custom_components/dirigera_platform/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def handle_dump_data(call):
6565
else:
6666
hub = dirigera.Hub(token, ip)
6767
json_resp = hub.get("/devices")
68-
logger.error(f"TYPE IS {type(json_resp)}")
68+
logger.debug(f"TYPE IS {type(json_resp)}")
6969
#import json
7070
#devices_json = json.loads(json_resp)
7171
# Sanitize the dump
@@ -161,14 +161,11 @@ async def async_setup_entry(
161161
) -> bool:
162162
global hub_events
163163
"""Set up platform from a ConfigEntry."""
164-
logger.debug("Staring async_setup_entry in init...")
165-
#logger.debug(dict(entry.data))
166-
#logger.debug(f"async_setup_entry {entry.unique_id} {entry.state} {entry.entry_id} {entry.title} {entry.domain}")
164+
logger.info("Staring async_setup_entry in init...")
165+
167166
hass.data.setdefault(DOMAIN, {})
168167
hass_data = dict(entry.data)
169168

170-
#logger.debug(f"hass_data : {hass_data}")
171-
172169
# for backward compatibility
173170
hide_device_set_bulbs : bool = True
174171
if CONF_HIDE_DEVICE_SET_BULBS in hass_data:
@@ -180,10 +177,10 @@ async def async_setup_entry(
180177
# If its not with HASS update it
181178
hass_data[CONF_HIDE_DEVICE_SET_BULBS] = hide_device_set_bulbs
182179

183-
logger.debug(f"******** HIDE : {hide_device_set_bulbs} ********")
184180
ip = hass_data[CONF_IP_ADDRESS]
185181
# Registers update listener to update config entry when options are updated.
186182
unsub_options_update_listener = entry.add_update_listener(options_update_listener)
183+
entry.async_on_unload(entry.add_update_listener(options_update_listener))
187184

188185
# Store a reference to the unsubscribe function to cleanup if an entry is unloaded.
189186
hass_data["unsub_options_update_listener"] = unsub_options_update_listener
@@ -224,7 +221,8 @@ async def async_setup_entry(
224221
async def options_update_listener(
225222
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
226223
):
227-
logger.debug("In options_update_listener")
224+
logger.debug("**********In options_update_listener")
225+
logger.debug(config_entry)
228226
"""Handle options update."""
229227
await hass.config_entries.async_reload(config_entry.entry_id)
230228

custom_components/dirigera_platform/config_flow.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ async def async_step_init(
150150
# Called when configure is called from an existing configured integration
151151
# The first screen that is shown, asl called after IP when submitted
152152

153-
logger.debug("OPTIONS async_step_init called....")
154-
logger.debug(user_input)
153+
logger.error("OPTIONS async_step_init called....")
154+
logger.error(user_input)
155155

156156
errors: Dict[str, str] = {}
157157

158158
if user_input is not None:
159-
logger.debug("async step init user input is not none...")
160-
logger.debug("user_input is ")
161-
logger.debug(user_input)
159+
logger.error("async step init user input is not none...")
160+
logger.error("user_input is ")
161+
logger.error(user_input)
162162

163163
self.ip = user_input[CONF_IP_ADDRESS]
164164
self.hide_device_set_bulbs = user_input[CONF_HIDE_DEVICE_SET_BULBS]
@@ -169,7 +169,7 @@ async def async_step_init(
169169
errors["base"] = "ip_not_specified"
170170
else:
171171
try:
172-
logger.debug("Moving to second step....")
172+
logger.error("Moving to second step....")
173173
if self.ip == "mock":
174174
logger.warning(
175175
"Using mock ip, skipping token generation step 1"
@@ -201,8 +201,8 @@ async def async_step_action(
201201
# Since IP is specified we will try and get the auth token an set that up in
202202
# the config for use at a later time
203203
errors: Dict[str, str] = {}
204-
logger.debug("ip {}".format(self.ip))
205-
logger.debug(f"hide device set bulbs {self.hide_device_set_bulbs}")
204+
logger.error("ip {}".format(self.ip))
205+
logger.error(f"hide device set bulbs {self.hide_device_set_bulbs}")
206206
# Try and get the token step_2
207207
try:
208208
if self.ip == "mock":
@@ -213,14 +213,18 @@ async def async_step_action(
213213
get_dirigera_token_step_two, self.ip, self.code, self.code_verifier
214214
)
215215
logger.info("Successful generating token")
216-
logger.debug(token)
216+
logger.error(token)
217217

218218
user_input[CONF_IP_ADDRESS] = self.ip
219219
user_input[CONF_TOKEN] = token
220220
user_input[CONF_HIDE_DEVICE_SET_BULBS] = self.hide_device_set_bulbs
221-
logger.debug("before create entry...")
222-
logger.debug(user_input)
221+
logger.error("before create entry...")
222+
logger.error(user_input)
223223

224+
self.hass.config_entries.async_update_entry(self.config_entry, data=user_input,
225+
title="IKEA Dirigera Hub : {}".format(user_input[CONF_IP_ADDRESS]),)
226+
#return self.async_create_entry(title=None, data=None)
227+
#return self.config_entry.async_update_entry(user_input)
224228
return self.async_create_entry(
225229
title="IKEA Dirigera Hub : {}".format(user_input[CONF_IP_ADDRESS]),
226230
data=user_input,

0 commit comments

Comments
 (0)