Skip to content

introduce weekdays to fixed_hours tariff#3252

Open
tpd-opitz wants to merge 2 commits intoopenWB:masterfrom
tpd-opitz:fixed-hours-per-weekday
Open

introduce weekdays to fixed_hours tariff#3252
tpd-opitz wants to merge 2 commits intoopenWB:masterfrom
tpd-opitz:fixed-hours-per-weekday

Conversation

@tpd-opitz
Copy link
Copy Markdown
Contributor

@tpd-opitz tpd-opitz commented Mar 29, 2026

https://forum.openwb.de/viewtopic.php?t=11934

  • extend config fail save
  • update overlap detection
  • update current price fetch
TODO: update UI
  • add list of weekdays a time frame should be active
  • values in this list range from 0 (monday) to 6 (sunday) eg:
                [
                    {
                        "name": "tariff1",
                        "price": 100,
                        "active_times": {
                            "dates": [("01-01", "31-12")],
                            "times": [("08:00", "12:00")],
                            "weekdays": [0, 1, 2, 3, 4],  # active on weekdays
                        },
                    },
                    {
                        "name": "tariff1",
                        "price": 200,
                        "active_times": {
                            "dates": [("01-01", "31-12")],
                            "times": [("08:00", "12:00")],
                            "weekdays": [5, 6],  # active on weekends
                        },
                    },
                ]

@tpd-opitz tpd-opitz force-pushed the fixed-hours-per-weekday branch from bd6cec9 to 0e4119e Compare March 29, 2026 11:19
@tpd-opitz tpd-opitz changed the title introduce weekdas to fixed_hours tariff introduce weekdays to fixed_hours tariff Mar 29, 2026
@tpd-opitz tpd-opitz force-pushed the fixed-hours-per-weekday branch from 0e4119e to c481cb0 Compare March 29, 2026 11:23
Comment on lines +12 to +17

# Process tariffs to ensure weekdays list is present
for tariff in self.tariffs:
if "active_times" in tariff and "weekdays" not in tariff["active_times"]:
tariff["active_times"]["weekdays"] = list(range(7)) # Default to all weekdays

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Process tariffs to ensure weekdays list is present
for tariff in self.tariffs:
if "active_times" in tariff and "weekdays" not in tariff["active_times"]:
tariff["active_times"]["weekdays"] = list(range(7)) # Default to all weekdays

Bitte über die update_config abbilden, damit die Einstellungen immer konsistent sind. Du kannst Dich zB an upgrade_datastore_104 orientieren.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich inkrementiere also DATASTORE_VERSION und lege ne neue Funktion an.

Muss noch irgendwo vermerkt werden, dass die neue datastore version aufgerufen werden muss?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nein, dafür ist DATASTORE_VERSION . Daran wird geprüft, ob noch eine upgrade datastore-Version aufgerufen werden muss.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte den obsoleten Code noch entfernen.

Comment on lines +79 to +80
# If no weekdays specified, assume all days are active
weekdays = tariff["active_times"]["weekdays"] or range(7)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# If no weekdays specified, assume all days are active
weekdays = tariff["active_times"]["weekdays"] or range(7)
weekdays = tariff["active_times"]["weekdays"]

Wird über update_config abgebildet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte den obsoleten Code noch entfernen.

@tpd-opitz tpd-opitz force-pushed the fixed-hours-per-weekday branch from c481cb0 to 9bf5891 Compare April 1, 2026 18:20
@tpd-opitz tpd-opitz requested a review from LKuemmel April 1, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants