Skip to content

Commit

Permalink
fix: go back to using options flow instead of reconfigure
Browse files Browse the repository at this point in the history
  • Loading branch information
mukaschultze committed Feb 5, 2025
1 parent 8ef745b commit cf40790
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/must_inverter/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,26 @@ async def next_step(user_input):

CONFIG_FLOW: Mapping[str, SchemaFlowStep] = {
"user": SchemaFlowFormStep(next_step="common"),
"reconfigure": SchemaFlowFormStep(next_step="common"),
# Reconfigure is not yet supported by SchemaConfigFlowHandler as it creates a new entry instead of updating the existing one
# "reconfigure": SchemaFlowFormStep(next_step="common"),
"common": SchemaFlowFormStep(schema=COMMON_SCHEMA, next_step=next_step),
"serial": SchemaFlowFormStep(schema=SERIAL_SCHEMA, next_step="modbus"),
"tcp": SchemaFlowFormStep(schema=TCP_SCHEMA, next_step="modbus"),
"udp": SchemaFlowFormStep(schema=UDP_SCHEMA, next_step="modbus"),
"modbus": SchemaFlowFormStep(schema=MODBUS_SCHEMA),
}

# OPTIONS_FLOW: Mapping[str, SchemaFlowStep] = {
# "init": SchemaFlowFormStep(next_step="common"),
# **CONFIG_FLOW,
# }
OPTIONS_FLOW: Mapping[str, SchemaFlowStep] = {
"init": SchemaFlowFormStep(next_step="common"),
**CONFIG_FLOW,
}


class MustInverterConfigFlow(SchemaConfigFlowHandler, domain=DOMAIN):
"""Handle a config flow for Must Inverter."""

config_flow = CONFIG_FLOW
# We'll use reconfigure feature for now
# options_flow = OPTIONS_FLOW
options_flow = OPTIONS_FLOW

def async_config_entry_title(self, options: Mapping[str, Any]) -> str:
"""Return config entry title."""
Expand Down
64 changes: 64 additions & 0 deletions custom_components/must_inverter/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,70 @@
}
}
},
"options": {
"step": {
"common": {
"title": "Common settings",
"description": "Configure your Must Inverter integration.",
"data": {
"name": "Name",
"model": "Model",
"scan_interval": "Scan Interval (seconds)",
"mode": "Connection type"
},
"data_description": {
"name": "Leave empty to use the inverter model as name.",
"model": "Leave in Auto Detect unless you're not seeing data that should be available for your device.",
"scan_interval": "The interval in seconds to poll the inverter for data.",
"mode": "The connection type to use to communicate with the inverter, usually via the included USB cable or via TCP/UDP for wireless connections."
}
},
"serial": {
"title": "USB or serial",
"description": "Configure the serial parameters for your inverter. The default values should work for most models.",
"data": {
"device": "USB or Serial device path",
"baudrate": "Baud rate",
"parity": "Parity (‘E’ven, ‘O’dd or ‘N’one)",
"stopbits": "Stop bits (1, 1.5, 2)",
"bytesize": "Byte size (7, 8)"
},
"data_description": {
"device": "The path to the USB or Serial device to use for the connection, usually /dev/ttyUSB0 or /dev/ttyS0."
}
},
"tcp": {
"title": "TCP",
"data": {
"host": "Host",
"port": "Port"
}
},
"udp": {
"title": "UDP",
"data": {
"host": "Host",
"port": "Port"
}
},
"modbus": {
"title": "PyModbus advanced settings",
"description": "Leave this section unchanged unless you are seeing connection issues or need to adjust the modbus connection settings.",
"data": {
"timeout": "Timeout (seconds)",
"retries": "Retries",
"reconnect_delay": "Reconnect Delay (seconds)",
"reconnect_delay_max": "Max Reconnect Delay (seconds)"
},
"data_description": {
"timeout": "Timeout for connecting and receiving data.",
"retries": "Max number of retries per request.",
"reconnect_delay": "Minimum delay before reconnecting. Set to 0 to disable reconnecting.",
"reconnect_delay_max": "Maximum delay before reconnecting. Pymodbus doubles the delay after each unsuccessful connection attempt."
}
}
}
},
"selector": {
"model": {
"options": {
Expand Down

0 comments on commit cf40790

Please sign in to comment.