Commit 389fff7
feat(tariffzones): add range syntax support for zone hours
_parse_hours now accepts inclusive range tokens (e.g. '0-5') in
addition to single values, enabling compact config like:
zone_1_hours: 7-22
zone_2_hours: 0-6,23
zone_3_hours: 17-20
Ranges are expanded inclusively (7-22 → [7,8,...,22]).
Single integers and range strings may be freely mixed.
List/tuple elements that are Python ints are handled directly
(no string conversion) to avoid treating negative integers as ranges.
Validation unchanged: inverted ranges (5-3) and out-of-bounds
values raise ValueError.
Updated config dummy example to use range notation.
Added 7 new parse_hours tests covering ranges.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent b03165d commit 389fff7
3 files changed
Lines changed: 96 additions & 19 deletions
File tree
- config
- src/batcontrol/dynamictariff
- tests/batcontrol/dynamictariff
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
168 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
169 | 199 | | |
170 | | - | |
| 200 | + | |
| 201 | + | |
171 | 202 | | |
172 | | - | |
| 203 | + | |
| 204 | + | |
173 | 205 | | |
174 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
175 | 210 | | |
176 | 211 | | |
177 | 212 | | |
178 | 213 | | |
179 | 214 | | |
180 | 215 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 216 | + | |
186 | 217 | | |
187 | 218 | | |
188 | 219 | | |
189 | 220 | | |
190 | 221 | | |
191 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
192 | 231 | | |
193 | 232 | | |
194 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
48 | 79 | | |
49 | 80 | | |
50 | 81 | | |
51 | 82 | | |
52 | 83 | | |
53 | 84 | | |
54 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
55 | 91 | | |
56 | 92 | | |
57 | 93 | | |
| |||
211 | 247 | | |
212 | 248 | | |
213 | 249 | | |
214 | | - | |
| 250 | + | |
215 | 251 | | |
216 | | - | |
| 252 | + | |
217 | 253 | | |
218 | 254 | | |
219 | 255 | | |
| |||
227 | 263 | | |
228 | 264 | | |
229 | 265 | | |
230 | | - | |
| 266 | + | |
231 | 267 | | |
232 | | - | |
| 268 | + | |
233 | 269 | | |
234 | 270 | | |
235 | 271 | | |
236 | 272 | | |
237 | 273 | | |
| 274 | + | |
| 275 | + | |
238 | 276 | | |
239 | 277 | | |
240 | 278 | | |
| |||
0 commit comments