From a54d507b34300baded4b7df381120d6a0338b180 Mon Sep 17 00:00:00 2001 From: sudoxnym <76703581+sudoxnym@users.noreply.github.com> Date: Fri, 17 May 2024 14:18:04 -0600 Subject: [PATCH] Add files via upload --- .../saas/__pycache__/__init__.cpython-312.pyc | Bin 4346 -> 4346 bytes .../saas/__pycache__/button.cpython-312.pyc | Bin 14654 -> 14654 bytes .../__pycache__/config_flow.cpython-312.pyc | Bin 8542 -> 9113 bytes .../saas/__pycache__/const.cpython-312.pyc | Bin 3602 -> 3602 bytes .../saas/__pycache__/sensor.cpython-312.pyc | Bin 27176 -> 27176 bytes .../saas/__pycache__/services.cpython-312.pyc | Bin 5240 -> 5240 bytes custom_components/saas/config_flow.py | 37 ++++++++++++------ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/custom_components/saas/__pycache__/__init__.cpython-312.pyc b/custom_components/saas/__pycache__/__init__.cpython-312.pyc index 8b2206af9dad37f95cad3e0504f83c6e55625013..1a327c073f65365c5c40e8062bf9f824c99fe494 100644 GIT binary patch delta 20 acmeyR_)C%dG%qg~0}y=O=)RHry#N47PX^fl delta 20 acmeyR_)C%dG%qg~0}%LbciYJQUH||@)&@2J diff --git a/custom_components/saas/__pycache__/button.cpython-312.pyc b/custom_components/saas/__pycache__/button.cpython-312.pyc index 944502d2b137ed74be3f883cdf384c53b96fac02..2d5c9a888f1a724f304b777779cde36ff51f6e7f 100644 GIT binary patch delta 20 acmdm2w6BQ!G%qg~0}y=O=)RHL*b)FrdRZgphQ}CdJ#3Zp!+gh z+%%pKlf;ZAn~4r|Sxgq=hehX1P`|V*Nm=*8Wm~o^S#ZkKElYOJ?HV81&WGRqpa0`` z{{R1Z+;3Z^IyAS{>TE#9(JLJT8*LwJK2pH*mp)Y#LRfO?E9I|@yqOqN`S@;5KK?%E z{o)onRYe4^5cG`%grTq>8HfsX5I7IeHYzvc4^?is4L?xz!dBd+?zglNwTnRw)Y?uU z!Vqvci05bOEyNRQ3Ya%JY|~W9f*{J^9?cA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#_HOOgjll{GA=?)@O@hvX5vZi^L{<= zb8gRhZ_fp9ZC8J^T1yD5KU;Pjq1xB#mqzNl{JpW3(sh@AG5x^|ekkS~;%=!!{8svL zQ!j>=lpfX-k@1*5nv8NAr1(yNPYDmA?-!q0_R^quU>TqRvBx^>+5u@F2asX_ z_4UBKX6*(hRW+u{!mYL$%p^_5WRX#AVnRJjnV@CfAiIbSuqa8>Q}^}CLPQ|a?M2@O z4n8Y$oe(ETnw_U5}1DgI*(^RIH;$psf{$Dl4d4Y*KBC30P(^Tj{GPNw0iqGFFFmS}H>2jy5RK!dqXm z6eR~pBhecQSwdD3zGFt#iy;|n!uDCKzNVN;%SDZ%0-OyQ^A+pQ?Em##Qj6UYHb|n< zjQplN@YGJzX>wc|B-8YBX`1@VUbpQFPlV&KdR=^L8=(6|vwcLa1ATGE-c^~C6B7v? zE*E#^YcV}<_ieAr8AC^t@pz2qlxS>ZGS1gyy%9l1cn$$)A!mwB==?+|5zQHs$Mi&U zBE@?kFJe`z46Vp&69=m7ujb5s$0M;kA*aMRPjcRl?WN(=iHS%kJd)(PPbth8UVF|G zndBU_L(#Av&RHgpfsI8A5sjr3;MC*d{>;=o@#Ue6HUw=TdRi^mI|kxvI+%4fXPnJ9ecP@aTypwPTYnmUEjv7w8J+^taoWfJ zCL~06vN>zk*^+U#To}*uvd;dDvwy+15Lt49#Nmwd@J;6{(6W~eUUt^6qqCzdg{O4Y z=-92wS3RwOydM%iBj1H*vKwI!0DOL-XfhHC@s}_aLl{PQ5uxxmjb5M#c&@1`fOp8x zvg7G}Psl{;U4T)H$Av fP9BYQ^C?l)I9}aLX~~=?>uSxoTJI5z^1}ZD3hIPK diff --git a/custom_components/saas/__pycache__/const.cpython-312.pyc b/custom_components/saas/__pycache__/const.cpython-312.pyc index 35bf02920edf5aadfbb2a0cbfaadaddcc41d5aa0..01a94ac344b022681279c649105cc49a36be5dce 100644 GIT binary patch delta 20 acmbOvGf9T~G%qg~0}y=O=)RGgoeuyvSp^jU delta 20 acmbOvGf9T~G%qg~0}%Y5;I@&Qoeuyu)CBzi diff --git a/custom_components/saas/__pycache__/sensor.cpython-312.pyc b/custom_components/saas/__pycache__/sensor.cpython-312.pyc index a3282328584a309d3e67ddec668a8b79a6f7d2b8..32121c1c4d6ce9f7e00f2366e8a1cb3e3fe97dfd 100644 GIT binary patch delta 22 ccmZ2+g>l6dM()$Ryj%=G@NJ{}MsC?G09mI8CIA2c delta 22 ccmZ2+g>l6dM()$Ryj%=GpeOILky|zk08q3A$p8QV diff --git a/custom_components/saas/__pycache__/services.cpython-312.pyc b/custom_components/saas/__pycache__/services.cpython-312.pyc index 7d065c2f3226ce2c4c0d8151c2db9ff991e5839d..5d171c00bfe89e44db86b394b557b48e4de0a6c3 100644 GIT binary patch delta 20 acmeyN@k4|AG%qg~0}y=M=)RFVR|Eh_1_ovT delta 20 acmeyN@k4|AG%qg~0}!0q=C+YLR|Eh@`367$ diff --git a/custom_components/saas/config_flow.py b/custom_components/saas/config_flow.py index 2d6d204..9bd25fe 100644 --- a/custom_components/saas/config_flow.py +++ b/custom_components/saas/config_flow.py @@ -68,49 +68,62 @@ class OptionsFlowHandler(config_entries.OptionsFlow): """Manage the options.""" _logger.debug("Entering async_step_init with user_input: %s", user_input) + errors = {} # Define errors here + try: # Fetch the initial configuration data current_data = self.hass.data[DOMAIN].get(self.config_entry.entry_id, self.config_entry.options) _logger.debug("Current data fetched: %s", current_data) + # Get the list of notify targets + notify_services = self.hass.services.async_services().get('notify', {}) + notify_targets = {target.replace('mobile_app_', '').title(): target for target in notify_services.keys() if target.startswith('mobile_app_')} + if user_input is not None: + # Validate the user input here + # If the input is valid, create an entry + # If the input is not valid, add an error message to the 'errors' dictionary + # For example: + if not user_input[CONF_NAME]: + errors[CONF_NAME] = "required" + if errors: + return self.async_show_form(step_id="init", data_schema=self.get_data_schema(current_data), errors=errors) # Pass errors to async_show_form + # Map the selected option back to the actual notify target name user_input[CONF_NOTIFY_TARGET] = notify_targets[user_input[CONF_NOTIFY_TARGET]] # Merge current_data with user_input updated_data = {**current_data, **user_input} _logger.debug("User input is not None, updated data: %s", updated_data) - + _logger.debug("Updating entry with updated data: %s", updated_data) - + if updated_data is not None: self.hass.data[DOMAIN][self.config_entry.entry_id] = updated_data # Save updated data - + # Update the entry data self.hass.config_entries.async_update_entry(self.config_entry, data=updated_data) - + # Send a signal to reload the integration async_dispatcher_send(self.hass, f"{DOMAIN}_reload_{self.config_entry.entry_id}") - + return self.async_create_entry(title="", data=updated_data) _logger.debug("User input is None, showing form with current_data: %s", current_data) - return self.async_show_form(step_id="init", data_schema=self.get_data_schema(current_data)) + return self.async_show_form(step_id="init", data_schema=self.get_data_schema(current_data), errors=errors) # Pass errors to async_show_form except Exception as e: _logger.error("Error in async_step_init: %s", str(e)) return self.async_abort(reason=str(e)) - def get_data_schema(self, current_data): - # Get the list of notify targets notify_services = self.hass.services.async_services().get('notify', {}) - notify_targets = {target.replace('mobile_app_', '').replace('_', ' ').title(): target for target in notify_services.keys() if target.startswith('mobile_app_')} - - # Extract the part after 'mobile_app_' and remove underscore + notify_targets = {target.replace('mobile_app_', '').title(): target for target in notify_services.keys() if target.startswith('mobile_app_')} + + # Extract the part after 'mobile_app_' and capitalize notify_target = current_data.get(CONF_NOTIFY_TARGET, "") - notify_target = notify_target.replace('mobile_app_', '').replace('_', ' ').title() if notify_target.startswith('mobile_app_') else notify_target + notify_target = notify_target.replace('mobile_app_', '').title() if notify_target.startswith('mobile_app_') else notify_target return Schema( {