Skip to content

Heatpump Steering with Integration into Thermia API #100

Closed
hashtagKnorke wants to merge 10 commits intomuexxl:mainfrom
hashtagKnorke:ifeature/integrate_thermia-online-api
Closed

Heatpump Steering with Integration into Thermia API #100
hashtagKnorke wants to merge 10 commits intomuexxl:mainfrom
hashtagKnorke:ifeature/integrate_thermia-online-api

Conversation

@hashtagKnorke
Copy link
Contributor

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
  1. 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.

  2. 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:

  • get_schedules(installation_id: str): Retrieves the schedules for a given installation.
  • add_new_schedule(installation_id: str, data: dict): Adds a new schedule for a given installation.
  • delete_schedule(installation_id: str, schedule_id: int): Deletes a schedule for a given installation.

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

  • Cost Savings: By scheduling the heat pump to operate in energy-saving modes during high price periods, users can significantly reduce their energy costs.
  • Automation: The integration with the Calendar function allows for automated control of the heat pump, reducing the need for manual adjustments.
  • Flexibility: Users can define multiple schedules with different operating modes, providing flexibility to adapt to changing energy prices and consumption patterns.

To get started with the extended Thermia Online API, refer to the documentation and configure the necessary settings in the config/batcontrol_config.yaml file.

Key Components

  1. ThermiaHighPriceHandling: Manages settings to handle high price periods.
  2. ThermiaStrategySlot: Represents a strategy decision for a specific time slot.
  3. ThermiaHeatpump: The main class that manages and controls the Thermia heat pump.

Strategy Overview

The strategy involves setting the heat pump to the most energy-saving mode during high price periods while considering the following modes:

  • E: EVU Block: Activated when electricity prices are high. Maximum energy saving, deactivating heating and Hot water production.
  • B: Hot Water Block: Activated to block hot water production during high price periods.
  • R: Reduced Heat: Lowers the heating effect to save energy.
  • N: Normal mode: No adjustments to heatpump behaviour.
  • H: Increased Heat: Increases heating when energy is cheap or there is a PV surplus.
  • W: Hot Water Boost: Boosts hot water production when there is an energy surplus.

Configuration Parameters

  • min_price_for_evu_block: Minimum price to trigger EVU block mode.
  • max_evu_block_hours: Maximum hours per day for EVU block mode.
  • max_evu_block_duration: Maximum continuous duration for EVU block mode.
  • min_price_for_hot_water_block: Minimum price to trigger hot water block mode.
  • max_hot_water_block_hours: Maximum hours per day for hot water block mode.
  • max_hot_water_block_duration: Maximum continuous duration for hot water block mode.
  • min_price_for_reduced_heat: Minimum price to trigger reduced heat mode.
  • max_reduced_heat_hours: Maximum hours per day for reduced heat mode.
  • max_reduced_heat_duration: Maximum continuous duration for reduced heat mode.
  • reduced_heat_temperature: Temperature setting for reduced heat mode.
  • max_price_for_increased_heat: Maximum price to trigger increased heat mode.
  • min_energy_surplus_for_increased_heat: Minimum energy surplus to trigger increased heat mode.
  • max_increased_heat_hours: Maximum hours per day for increased heat mode.
  • max_increased_heat_duration: Maximum continuous duration for increased heat mode.
  • increased_heat_temperature: Temperature setting for increased heat mode.
  • max_increased_heat_outdoor_temperature: Maximum outdoor temperature for increased heat mode.
  • min_energy_surplus_for_hot_water_boost: Minimum energy surplus to trigger hot water boost mode.
  • max_hot_water_boost_hours: Maximum hours per day for hot water boost mode.

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

