diff --git a/custom_components/solarman/config_flow.py b/custom_components/solarman/config_flow.py index 8d17625..67ba283 100644 --- a/custom_components/solarman/config_flow.py +++ b/custom_components/solarman/config_flow.py @@ -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} diff --git a/custom_components/solarman/const.py b/custom_components/solarman/const.py index 577089c..ea5dc28 100644 --- a/custom_components/solarman/const.py +++ b/custom_components/solarman/const.py @@ -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"