Skip to content

Commit

Permalink
Fix config_flow error
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamish Findlay committed Dec 10, 2023
1 parent 6d47cc1 commit a652205
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions custom_components/battery_sim/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def async_step_user(self, user_input):
await self.async_set_unique_id(self._data[CONF_NAME])
self._abort_if_unique_id_configured()
self._data[CONF_INPUT_LIST] = []
return await self.async_meter_menu()
return await self.async_step_meter_menu()

battery_options_names = list(BATTERY_OPTIONS)
return self.async_show_form(
Expand All @@ -78,7 +78,7 @@ async def async_step_custom(self, user_input=None):
self._data[CONF_NAME] = f"{DOMAIN}: {self._data[CONF_UNIQUE_NAME]}"
await self.async_set_unique_id(self._data[CONF_NAME])
self._abort_if_unique_id_configured()
return await self.async_meter_menu()
return await self.async_step_meter_menu()

return self.async_show_form(
step_id="custom",
Expand All @@ -99,7 +99,7 @@ async def async_step_custom(self, user_input=None):
),
)

async def async_meter_menu(self, user_input=None):
async def async_step_meter_menu(self, user_input=None):
menu_options = ["add_import_meter", "add_export_meter"]
import_meter: bool = False
export_meter: bool = False
Expand All @@ -119,7 +119,7 @@ async def async_step_add_import_meter(self, user_input=None):
SENSOR_TYPE: IMPORT,
SIMULATED_SENSOR: f"simulated_{user_input[SENSOR_ID]}",
}
return await self.async_tariff_menu()
return await self.async_step_tariff_menu()

return self.async_show_form(
step_id="add_import_meter",
Expand All @@ -139,7 +139,7 @@ async def async_step_add_export_meter(self, user_input=None):
SENSOR_TYPE: EXPORT,
SIMULATED_SENSOR: f"simulated_{user_input[SENSOR_ID]}",
}
return await self.async_tariff_menu()
return await self.async_step_tariff_menu()

return self.async_show_form(
step_id="add_export_meter",
Expand All @@ -152,7 +152,7 @@ async def async_step_add_export_meter(self, user_input=None):
),
)

async def async_tariff_menu(self, user_input=None):
async def async_step_tariff_menu(self, user_input=None):
return self.async_show_menu(
step_id="tariff_menu",
menu_options=["no_tariff_info", "fixed_tariff", "tariff_sensor"],
Expand All @@ -161,14 +161,14 @@ async def async_tariff_menu(self, user_input=None):
async def async_step_no_tariff_info(self, user_input=None):
self.current_input_entry[TARIFF_TYPE] = NO_TARIFF_INFO
self._data[CONF_INPUT_LIST].append(self.current_input_entry)
return await self.async_meter_menu()
return await self.async_step_meter_menu()

async def async_step_fixed_tariff(self, user_input=None):
if user_input is not None:
self.current_input_entry[TARIFF_TYPE] = FIXED_TARIFF
self.current_input_entry[FIXED_TARIFF] = user_input[FIXED_TARIFF]
self._data[CONF_INPUT_LIST].append(self.current_input_entry)
return await self.async_meter_menu()
return await self.async_step_meter_menu()

return self.async_show_form(
step_id="fixed_tariff",
Expand All @@ -186,7 +186,7 @@ async def async_step_tariff_sensor(self, user_input=None):
self.current_input_entry[TARIFF_TYPE] = TARIFF_SENSOR
self.current_input_entry[TARIFF_SENSOR] = user_input[TARIFF_SENSOR]
self._data[CONF_INPUT_LIST].append(self.current_input_entry)
return await self.async_meter_menu()
return await self.async_step_meter_menu()

return self.async_show_form(
step_id="tariff_sensor",
Expand Down Expand Up @@ -298,7 +298,7 @@ async def async_step_edit_input_tariff(self, user_input=None):
for input in self.updated_entry[CONF_INPUT_LIST]:
if input[SENSOR_ID] == user_input[CONF_INPUT_LIST]:
self.current_input_entry = input
return await self.async_tariff_menu()
return await self.async_step_tariff_menu()

list_of_inputs = []
for input in self.updated_entry[CONF_INPUT_LIST]:
Expand All @@ -319,7 +319,7 @@ async def async_step_add_import_meter(self, user_input=None):
SIMULATED_SENSOR: f"simulated_{user_input[SENSOR_ID]}",
}
self.updated_entry[CONF_INPUT_LIST].append(self.current_input_entry)
return await self.async_tariff_menu()
return await self.async_step_tariff_menu()

return self.async_show_form(
step_id="add_import_meter",
Expand All @@ -340,7 +340,7 @@ async def async_step_add_export_meter(self, user_input=None):
SIMULATED_SENSOR: f"simulated_{user_input[SENSOR_ID]}",
}
self.updated_entry[CONF_INPUT_LIST].append(self.current_input_entry)
return await self.async_tariff_menu()
return await self.async_step_tariff_menu()

return self.async_show_form(
step_id="add_export_meter",
Expand All @@ -353,9 +353,9 @@ async def async_step_add_export_meter(self, user_input=None):
),
)

async def async_tariff_menu(self, user_input=None):
async def async_step_tariff_menu(self, user_input=None):
return self.async_show_menu(
step_id="tariffMenu",
step_id="tariff_menu",
menu_options=["no_tariff_info", "fixed_tariff", "tariff_sensor"],
)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/battery_sim/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
},
"description": "At least one import and one export meter are required. Meters monitoring solar generation directly shouldn't be used."
},
"tariffMenu": {
"tariff_menu": {
"title": "Select Tariff Type",
"menu_options": {
"no_tariff_info": "No tariff for this meter",
Expand Down

0 comments on commit a652205

Please sign in to comment.