2024-12-29 16:14:17 DEBUG [Rule] Evaluating next 6 hours until 22:59
2024-12-29 16:14:17 DEBUG [Rule] Reserved Energy will be used in the next hours: [1]
2024-12-29 16:14:17 DEBUG [Rule] Reserved Energy: 1794.0 Wh. Usable in Battery: 0.0 Wh
2024-12-29 16:14:17 DEBUG [Rule] Discharge forbidden. Stored usable energy 0.0 Wh <= Reserved energy 1794.0 Wh
2024-12-29 16:14:17 DEBUG [Rule] Discharging is NOT allowed
2024-12-29 16:14:17 DEBUG [BatCTRL] Charging allowed: True
2024-12-29 16:14:17 DEBUG [Rule] Charging is allowed, because SOC is below 98%
2024-12-29 16:14:17 DEBUG [Rule] No additional energy required or possible price found.
2024-12-29 16:14:17 INFO [BatCTRL] Mode: Avoid Discharging
2024-12-29 16:14:17 DEBUG [ThermiaHeatpump] Planning until 2024-12-30 17:00:00+01:00
2024-12-29 16:14:17 DEBUG [ThermiaHeatpump] Replan from scratch: Deleted expired schedule CalendarSchedule(_CalendarSchedule__isRunning=False, _CalendarSchedule__isFaulty=False, _CalendarSchedule__id=182810, _CalendarSchedule__installationId='4881321', _CalendarSchedule__functionId=15004, _CalendarSchedule__start=datetime.datetime(2024, 11, 17, 13, 8), _CalendarSchedule__end=datetime.datetime(2024, 11, 17, 13, 18), _CalendarSchedule__recurringType=0, _CalendarSchedule__recurringOccurrence=1, _CalendarSchedule__value=None, _CalendarSchedule__isPaused=False)
2024-12-29 16:14:17 DEBUG [ThermiaHeatpump] Replan from scratch: Keeping schedule CalendarSchedule(_CalendarSchedule__isRunning=False, _CalendarSchedule__isFaulty=False, _CalendarSchedule__id=187763, _CalendarSchedule__installationId=4881321, _CalendarSchedule__functionId=15001, _CalendarSchedule__start=datetime.datetime(2024, 12, 29, 14, 0), _CalendarSchedule__end=datetime.datetime(2024, 12, 29, 22, 0), _CalendarSchedule__recurringType=0, _CalendarSchedule__recurringOccurrence=1, _CalendarSchedule__value=20, _CalendarSchedule__isPaused=False)
2024-12-29 16:14:17 DEBUG [ThermiaHeatpump] Replan from scratch: Deleted conflicting schedule CalendarSchedule(_CalendarSchedule__isRunning=False, _CalendarSchedule__isFaulty=False, _CalendarSchedule__id=187664, _CalendarSchedule__installationId='4881321', _CalendarSchedule__functionId=15001, _CalendarSchedule__start=datetime.datetime(2024, 12, 29, 16, 0), _CalendarSchedule__end=datetime.datetime(2024, 12, 29, 18, 0), _CalendarSchedule__recurringType=0, _CalendarSchedule__recurringOccurrence=1, _CalendarSchedule__value=20, _CalendarSchedule__isPaused=False)
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +1h due to high price 0.345
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +0h due to high price 0.3401
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +2h due to high price 0.3393
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +3h due to high price 0.3257
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +23h due to high price 0.3103
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +22h due to high price 0.3049
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Reduced Heat at +4h due to high price 0.3023
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +16h due to price 0.2985
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +15h due to price 0.2976
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +5h due to price 0.2946
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +17h due to price 0.2945
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +21h due to price 0.2945
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +19h due to price 0.2935
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +20h due to price 0.2907
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +14h due to price 0.2904
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +18h due to price 0.2888
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +7h due to price 0.2803
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +6h due to price 0.2802
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +13h due to price 0.2796
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +12h due to price 0.2772
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +8h due to price 0.2766
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +9h due to price 0.2766
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +11h due to price 0.2745
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Normal Heat at +10h due to price 0.2719
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Adjusted Heatpump Modes: ['R', 'R', 'R', 'R', 'R', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'R', 'R']
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Apply Mode R from +0h to +4h
2024-12-29 16:14:18 INFO [ThermiaHeatpump] Planning Strategy [R] starting at 2024-12-29 17:00:00+01:00, duration: 5:00:00
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Heatpump to REDUCED Heating (20) from 17:00 to 22:00
2024-12-29 16:14:18 INFO [ThermiaHeatpump] Created high price handler: HighPriceHandlingStrategy(schedule=CalendarSchedule(_CalendarSchedule__isRunning=False, _CalendarSchedule__isFaulty=False, _CalendarSchedule__id=187784, _CalendarSchedule__installationId=4881321, _CalendarSchedule__functionId=15001, _CalendarSchedule__start=datetime.datetime(2024, 12, 29, 17, 0), _CalendarSchedule__end=datetime.datetime(2024, 12, 29, 22, 0), _CalendarSchedule__recurringType=0, _CalendarSchedule__recurringOccurrence=1, _CalendarSchedule__value=20, _CalendarSchedule__isPaused=False))
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleanup complete. Remaining handlers: 1
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Apply Mode N from +5h to +21h
2024-12-29 16:14:18 INFO [ThermiaHeatpump] Planning Strategy [N] starting at 2024-12-29 22:00:00+01:00, duration: 17:00:00
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] No change in Heatpump mode from 22:00 to 15:00
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleanup complete. Remaining handlers: 1
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Apply Mode R from +22h to +24h
2024-12-29 16:14:18 INFO [ThermiaHeatpump] Planning Strategy [R] starting at 2024-12-30 15:00:00+01:00, duration: 3:00:00
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Set Heatpump to REDUCED Heating (20) from 15:00 to 18:00
2024-12-29 16:14:18 INFO [ThermiaHeatpump] Created high price handler: HighPriceHandlingStrategy(schedule=CalendarSchedule(_CalendarSchedule__isRunning=False, _CalendarSchedule__isFaulty=False, _CalendarSchedule__id=187785, _CalendarSchedule__installationId=4881321, _CalendarSchedule__functionId=15001, _CalendarSchedule__start=datetime.datetime(2024, 12, 30, 15, 0), _CalendarSchedule__end=datetime.datetime(2024, 12, 30, 18, 0), _CalendarSchedule__recurringType=0, _CalendarSchedule__recurringOccurrence=1, _CalendarSchedule__value=20, _CalendarSchedule__isPaused=False))
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleanup complete. Remaining handlers: 2
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleaning up high price strategies, currently 24 strategies
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleanup complete. Remaining strategies: 24
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] publishing strategy values (2 handlers, 24 strategies) to MQTT
2024-12-29 16:14:18 DEBUG [ThermiaHeatpump] Cleaning up all previously published handlers at heatpumps/0/handlers/
2024-12-29 16:14:18 DEBUG [MQTT] Deleting all topics with prefix batcontrol/heatpumps/0/handlers
2024-12-29 16:14:18 DEBUG [MQTT] Waiting for messages matching topic (batcontrol/heatpumps/0/handlers/#)
2024-12-29 16:14:21 DEBUG [MQTT] All topics with prefix batcontrol/heatpumps/0/handlers/# deleted
2024-12-29 16:14:21 DEBUG [ThermiaHeatpump] Cleaning up all previously published strategies at heatpumps/0/strategies/
2024-12-29 16:14:21 DEBUG [MQTT] Deleting all topics with prefix batcontrol/heatpumps/0/strategies
2024-12-29 16:14:21 DEBUG [MQTT] Waiting for messages matching topic (batcontrol/heatpumps/0/strategies/#)
2024-12-29 16:14:24 DEBUG [MQTT] All topics with prefix batcontrol/heatpumps/0/strategies/# deleted
2024-12-29 16:14:24 DEBUG [ThermiaHeatpump] strategy values (2 handlers, 24 strategies) published to MQTT
2024-12-29 16:14:24 INFO [Main] Next evaluation at 17:15:00. Sleeping for 35 seconds
2024-12-29 16:15:00 DEBUG [ThermiaHeatpump] Refreshing API values
2024-12-29 16:15:01 ERROR [ThermiaHeatpump] Failed to refresh API values: attribute name must be string, not 'tuple'
2024-12-29 16:15:01 DEBUG [FC Cons] predicting consumption: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1372.1 1303.2 1230.9 1134.8 1065.3
 1019.6 1303.6  824.  1184.3]
2024-12-29 16:15:01 DEBUG [BatCTRL] Production FCST: [  0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
   0.  35. 206. 338. 426. 449. 408. 306. 181.  15.]
2024-12-29 16:15:01 DEBUG [BatCTRL] Consumption FCST: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1372.1 1303.2 1230.9 1134.8 1065.3
 1019.6 1303.6  824.  1184.3]
