Skip to content

Commit

Permalink
feat: Add persistent inverter_definitions/custom
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Jul 25, 2024
1 parent 38c2e72 commit ab71e3e
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 358 deletions.
2 changes: 2 additions & 0 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ async def step_user_data_process(discovery):

async def step_user_data_schema(hass: HomeAssistant, data: dict[str, Any] = { CONF_NAME: DEFAULT_NAME, CONF_DISCOVERY: DEFAULT_DISCOVERY, CONF_INVERTER_PORT: DEFAULT_PORT_INVERTER, CONF_INVERTER_MB_SLAVE_ID: DEFAULT_INVERTER_MB_SLAVE_ID, CONF_LOOKUP_FILE: DEFAULT_LOOKUP_FILE, CONF_BATTERY_NOMINAL_VOLTAGE: DEFAULT_BATTERY_NOMINAL_VOLTAGE, CONF_BATTERY_LIFE_CYCLE_RATING: DEFAULT_BATTERY_LIFE_CYCLE_RATING }, wname: bool = True) -> vol.Schema:
lookup_files = sorted([f for f in await async_execute(lambda: os.listdir(hass.config.path(LOOKUP_DIRECTORY_PATH))) if os.path.isfile(LOOKUP_DIRECTORY_PATH + f)])
if os.path.exists(hass.config.path(LOOKUP_CUSTOM_DIRECTORY_PATH)):
lookup_files = lookup_files + sorted([f"custom/{f}" for f in await async_execute(lambda: os.listdir(hass.config.path(LOOKUP_CUSTOM_DIRECTORY_PATH))) if os.path.isfile(LOOKUP_CUSTOM_DIRECTORY_PATH + f)])
_LOGGER.debug(f"step_user_data_schema: data: {data}, {LOOKUP_DIRECTORY_PATH}: {lookup_files}")
#STEP_USER_DATA_SCHEMA = vol.Schema({ vol.Required(CONF_NAME, default = data.get(CONF_NAME)): str }, extra = vol.PREVENT_EXTRA) if wname else vol.Schema({}, extra = vol.PREVENT_EXTRA)
#STEP_USER_DATA_SCHEMA = STEP_USER_DATA_SCHEMA.extend(
Expand Down
1 change: 1 addition & 0 deletions custom_components/solarman/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

LOOKUP_DIRECTORY = "inverter_definitions"
LOOKUP_DIRECTORY_PATH = f"{COMPONENTS_DIRECTORY}/{DOMAIN}/{LOOKUP_DIRECTORY}/"
LOOKUP_CUSTOM_DIRECTORY_PATH = f"{COMPONENTS_DIRECTORY}/{DOMAIN}/{LOOKUP_DIRECTORY}/custom/"

CONF_DISCOVERY = "inverter_discovery"
CONF_INVERTER_HOST = "inverter_host"
Expand Down
Loading

0 comments on commit ab71e3e

Please sign in to comment.