Skip to content

Commit

Permalink
refactor: Add SUGGESTED_VALUE constant
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 9, 2024
1 parent 72b481b commit c0717b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
}

OPTS_SCHEMA = {
vol.Optional(CONF_HOST, default = DEFAULT_[CONF_HOST], description = {"suggested_value": DEFAULT_[CONF_HOST]}): str,
vol.Optional(CONF_PORT, default = DEFAULT_[CONF_PORT], description = {"suggested_value": DEFAULT_[CONF_PORT]}): cv.port,
vol.Optional(CONF_LOOKUP_FILE, default = DEFAULT_[CONF_LOOKUP_FILE], description = {"suggested_value": DEFAULT_[CONF_LOOKUP_FILE]}): str,
vol.Optional(CONF_HOST, default = DEFAULT_[CONF_HOST], description = {SUGGESTED_VALUE: DEFAULT_[CONF_HOST]}): str,
vol.Optional(CONF_PORT, default = DEFAULT_[CONF_PORT], description = {SUGGESTED_VALUE: DEFAULT_[CONF_PORT]}): cv.port,
vol.Optional(CONF_LOOKUP_FILE, default = DEFAULT_[CONF_LOOKUP_FILE], description = {SUGGESTED_VALUE: DEFAULT_[CONF_LOOKUP_FILE]}): str,
vol.Required(CONF_ADDITIONAL_OPTIONS): section(
vol.Schema(
{
vol.Optional(CONF_MOD, default = DEFAULT_[CONF_MOD], description = {"suggested_value": DEFAULT_[CONF_MOD]}): bool,
vol.Optional(CONF_MPPT, default = DEFAULT_[CONF_MPPT], description = {"suggested_value": DEFAULT_[CONF_MPPT]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 12)),
vol.Optional(CONF_PHASE, default = DEFAULT_[CONF_PHASE], description = {"suggested_value": DEFAULT_[CONF_PHASE]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 3)),
vol.Optional(CONF_BATTERY_NOMINAL_VOLTAGE, default = DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE], description = {"suggested_value": DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE]}): cv.positive_int,
vol.Optional(CONF_BATTERY_LIFE_CYCLE_RATING, default = DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING], description = {"suggested_value": DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING]}): cv.positive_int,
vol.Optional(CONF_MB_SLAVE_ID, default = DEFAULT_[CONF_MB_SLAVE_ID], description = {"suggested_value": DEFAULT_[CONF_MB_SLAVE_ID]}): cv.positive_int
vol.Optional(CONF_MOD, default = DEFAULT_[CONF_MOD], description = {SUGGESTED_VALUE: DEFAULT_[CONF_MOD]}): bool,
vol.Optional(CONF_MPPT, default = DEFAULT_[CONF_MPPT], description = {SUGGESTED_VALUE: DEFAULT_[CONF_MPPT]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 12)),
vol.Optional(CONF_PHASE, default = DEFAULT_[CONF_PHASE], description = {SUGGESTED_VALUE: DEFAULT_[CONF_PHASE]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 3)),
vol.Optional(CONF_BATTERY_NOMINAL_VOLTAGE, default = DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE], description = {SUGGESTED_VALUE: DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE]}): cv.positive_int,
vol.Optional(CONF_BATTERY_LIFE_CYCLE_RATING, default = DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING], description = {SUGGESTED_VALUE: DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING]}): cv.positive_int,
vol.Optional(CONF_MB_SLAVE_ID, default = DEFAULT_[CONF_MB_SLAVE_ID], description = {SUGGESTED_VALUE: DEFAULT_[CONF_MB_SLAVE_ID]}): cv.positive_int
}
),
{"collapsed": True}
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 @@ -35,6 +35,7 @@

OLD_ = { CONF_SERIAL: "inverter_serial", CONF_HOST: "inverter_host", CONF_PORT: "inverter_port" }

SUGGESTED_VALUE = "suggested_value"
UPDATE_INTERVAL = "update_interval"
IS_SINGLE_CODE = "is_single_code"
REGISTERS_CODE = "registers_code"
Expand Down

0 comments on commit c0717b2

Please sign in to comment.