2024-12-29 16:15:01 DEBUG [BatCTRL] Net Consumption FCST: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1337.1 1097.2  892.9  708.8  616.3
  611.6  997.6  643.  1169.3]
2024-12-29 16:15:01 DEBUG [BatCTRL] Prices: [0.34  0.345 0.339 0.326 0.302 0.295 0.28  0.28  0.277 0.277 0.272 0.274
 0.277 0.28  0.29  0.298 0.298 0.294 0.289 0.294 0.291 0.294 0.305 0.31 ]
2024-12-29 16:15:01 DEBUG [Rule] Recharge possible in 6 hours, limiting evaluation window.
2024-12-29 16:15:01 DEBUG [Rule] Future price: 0.280 < Current price: 0.340 - min_price_diff. 0.050
2024-12-29 16:15:01 DEBUG [Rule] Evaluating next 6 hours until 22:59
2024-12-29 16:15:01 DEBUG [Rule] Reserved Energy will be used in the next hours: [1]
2024-12-29 16:15:01 DEBUG [Rule] Reserved Energy: 1794.0 Wh. Usable in Battery: 0.0 Wh
2024-12-29 16:15:01 DEBUG [Rule] Discharge forbidden. Stored usable energy 0.0 Wh <= Reserved energy 1794.0 Wh
2024-12-29 16:15:01 DEBUG [Rule] Discharging is NOT allowed
2024-12-29 16:15:01 DEBUG [BatCTRL] Charging allowed: True
2024-12-29 16:15:01 DEBUG [Rule] Charging is allowed, because SOC is below 98%
2024-12-29 16:15:01 DEBUG [Rule] No additional energy required or possible price found.
2024-12-29 16:15:01 INFO [BatCTRL] Mode: Avoid Discharging
2024-12-29 16:15:01 DEBUG [ThermiaHeatpump] No replanning necessary, already planned until 2024-12-30 17:00:00+01:00
2024-12-29 16:15:01 INFO [Main] Next evaluation at 17:18:00. Sleeping for 178 seconds
2024-12-29 16:18:00 DEBUG [ThermiaHeatpump] Refreshing API values
2024-12-29 16:18:01 ERROR [ThermiaHeatpump] Failed to refresh API values: attribute name must be string, not 'tuple'
2024-12-29 16:18:01 DEBUG [FC Cons] predicting consumption: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1372.1 1303.2 1230.9 1134.8 1065.3
 1019.6 1303.6  824.  1184.3]
