@@ -27,7 +27,7 @@ def is_matching(self, other_flow):
27
27
return False # Return False if you don't have specific matching logic
28
28
29
29
async def async_step_user (self , user_input = None ) -> FlowResult :
30
- """Handle the initial step."""
30
+ """Handle the initial step of the config flow ."""
31
31
errors = {}
32
32
33
33
if user_input is not None :
@@ -100,55 +100,76 @@ async def async_step_init(self, user_input=None) -> FlowResult:
100
100
if user_input is not None :
101
101
_LOGGER .debug ("User updated options: %s" , user_input )
102
102
# Update the entry with new options
103
- self .hass .config_entries .async_update_entry (self .config_entry , data = user_input )
103
+ self .hass .config_entries .async_update_entry (self .config_entry , options = user_input )
104
104
return self .async_create_entry (title = "" , data = {})
105
105
106
106
data_schema = vol .Schema (
107
107
{
108
108
vol .Required (
109
109
CONF_BASE_URL ,
110
- default = self .config_entry .data .get (CONF_BASE_URL ),
110
+ default = self .config_entry .options . get ( CONF_BASE_URL , self . config_entry . data .get (CONF_BASE_URL ) ),
111
111
): str ,
112
112
vol .Required (
113
113
CONF_USERNAME ,
114
- default = self .config_entry .data .get (CONF_USERNAME ),
114
+ default = self .config_entry .options . get ( CONF_USERNAME , self . config_entry . data .get (CONF_USERNAME ) ),
115
115
): str ,
116
116
vol .Required (
117
117
CONF_PASSWORD ,
118
- default = self .config_entry .data .get (CONF_PASSWORD ),
118
+ default = self .config_entry .options . get ( CONF_PASSWORD , self . config_entry . data .get (CONF_PASSWORD ) ),
119
119
): str ,
120
120
vol .Required (
121
121
CONF_ACCOUNT_NUMBER ,
122
- default = self .config_entry .data .get (CONF_ACCOUNT_NUMBER ),
122
+ default = self .config_entry .options .get (
123
+ CONF_ACCOUNT_NUMBER ,
124
+ self .config_entry .data .get (CONF_ACCOUNT_NUMBER ),
125
+ ),
123
126
): str ,
124
127
vol .Required (
125
128
CONF_METER_NUMBER ,
126
- default = self .config_entry .data .get (CONF_METER_NUMBER ),
129
+ default = self .config_entry .options .get (
130
+ CONF_METER_NUMBER ,
131
+ self .config_entry .data .get (CONF_METER_NUMBER ),
132
+ ),
127
133
): str ,
128
- vol .Required ("unit_type" , default = self .config_entry .data .get ("unit_type" , "CF" )): vol .In (["CF" , "G" ]),
134
+ vol .Required (
135
+ "unit_type" ,
136
+ default = self .config_entry .options .get ("unit_type" , self .config_entry .data .get ("unit_type" , "CF" )),
137
+ ): vol .In (["CF" , "G" ]),
129
138
vol .Optional (
130
139
"tier1_gallons" ,
131
- default = self .config_entry .data .get ("tier1_gallons" , None ),
140
+ default = self .config_entry .options .get (
141
+ "tier1_gallons" , self .config_entry .data .get ("tier1_gallons" , None )
142
+ ),
132
143
): vol .Any (None , vol .Coerce (float ), vol .Range (min = 0 )),
133
144
vol .Required (
134
145
"tier1_price" ,
135
- default = self .config_entry .data .get ("tier1_price" , 0.0128 ),
146
+ default = self .config_entry .options .get (
147
+ "tier1_price" , self .config_entry .data .get ("tier1_price" , 0.0128 )
148
+ ),
136
149
): cv .positive_float ,
137
150
vol .Optional (
138
151
"tier2_gallons" ,
139
- default = self .config_entry .data .get ("tier2_gallons" , None ),
152
+ default = self .config_entry .options .get (
153
+ "tier2_gallons" , self .config_entry .data .get ("tier2_gallons" , None )
154
+ ),
140
155
): vol .Any (None , vol .Coerce (float ), vol .Range (min = 0 )),
141
156
vol .Optional (
142
157
"tier2_price" ,
143
- default = self .config_entry .data .get ("tier2_price" , None ),
158
+ default = self .config_entry .options .get (
159
+ "tier2_price" , self .config_entry .data .get ("tier2_price" , None )
160
+ ),
144
161
): vol .Any (None , vol .Coerce (float ), vol .Range (min = 0 )),
145
162
vol .Optional (
146
163
"tier3_price" ,
147
- default = self .config_entry .data .get ("tier3_price" , None ),
164
+ default = self .config_entry .options .get (
165
+ "tier3_price" , self .config_entry .data .get ("tier3_price" , None )
166
+ ),
148
167
): vol .Any (None , vol .Coerce (float ), vol .Range (min = 0 )),
149
168
vol .Required (
150
169
"service_fee" ,
151
- default = self .config_entry .data .get ("service_fee" , 15.00 ),
170
+ default = self .config_entry .options .get (
171
+ "service_fee" , self .config_entry .data .get ("service_fee" , 15.00 )
172
+ ),
152
173
): cv .positive_float ,
153
174
}
154
175
)
0 commit comments