Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 22 additions & 1 deletion solar_router/engine_1switch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ number:
optimistic: True
on_value:
then:
# Keep regulator_opening in sync with router_level so the shared
# regulator_opening_sensor in engine_common.yaml tracks this
# variant too (same pattern as engine_1dimmer.yaml).
- number.set:
id: regulator_opening
value: !lambda return id(router_level).state;
- if:
condition:
number.in_range:
Expand All @@ -85,7 +91,22 @@ number:
- switch.is_on: activate
then:
- light.turn_on: green_led


# Regulator opening percentage. On this variant the router is either
# fully open (100 %) or fully closed (0 %), so `mode: box` reflects the
# discrete nature — a slider with step 100 would only be reachable at
# its endpoints.
- platform: template
name: "Regulator Opening"
id: regulator_opening
min_value: 0
max_value: 100
step: 100
unit_of_measurement: "%"
optimistic: True
mode: box
internal: true

# Define the power level to start divertion
- platform: template
name: "Start power level"
Expand Down
11 changes: 11 additions & 0 deletions solar_router/engine_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ sensor:
then:
script.execute: energy_regulation

# Mirror the current regulator opening (%) as a template sensor so it
# is visible in Home Assistant graphs. Every engine variant defines a
# `regulator_opening` template number; this sensor tracks its state.
- platform: template
name: "Regulator Opening Sensor"
id: regulator_opening_sensor
unit_of_measurement: "%"
accuracy_decimals: 0
update_interval: 5s
lambda: return id(regulator_opening).state;

substitutions:
# By default LEDs are pin-controlled and not inverted
green_led_inverted: "False"
Expand Down
12 changes: 6 additions & 6 deletions solar_router/power_meter_fronius.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

esphome:
min_version: 2025.5.0
Expand Down Expand Up @@ -100,10 +101,9 @@ script:
time:
- platform: sntp
on_time:
# The engine only reacts to real_power / consumption when the
# `activate` switch is on; polling the meter unconditionally lets
# Home Assistant show live figures even while routing is off.
- seconds: /1
then:
- if:
condition:
- lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source
- script.execute: power_meter_source
33 changes: 24 additions & 9 deletions solar_router/power_meter_home_assistant.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

esphome:
min_version: 2025.5.0

# ----------------------------------------------------------------------------------------------------
# Define sensor for power collection
# ----------------------------------------------------------------------------------------------------
# The Home Assistant power meter imports two sensors from HA and forwards
# them into the `real_power` / `consumption` template sensors declared in
# power_meter_common.yaml, so the rest of the packages see the same API
# as every other meter variant. The reader sensors are `internal: True`
# to avoid exposing duplicate entities in Home Assistant.

sensor:
# Sensor showing the actual power exchange
- platform: homeassistant
id: real_power
id: real_power_reader
entity_id: ${main_power_sensor}
internal: False
name: "Real Power"
internal: True
name: "Real Power Reader"
device_class: "power"
unit_of_measurement: "W"
filters:
- multiply: ${power_sign}
on_value:
then:
- lambda: |-
id(real_power).publish_state(x);

# Sensor showing the actual consumption
- platform: homeassistant
id: consumption
id: consumption_reader
entity_id: ${consumption_sensor}
internal: False
name: "Consumption"
internal: True
name: "Consumption Reader"
device_class: "power"
unit_of_measurement: "W"
on_value:
then:
- lambda: |-
id(consumption).publish_state(x);
12 changes: 6 additions & 6 deletions solar_router/power_meter_jsy-mk-194t.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

# ----------------------------------------------------------------------------------------------------
# User interaction
# ----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -31,10 +33,8 @@ script:
time:
- platform: sntp
on_time:
# Poll unconditionally so real_power stays fresh in HA even when
# the router's `activate` switch is off.
- seconds: /1
then:
- if:
condition:
lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source
- script.execute: power_meter_source
13 changes: 6 additions & 7 deletions solar_router/power_meter_proxy_client.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

esphome:
min_version: 2024.11.1
min_version: 2025.5.0