2024-12-29 16:18:01 DEBUG [BatCTRL] Production FCST: [  0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.   0.
   0.  35. 206. 338. 426. 449. 408. 306. 181.  15.]
2024-12-29 16:18:01 DEBUG [BatCTRL] Consumption FCST: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1372.1 1303.2 1230.9 1134.8 1065.3
 1019.6 1303.6  824.  1184.3]
2024-12-29 16:18:01 DEBUG [BatCTRL] Net Consumption FCST: [2491.  1794.  1554.1 1217.2  958.3  753.   822.2  659.7  578.9  543.3
  539.9  850.3  842.4  724.6  962.9 1337.1 1097.2  892.9  708.8  616.3
  611.6  997.6  643.  1169.3]
2024-12-29 16:18:01 DEBUG [BatCTRL] Prices: [0.34  0.345 0.339 0.326 0.302 0.295 0.28  0.28  0.277 0.277 0.272 0.274
 0.277 0.28  0.29  0.298 0.298 0.294 0.289 0.294 0.291 0.294 0.305 0.31 ]
2024-12-29 16:18:01 DEBUG [Rule] Recharge possible in 6 hours, limiting evaluation window.
2024-12-29 16:18:01 DEBUG [Rule] Future price: 0.280 < Current price: 0.340 - min_price_diff. 0.050
2024-12-29 16:18:01 DEBUG [Rule] Evaluating next 6 hours until 22:59
2024-12-29 16:18:01 DEBUG [Rule] Reserved Energy will be used in the next hours: [1]
2024-12-29 16:18:01 DEBUG [Rule] Reserved Energy: 1794.0 Wh. Usable in Battery: 0.0 Wh
2024-12-29 16:18:01 DEBUG [Rule] Discharge forbidden. Stored usable energy 0.0 Wh <= Reserved energy 1794.0 Wh
2024-12-29 16:18:01 DEBUG [Rule] Discharging is NOT allowed
2024-12-29 16:18:01 DEBUG [BatCTRL] Charging allowed: True
2024-12-29 16:18:01 DEBUG [Rule] Charging is allowed, because SOC is below 98%
2024-12-29 16:18:01 DEBUG [Rule] No additional energy required or possible price found.
2024-12-29 16:18:01 INFO [BatCTRL] Mode: Avoid Discharging
2024-12-29 16:18:02 DEBUG [ThermiaHeatpump] No replanning necessary, already planned until 2024-12-30 17:00:00+01:00
2024-12-29 16:18:02 INFO [Main] Next evaluation at 17:21:00. Sleeping for 178 seconds

