Skip to content

Commit

Permalink
chore: code cleanup and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierBerger authored Nov 23, 2024
2 parents 51be21b + 1587282 commit a177e00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions solar_router/engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ script:
# Define the opening level of regulator based on power measured and grid exchange target
# The value of regulator is a precentage and is then limited to the range 0 100
- lambda: |-
if (isnan(id(real_power).state)){
// If we can have information about grid exchange, do not divert any energy
id(regulator_opening).publish_state(0);
return;
}
double delta = -1*(id(real_power).state-id(target_grid_exchange).state)*id(reactivity).state/1000;
double regulator_status = id(regulator_opening).state + delta;
regulator_status = std::max(0.0, std::min(100.0, regulator_status));
Expand Down
5 changes: 5 additions & 0 deletions solar_router/engine_on_off.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ script:
then:
# Energy export is negative
- lambda: |-
if (isnan(id(real_power).state)){
// If we can have information about grid exchange, do not divert any energy
id(energy_divertion).turn_off();
return;
}
if (id(real_power).state < -id(start_power_level).state)
{
// Energy divertion is needed
Expand Down
4 changes: 3 additions & 1 deletion solar_router/power_meter_fronius.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
esphome:
min_version: 2024.11.1

# ----------------------------------------------------------------------------------------------------
# Sensor updated every second to give feedback in Home Assistant
# ----------------------------------------------------------------------------------------------------

sensor:
# Sensor showing the actual power consumption
- id: real_power
Expand Down
4 changes: 3 additions & 1 deletion solar_router/power_meter_fronius_with_simulated_load.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
esphome:
min_version: 2024.11.1

# ----------------------------------------------------------------------------------------------------
# Sensor updated every second to give feedback in Home Assistant
# ----------------------------------------------------------------------------------------------------

sensor:
# Sensor showing the actual power consumption
- id: real_power
Expand Down
4 changes: 3 additions & 1 deletion solar_router/power_meter_proxy_client.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
esphome:
min_version: 2024.11.1

# ----------------------------------------------------------------------------------------------------
# Sensor updated every second to give feedback in Home Assistant
# ----------------------------------------------------------------------------------------------------

sensor:
# Sensor showing the actual power consumption
- id: real_power
Expand Down

0 comments on commit a177e00

Please sign in to comment.