# ----------------------------------------------------------------------------------------------------
# Use http request component
Expand Down Expand Up @@ -90,10 +91,8 @@ script:
time:
- platform: sntp
on_time:
# Poll unconditionally so real_power/consumption stay fresh in HA
# even when the router's `activate` switch is off.
- seconds: /1
then:
- if:
condition:
- lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source
- script.execute: power_meter_source
11 changes: 5 additions & 6 deletions solar_router/power_meter_shelly_em.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

esphome:
min_version: 2025.5.0
Expand Down Expand Up @@ -72,10 +73,8 @@ script:
time:
- platform: sntp
on_time:
# Poll unconditionally so real_power stays fresh in HA even when
# the router's `activate` switch is off.
- seconds: /1
then:
- if:
condition:
- lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source
- script.execute: power_meter_source
45 changes: 12 additions & 33 deletions solar_router/power_meter_shelly_em3.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<<: !include power_meter_common.yaml
packages:
- !include power_meter_common.yaml

esphome:
min_version: 2025.5.0
Expand Down Expand Up @@ -31,13 +32,9 @@ esphome:
# show_phase_power (optional) expose per-phase W sensors, default "False".

substitutions:
# Same defaults as power_meter_common.yaml - re-declared here because a
# substitution block overriding the merged one replaces it entirely.
power_meter_activated_at_start: "0"
power_sign: "1"
# The Shelly EM3 only exposes a NET power (total_act_power): the per-phase
# "consumption" template below is never written in this package, so it stayed
# stuck at "unknown" in HA. Hide it instead of shipping dead weight.
# The Shelly EM3 only exposes a net power (total_act_power), so the per-phase
# "consumption" template inherited from power_meter_common.yaml is never
# written from this package. Hide it instead of shipping a dead entity.
consumption_sensor_internal: "true"
# This package specifics
power_meter_emeter_id: "0"
Expand All @@ -51,7 +48,7 @@ http_request:
verify_ssl: False

script:
# Poll the Em3 meter and publish the grid-exchange power (total_act_power)
# Poll the EM3 meter and publish the grid-exchange power (total_act_power)
- id: power_meter_source
mode: single
then:
Expand Down Expand Up @@ -109,26 +106,10 @@ script:
- lambda: |-
id(real_power).publish_state(NAN);

# Sense the per-phase active powers for debugging / tuning (hidden by default)
# Per-phase active powers for debugging / tuning (hidden by default).
# real_power / consumption template sensors come from power_meter_common.yaml
# via the `packages:` include; no need (and no room) to redeclare them here.
sensor:
# Re-declared from power_meter_common.yaml: the '<<' merge only keeps the
# FIRST definition of a key, and this file defines its own 'sensor:' section.
# The engine depends on these two template sensors.
- id: real_power
platform: template
name: "Real Power"
device_class: "power"
unit_of_measurement: "W"
update_interval: 1s

- id: consumption
platform: template
name: "Consumption"
device_class: "power"
unit_of_measurement: "W"
update_interval: 1s
internal: ${consumption_sensor_internal}

- platform: template
id: em3_phase_a_power
name: "EM3 Phase A Active Power"
Expand Down Expand Up @@ -161,10 +142,8 @@ time:
# if a future ESPHome release fixes the http_request/IDF transport reuse race.
- platform: sntp
on_time:
# Poll unconditionally so real_power stays fresh in HA even when
# the router's `activate` switch is off.
- seconds: /2
then:
- if:
condition:
- lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source
- script.execute: power_meter_source
6 changes: 5 additions & 1 deletion solar_router/temperature_limiter_DS18B20.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
esphome:
min_version: 2025.5.0

substitutions:
DS18B20_address: "0"
temperature_update_interval: 5s
red_led_inverted: "False"

<<: !include temperature_limiter_common.yaml
packages:
- !include temperature_limiter_common.yaml

one_wire:
- platform: gpio
Expand Down
8 changes: 6 additions & 2 deletions solar_router/temperature_limiter_home_assistant.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# ----------------------------------------------------------------------------------------------------
# Define sensor for temperaturewer collection
# Define sensor for temperature collection
# ----------------------------------------------------------------------------------------------------
esphome:
min_version: 2025.5.0

substitutions:
red_led_inverted: "False"

<<: !include temperature_limiter_common.yaml
packages:
- !include temperature_limiter_common.yaml

sensor:
# Sensor showing the temprature to monitor
Expand Down