@MaStr
Copy link
Collaborator

MaStr commented Dec 29, 2024

Wow.

it seems this error was already addressed, wasn’t it?
`ˋˋ
2024-12-29 16:15:01 ERROR [ThermiaHeatpump] Failed to refresh API values: attribute name must be string, not 'tuple'
ˋˋˋ

@muexxl I think we need to discuss this integration.

@MaStr MaStr requested a review from muexxl December 29, 2024 19:40
@MaStr MaStr added the enhancement New feature or request label Dec 29, 2024
@hashtagKnorke
Copy link
Contributor Author

Wow.

it seems this error was already addressed, wasn’t it?
`ˋˋ
2024-12-29 16:15:01 ERROR [ThermiaHeatpump] Failed to refresh API values: attribute name must be string, not 'tuple'
ˋˋˋ

bd46757 contains the fix

@muexxl
Copy link
Owner

muexxl commented Dec 29, 2024

Wow.

it seems this error was already addressed, wasn’t it? `ˋˋ 2024-12-29 16:15:01 ERROR [ThermiaHeatpump] Failed to refresh API values: attribute name must be string, not 'tuple' ˋˋˋ

@muexxl I think we need to discuss this integration.

YES. Time for a dev call

@muexxl muexxl closed this Dec 29, 2024
@muexxl muexxl reopened this Dec 29, 2024
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
@hashtagKnorke hashtagKnorke force-pushed the ifeature/integrate_thermia-online-api branch from 5327ec9 to bbb9b89 Compare January 2, 2025 12:20
@hashtagKnorke
Copy link
Contributor Author

hashtagKnorke commented Jan 2, 2025

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) 🤷‍♂️

@MaStr
Copy link
Collaborator

MaStr commented Jan 2, 2025

Yeah, sorry for the pylint stuff. I guess I’ll merge your other PR to reduce that burden.

@MaStr
Copy link
Collaborator

MaStr commented Jan 2, 2025

@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.
On the other hand, it makes totally sense to „store“ energy with the heat pump & release other consumers on the low price events.

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
…ing +1h in multiple code locations redundantly addfs up to wrong durations), partially fixes 01.01.2025 ..... #27
@johannesghd
Copy link
Contributor

@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.

@muexxl
Copy link
Owner

muexxl commented Jan 15, 2025

Dear @hashtagKnorke,
first of all thanks a lot for your contribution.
Me and @MaStr just had a conversation about this pending PR. We do see some potential issues when integrating the control of consumers into the project. We are highly interested in getting your perspective and thoughts. Therefore, we would kindly ask you to join our discord channel https://discord.gg/rNcCK42s

@johannesghd : ofc you are also more than welcome to join us :)

The main issues I am seeing:

  • when consumers (Heatpumps, EVs, Washing mashines..) take decisions based not only on the price but also on the available solar power and battery charge there is the potential of competing control algorithms that lead to oscillations. Also, the consumers may assume that the entire available solar energy surplus is available for use, leading to double (triple..) allocation of the same kWh
  • when consumers to alter their load profile and do not communicate this back to the main controller of batcontrol, batcontrol will take suboptimal decisions
  • Adding the control of consumers to the project adds a whole new level of complexity and changes the project scope from a simple tool for avoiding price peaks by using the home battery to a full blown smart home energy management system. There is the risk of overloading the project.

Looking forward to having a conversation with you .

  • Muexxl

@MaStr
Copy link
Collaborator

MaStr commented Mar 1, 2025

Closing here, as we discussed about the plugin mechanism

@MaStr MaStr closed this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants