Heatpump Steering with Integration into Thermia API #100
Heatpump Steering with Integration into Thermia API #100hashtagKnorke wants to merge 10 commits intomuexxl:mainfrom
Conversation
|
Wow. it seems this error was already addressed, wasn’t it? @muexxl I think we need to discuss this integration. |
bd46757 contains the fix |
YES. Time for a dev call |
adding the basic docker file and build script add initial integration for Thermia API submodule fix inconsistencies fix NPE fix comparison add debug logging str activate MQTT for reatpump iterate properties instead of attrs handle property type and convert to mqtt supported type if necessary handle network errors fix args fix initializer dummy class for heatpump interface in case no heatpump intergation wanted add high price strategy handling rework baseclass enable Thermia or default dummy heatpump impl add heatpump parameter handling based on net consumption and pricing update submodule to latest commit for thermia_online_api fork update mode names, identifiers and log timmestamp formatting add dependabot config file new strategy: assign most energy conserving modes to most expensive hours adjust the hour offsets for hour end refactor thermia heatpump code to thermia class, add SilentHeatpump class and enhance Heatpump factory logic update subproject commit reference for thermia_online_api add numpy import to baseclass for heatpump implementation add numpy import to Thermia module enhance ThermiaHeatpump logic with additional heat modes (hot water boost and increased temperature heat ) and improved price handling commented-out code for adding thermia_online_api to Python path##hackOFF import datetime fix: correct range_duration calculation in ThermiaHeatpump class refactor: update ThermiaHeatpump initialization to accept config dict make strategy parameters instance vars instead of local config enhance: add configuration parameters for various heat modes in ThermiaHeatpump and fetch from config refactor: replace local variables with instance variables in ThermiaHeatpump mode calculations add timezone of batcontrol to init params enhance: add batcontrol timezone parameter to ThermiaHeatpump initialization - refactor: rename method _plan_for_high_price_window to ensure_strategy_for_time_window for clarity - load strategy config from config file refactor: rename HighPriceHandlingStrategy to ThermiaHighPriceHandling and introduce ThermiaStrategySlot for improved strategy management chore: update subproject commit reference in thermia_online_api refactor: improve logging and update MQTT publishing for high price strategies refactor: update min energy surplus for increased heat and enhance MQTT logging for configuration and strategy values refactor: streamline MQTT publishing for configuration and strategy values, and enhance error logging refactor: fix timestamp formatting in MQTT publishing for high price handlers and strategies refactor: rename mqtt_api to mqtt_client for consistency and clarity in ThermiaHeatpump class refactor: remove unnecessary self reference in install_schedule_in_heatpump method and add type hints for parameters refactor: add comprehensive heat pump configuration options to batcontrol_config_dummy.yaml refactor: simplify debug logging for MQTT configuration publishing in ThermiaHeatpump class refactor: ensure proper cleanup of heatpump reference in Batcontrol destructor refactor: implement destructor to clean up high price handlers and delete schedules in ThermiaHeatpump class refactor: remove commented-out api_set_max_grid_charge_rate method in ThermiaHeatpump class refactor: update type hints and improve constructor documentation in ThermiaHeatpump class refactor: enhance logging for high price strategy planning and streamline handler creation in ThermiaHeatpump class refactor: update cleanup methods to use aware datetime and improve logging in ThermiaHeatpump class refactor: rename timezone variable to heatpump_timezone and update datetime usage for consistency in ThermiaHeatpump class refactor: ensure datetime objects are timezone aware in ThermiaHeatpump cleanup methods update .gitignore to exclude all test files matching test*.py pattern fix: adjust timezone handling for high price strategies and handlers fix: update timezone handling in ThermiaHeatpump class fix: enhance logging and cleanup for high price strategies and handlers Implement retry logic for MQTT connection attempts with logging Add optional retry configuration for MQTT connection in batcontrol_config_dummy.yaml rebase to integrate reced improvements on main branch: MQTT retry configuration fix: update datetime type annotations and improve timestamp comparisons in Thermia classes feat: extend ThermiaStrategySlot to include price and consumption attributes, and publish additional strategy details to MQTT fix: add timestamp publishing for strategy start time and improve handler attribute check fix: update datetime handling to use batcontrol timezone for accurate time calculations fix: ensure correct timezone handling for already planned until in ThermiaHeatpump initialization chore: update subproject reference in thermia_online_api - adapt to chaged Class name: Schedule-->CalendarSchedule - reformatting with linter style: improve code formatting and consistency across heatpump classes chore: update subproject reference in thermia_online_api feat: add method to delete all MQTT topics with a specified prefix refactor: - streamline MQTT topic handling and improve code clarity - clean replanning when new data becomes available - deleting mqtt subtree about handlers and strategies whenever publishing new style: improve code formatting and consistency in Thermia.py feat: refactor MQTT publishing logic into a dedicated method feat: enhance MQTT publishing with additional start and end time topics refactor and docs style: clean up code formatting and remove unnecessary line breaks in Thermia.py feat: add debug logging for topic deletion process in MQTT_API feat: add debug logging in ThermiaHeatpump destructor for high price handler cleanup fix: fully qualified topic needed in delete all topics feat: add docstring to delete_all_topics method and improve topic prefix handling fix: ensure prefix is trimmed and improve topic deletion logging in MQTT_API feat: add debug logging for high price handler and strategy cleanup in MQTT publishing feat: enhance build_docker.sh to include current commit SHA and versioning -- consuned by DOCKERFILE feat: add ThermiaOnlineAPI module and heapump codebase to Docker image feat: implement shutdown method for heatpump and integrate it into batcontrol cleanup revert mistake: set delay evaluation by seconds in ForecastSolar initialization feat: update build_docker.sh to include build arguments for GIT_SHA and VERSION refactor: update MQTT API import and type hints in Thermia and baseclass modules to reflect name refactiorings that happened upstream refactor: reduce sleep duration in MQTT message processing from 20 seconds to 3 seconds refactor: enhance HeatpumpBaseclass documentation and format to address pylint suggestions refactor: - restructure heatpump module and update class references for consistency - follow pylint suggestions refactor: update import statements in DummyHeatpump and SilentHeatpump to use relative imports refactor: rename SilentHeatpump module and update class implementation with improved documentation refactor: rename DummyHeatpump module to dummy_heatpump and enhance class documentation refactor: update import statement for ThermiaHeatpump to use lowercase module name refactor: formatting, docstrings and import statements refactor: add NoHeatPumpsFoundException for better error handling refactor: remove ensure_strategy_for_time_window method from base and dummy heatpump classes, pushing it down into Thermia specific implementation refactor: linting suggestions applied refactor: remove unused import and improve NoHeatPumpsFoundException docstring formatting fix: using indexes in MQTT strategy publish to have a static set tof topics that are not extended over time refactor: replace mode with schedule functionId in MQTT publish for improved clarity fix: ensure functionId is converted to string for MQTT publish formatting feat: implement schedule validation and cleanup for ThermiaHeatpump fix: ensure timestamp comparisons for schedule deletion are accurate HACK: add dynamic path adjustment for ThermiaOnlineAPI module import HACK docs: enhance HOWITWORKS and README with Thermia heat pump integration details docs: update HOWITWORKS to clarify heat pump mode descriptions and energy-saving strategies fix: update _get_all_properties method to include method variable in loop
… for ASCII sorting properly
5327ec9 to
bbb9b89
Compare
|
rebased and squashed the commits of this PR to eliminate merge conflicts with main pylint checks applied on whole codebase instead of PR's actual changes creates quite a burden (fixing all linter complaints in the codebase) 🤷♂️ |
|
Yeah, sorry for the pylint stuff. I guess I’ll merge your other PR to reduce that burden. |
|
@hashtagKnorke @muexxl and I will manage to have a call next week. to give you short feedback: We are both struggling with the scope of the project. Initially, we are thinking about controlling the battery only. For BEV cars, we have evcc in place, which controls charging. It can also control other devices, but is not able to save plans like you did based of the work you’ve done. muexxl will discuss this, and what we need to do to have a more generic introduction for controlling consumers. |
…#102) * Refactor pylint workflow to analyze only changed Python files * Add step to fetch main branch for git diff comparison in pylint workflow * Enhance pylint workflow to dynamically determine and fetch the base branch (origin/main vs. upstream/main) for comparison * fix indentation error * Add check to prevent duplicate upstream remote addition in pylint workflow
…ypoint script add tzdata package
fixes: reduce periodic MQTT publish logs #25
fixes: reduce periodic handler cleanup logs #26
…ing +1h in multiple code locations redundantly addfs up to wrong durations), partially fixes 01.01.2025 ..... #27
…rrectly include single hour slots
|
@hashtagKnorke Love it! 👏 I'd also second a module structure for controlling consumers. There's also the built-in ones from Fronius (i.e. the 230V pins) for more "basic" consumers, which is not too big of a project to implement. Others can then follow as and when required or contributed too. Get the structure/framework in place and make it easy for people to contribute. |
|
Dear @hashtagKnorke, @johannesghd : ofc you are also more than welcome to join us :) The main issues I am seeing:
Looking forward to having a conversation with you .
|
|
Closing here, as we discussed about the plugin mechanism |
Heatpump integration
Thermia Heatpump Strategy
The Thermia heat pump integration in this software is designed to optimize the operation of your heat pump based on electricity prices, energy consumption, and energy production forecasts. The strategy aims to minimize energy costs by adjusting the heat pump's operating modes according to predefined rules and configurations.
Thermia Online API Extension
The Thermia Online API (https://github.com/klejejs/python-thermia-online-api) has been forked and extended (https://github.com/hashtagKnorke/thermia-online-api/tree/add_calendars) to leverage the Calendar function schedule API of Thermia Online API for setting up the behavior of the Thermia heat pump. This extension allows to control the heat pump based on predefined schedules and energy price forecasts.
Integration of the fork
The changes in the fork have been raised as a PR (klejejs/python-thermia-online-api#48) so that they might converge into the mainstream library. For the meantime, the fork has been integrated into the batcontrol repo as a a submodule, integrating the library as sourcecode during dockerfile build.
In case the directory is not in path a small hack in (https://github.com/hashtagKnorke/batcontrol/blob/be5f4eb2df73936234807a4ff355b7d1a9da882e/heatpump/thermia_heatpump.py#L36) tries to add the subdir to the python path so that the import succeeds.
Key Enhancements
Calendar Function Integration: The API now supports the Calendar function, enabling users to define and manage schedules for the heat pump's operation. This allows for automated adjustments to the heat pump's modes based on time and energy price forecasts.
Enhanced Scheduling: Users can create, update, and delete schedules for the heat pump. These schedules can specify different operating modes for different times of the day, optimizing energy usage and cost savings.
API Methods
The following methods have been added to the Thermia API to support the Calendar function:
These methods allow for full control over the scheduling of the heat pump's operation, enabling users to optimize energy usage and minimize costs effectively.
Benefits
To get started with the extended Thermia Online API, refer to the documentation and configure the necessary settings in the
config/batcontrol_config.yamlfile.Key Components
Strategy Overview
The strategy involves setting the heat pump to the most energy-saving mode during high price periods while considering the following modes:
Configuration Parameters
Operation
The software continuously monitors electricity prices, energy consumption, and production forecasts. Based on these inputs and the current state of charge (SOC) of the battery, it dynamically adjusts the heat pump's operating mode to optimize energy usage and minimize costs.
The strategy is recalculated every three minutes to ensure that the heat pump operates in the most cost-effective manner, taking into account the latest forecasts and current conditions.
To configure the Thermia heat pump integration, you will need to adapt the settings in
config/batcontrol_config.yaml.Example Log Output illustrating the behaviour