Skip to content
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
2872ba1
Initial plan
Copilot Oct 24, 2025
526e9e6
Implement sliding-window smoothing and battery reserve features
Copilot Oct 24, 2025
8b1bfae
Add separate smoothing windows for consumption and battery power
Copilot Oct 24, 2025
1a62914
Fix naming convention and add translations for new configuration options
Copilot Oct 24, 2025
b5337b0
Implement sliding-window smoothing for production, consumption, and …
HAuser1234 Oct 24, 2025
3bf673b
Initial plan
Copilot Oct 25, 2025
f3e74e0
Add battery recharge reserve before smoothing option
Copilot Oct 25, 2025
c8876bf
Add tests for battery reserve before/after smoothing
Copilot Oct 25, 2025
ea43448
Add translations for battery reserve before smoothing option
Copilot Oct 25, 2025
646a938
Update translations to include new option in en.json and shorten desc…
Copilot Oct 25, 2025
f862a4b
Add French translations and battery reserve reduction attribute to po…
Copilot Oct 25, 2025
7459d9c
Add battery recharge reserve option in German translation
HAuser1234 Oct 25, 2025
5dc0c8d
Merge pull request #2 from HAuser1234/copilot/add-switch-for-battery-…
HAuser1234 Oct 25, 2025
df6feb7
Fix formatting in German translation for solar optimizer
HAuser1234 Oct 25, 2025
4b723b7
Add translation for battery recharge reserve before smoothing
HAuser1234 Oct 25, 2025
9c7aa3e
Initial plan
Copilot Oct 26, 2025
7b813e2
Update core algorithm and config to use household consumption
Copilot Oct 26, 2025
5f23a1b
Update README files with simplified power distribution documentation
Copilot Oct 26, 2025
1cc8ac0
Fix algorithm to explicitly account for production in net calculation
Copilot Oct 26, 2025
4643070
Address code review comments - fix spelling and language consistency
Copilot Oct 26, 2025
11bbee4
Fix household consumption calculation and add diagnostic sensors
Copilot Oct 26, 2025
f529213
Fix algorithm to use direct power sum instead of diff
Copilot Oct 26, 2025
c21af93
Add household smoothing and min export margin features
Copilot Oct 26, 2025
b8ad585
Fix power deficit handling and remove battery smoothing
Copilot Oct 26, 2025
9bd7c53
Merge pull request #3 from HAuser1234/copilot/implement-simplified-po…
HAuser1234 Oct 26, 2025
e250717
Initial plan
Copilot Oct 26, 2025
8ffefb1
Fix power distribution bug caused by HA state lag
Copilot Oct 26, 2025
fb44375
Add documentation for state lag handling in coordinator
Copilot Oct 26, 2025
d61993e
Address code review feedback - improve comment clarity
Copilot Oct 26, 2025
e6da685
Fix deactivation lag handling - complete state lag fix
Copilot Oct 26, 2025
f24dbce
Address code review feedback - improve error handling and testing
Copilot Oct 26, 2025
8c1ccdf
Merge pull request #5 from HAuser1234/copilot/investigate-power-distr…
HAuser1234 Oct 26, 2025
4811ecb
Initial plan
Copilot Oct 26, 2025
66ba0c5
Add device switching stability to prevent excessive device changes
Copilot Oct 26, 2025
5fd0762
Clean up code formatting (remove trailing whitespace, fix line length)
Copilot Oct 26, 2025
7bbea69
Fix code review issues: avoid code duplication and NameError
Copilot Oct 26, 2025
9640b9d
Move switching_penalty_factor to UI config and clarify variable power…
Copilot Oct 26, 2025
4c22cd5
Fix missing import and remove YAML backward compatibility
Copilot Oct 26, 2025
7813f47
Add translations for switching_penalty_factor in EN, FR, and DE
Copilot Oct 26, 2025
3e76213
Fix config flow: Use NumberSelector for switching_penalty_factor
Copilot Oct 26, 2025
ab6ed89
Merge pull request #6 from HAuser1234/copilot/optimize-power-switchin…
HAuser1234 Oct 28, 2025
815657e
Revert "Fix device power tracking during HA state lag causing overcon…
HAuser1234 Oct 28, 2025
c25a7f8
Merge pull request #8 from HAuser1234/revert-5-copilot/investigate-po…
HAuser1234 Oct 28, 2025
2282347
Revert "Revert "Fix device power tracking during HA state lag causing…
HAuser1234 Oct 28, 2025
37a047a
Merge pull request #9 from HAuser1234/revert-8-revert-5-copilot/inves…
HAuser1234 Oct 28, 2025
dde2053
Revert "Revert "Revert "Fix device power tracking during HA state lag…
HAuser1234 Oct 28, 2025
45a9a7a
Merge pull request #10 from HAuser1234/revert-9-revert-8-revert-5-cop…
HAuser1234 Oct 28, 2025
c587031
Initial plan
Copilot Oct 28, 2025
1c8c0e7
Fix household deficit handling - compute excess correctly
Copilot Oct 28, 2025
1f0f37c
Apply Black formatting
Copilot Oct 28, 2025
f3d9e29
Merge pull request #12 from HAuser1234/copilot/fix-excess-power-calcu…
HAuser1234 Oct 28, 2025
9d69226
Initial plan
Copilot Oct 29, 2025
8805169
Implement standby handling and off-penalty + debounce for 0W devices
Copilot Oct 29, 2025
fb86b1e
Add auto-suggest switching penalty and optional price clamping
Copilot Oct 29, 2025
680aaca
Add suggested penalty sensor and update coordinator
Copilot Oct 29, 2025
025af33
Add translations for auto_switching_penalty and clamp_price_step
Copilot Oct 29, 2025
35dfe60
Add config flow options and fix suggested_penalty sensor
Copilot Oct 29, 2025
e29681f
Add reward for turning on devices with excess power
Copilot Oct 29, 2025
0b698f4
Add priority-aware reward boost for low-priority devices with excess …
Copilot Oct 29, 2025
a574748
Merge pull request #13 from HAuser1234/copilot/fix-device-power-issues
HAuser1234 Nov 1, 2025
320e0c9
Initial plan
Copilot Nov 1, 2025
2d34520
Fix coordinator selector to show device type options after adding coo…
Copilot Nov 1, 2025
61a309f
Merge pull request #14 from HAuser1234/copilot/fix-coordinator-select…
HAuser1234 Nov 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
- [Les contributions sont les bienvenues !](#les-contributions-sont-les-bienvenues)

> ![Nouveau](https://github.com/jmcollin78/solar_optimizer/blob/main/images/new-icon.png?raw=true) _*Nouveautés*_
> * **release 3.6.0** :
> - **Calcul de puissance simplifié** : L'algorithme attend maintenant la consommation de base de la maison (en watts positifs), offrant une optimisation plus précise
> - **Configuration mise à jour** : `power_consumption_entity_id` doit maintenant représenter la consommation de la maison, pas la mesure nette. Voir [Créer des capteurs template pour votre installation](#créer-des-capteurs-template-pour-votre-installation) pour le guide de migration
> - **Amélioration de la gestion de la batterie** : Le capteur de puissance de charge de la batterie est maintenant optionnel (utilisé uniquement pour les diagnostics). La réserve et le SOC de la batterie sont gérés plus efficacement
> - **Lissage par défaut mis à jour** : Le lissage de production PV est maintenant par défaut à 15 minutes pour une meilleure stabilité. Lissage de la consommation et de la batterie désactivé par défaut
> * **release 3.5.0** :
> - ajout d'une gestion de la priorité. Cf. [la gestion de la priorité](#la-gestion-de-la-priorité)
> * **release 3.2.0** :
Expand Down
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@


>![New](https://github.com/jmcollin78/solar_optimizer/blob/main/images/new-icon.png?raw=true) _*News*_
> * **release 3.6.0**:
> - **Simplified power calculation**: The algorithm now expects household base consumption (positive watts) as input, providing more accurate optimization
> - **Updated configuration**: `power_consumption_entity_id` should now represent household consumption, not net metering. See [Creating Sensor Templates](#creating-sensor-templates-for-your-installation) for migration guidance
> - **Battery handling improvements**: Battery charge power sensor is now optional (used for diagnostics only). Battery reserve and SOC are handled more efficiently
> - **Default smoothing updated**: PV production smoothing now defaults to 15 minutes for better stability. Consumption and battery smoothing disabled by default
> * **release 3.5.0**:
> - added support for priority management. See [Priority Management](#priority-management)
> * **release 3.2.0** :
Expand Down Expand Up @@ -584,7 +589,36 @@ data: {}

Your setup may require the creation of specific sensors that need to be configured [here](README-en.md#configure-the-integration-for-the-first-time). The rules for these sensors are crucial and must be strictly followed to ensure the proper functioning of Solar Optimizer.

Below are my sensor templates (applicable only for an Enphase installation):
## Important: Household Consumption Sensor

**As of version 3.6.0**, Solar Optimizer expects the `power_consumption_entity_id` to represent **positive household base consumption in watts**. This is the power consumed by your home, excluding the managed devices controlled by Solar Optimizer.

### What this means:
- The sensor should report **positive values** representing actual household consumption
- It should **not** include the power of devices managed by Solar Optimizer (they are tracked separately)
- If you use a **net-metering sensor** (where negative values indicate export to grid), you should create a template sensor to convert it to positive household consumption

### Example scenarios:
1. **If you have a direct household consumption sensor**: Use it directly
2. **If you have a net-metering sensor**: Create a template sensor like:
```yaml
- sensor:
- name: "Household Base Consumption (W)"
unit_of_measurement: "W"
device_class: power
state_class: measurement
state: >
{% set net_power = states('sensor.your_net_power_sensor') | float(default=0) %}
{{ [0, net_power] | max }}
```

### Battery handling:
- Battery state of charge (SOC) is used for device usability rules
- Battery reserve can be configured to prioritize battery charging over devices
- Battery charge power sensor is now **optional** and used only for diagnostics
- The algorithm automatically accounts for battery behavior through the configured reserve

Below are example sensor templates (applicable for an Enphase installation):

### File `configuration.yaml`:
```
Expand Down
6 changes: 6 additions & 0 deletions custom_components/solar_optimizer/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
selector.EntitySelectorConfig(domain=[SENSOR_DOMAIN, INPUT_NUMBER_DOMAIN])
),
vol.Optional(CONF_SMOOTH_PRODUCTION, default=True): cv.boolean,
vol.Optional(CONF_SMOOTHING_PRODUCTION_WINDOW_MIN, default=DEFAULT_SMOOTHING_PRODUCTION_WINDOW_MIN): vol.Coerce(int),
vol.Optional(CONF_SMOOTHING_CONSUMPTION_WINDOW_MIN, default=DEFAULT_SMOOTHING_CONSUMPTION_WINDOW_MIN): vol.Coerce(int),
vol.Optional(CONF_SMOOTHING_HOUSEHOLD_WINDOW_MIN, default=DEFAULT_SMOOTHING_HOUSEHOLD_WINDOW_MIN): vol.Coerce(int),
vol.Optional(CONF_BATTERY_RECHARGE_RESERVE_W, default=DEFAULT_BATTERY_RECHARGE_RESERVE_W): vol.Coerce(float),
vol.Optional(CONF_BATTERY_RECHARGE_RESERVE_BEFORE_SMOOTHING, default=DEFAULT_BATTERY_RECHARGE_RESERVE_BEFORE_SMOOTHING): cv.boolean,
vol.Optional(CONF_MIN_EXPORT_MARGIN_W, default=DEFAULT_MIN_EXPORT_MARGIN_W): vol.Coerce(float),
vol.Optional(CONF_BATTERY_SOC_ENTITY_ID): selector.EntitySelector(
selector.EntitySelectorConfig(domain=[SENSOR_DOMAIN, INPUT_NUMBER_DOMAIN])
),
Expand Down
12 changes: 12 additions & 0 deletions custom_components/solar_optimizer/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

DEFAULT_REFRESH_PERIOD_SEC = 300
DEFAULT_RAZ_TIME = "05:00"
DEFAULT_SMOOTHING_PRODUCTION_WINDOW_MIN = 15
DEFAULT_SMOOTHING_CONSUMPTION_WINDOW_MIN = 0
DEFAULT_SMOOTHING_HOUSEHOLD_WINDOW_MIN = 0
DEFAULT_BATTERY_RECHARGE_RESERVE_W = 0.0
DEFAULT_BATTERY_RECHARGE_RESERVE_BEFORE_SMOOTHING = False
DEFAULT_MIN_EXPORT_MARGIN_W = 0.0

CONF_ACTION_MODE_ACTION = "action_call"
CONF_ACTION_MODE_EVENT = "event"
Expand Down Expand Up @@ -55,6 +61,12 @@
CONF_BUY_COST_ENTITY_ID = "buy_cost_entity_id"
CONF_SELL_TAX_PERCENT_ENTITY_ID = "sell_tax_percent_entity_id"
CONF_SMOOTH_PRODUCTION = "smooth_production"
CONF_SMOOTHING_PRODUCTION_WINDOW_MIN = "smoothing_production_window_min"
CONF_SMOOTHING_CONSUMPTION_WINDOW_MIN = "smoothing_consumption_window_min"
CONF_SMOOTHING_HOUSEHOLD_WINDOW_MIN = "smoothing_household_window_min"
CONF_BATTERY_RECHARGE_RESERVE_W = "battery_recharge_reserve_w"
CONF_BATTERY_RECHARGE_RESERVE_BEFORE_SMOOTHING = "battery_recharge_reserve_before_smoothing"
CONF_MIN_EXPORT_MARGIN_W = "min_export_margin_w"
CONF_REFRESH_PERIOD_SEC = "refresh_period_sec"
CONF_NAME = "name"
CONF_ENTITY_ID = "entity_id"
Expand Down
Loading