Skip to content

Commit

Permalink
Transform energy_consumed_increasing to a realtime daily counter with…
Browse files Browse the repository at this point in the history
… copy sensor and remove HA dependency for time
  • Loading branch information
gekkekoe committed Jan 17, 2025
1 parent d39af62 commit 3048204
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/ecodan/climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ namespace ecodan
new_action = climate::CLIMATE_ACTION_COOLING;
}
break;
case ecodan::Status::OperationMode::UNAVAILABLE:
case ecodan::Status::OperationMode::OFF:
case ecodan::Status::OperationMode::DHW_ON:
case ecodan::Status::OperationMode::LEGIONELLA_PREVENTION:
Expand Down
42 changes: 37 additions & 5 deletions confs/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ text_sensor:
case esphome::ecodan::Status::OperationMode::COOL_ON: return std::string("${cooling}");
case esphome::ecodan::Status::OperationMode::FROST_PROTECT: return std::string("${frost_protection}");
case esphome::ecodan::Status::OperationMode::LEGIONELLA_PREVENTION: return std::string("${legionella_prevention}");
case esphome::ecodan::Status::OperationMode::UNAVAILABLE:
default: return std::string("Unknown");
}
Expand Down Expand Up @@ -319,12 +320,43 @@ sensor:
name: ${dhw_consumed}
dhw_delivered:
name: ${dhw_delivered}
energy_consumed_increasing:
name: ${energy_consumed_increasing}

refrigerant_error_code:
internal: true
id: refrigerant_error_code
energy_consumed_increasing:
internal: true
id: energy_consumed_increasing
name: ${energy_consumed_increasing}
- platform: copy
source_id: energy_consumed_increasing
id: delta_energy_consumed_increasing
name: ${daily_repported_input_power}
unit_of_measurement: 'kWh'
state_class: total_increasing
filters:
- lambda: |-
static float last_value = 0.0;
static float partial_sum = 0.0;
static uint16_t last_day_of_year = 0;
auto t = id(sntp_time).now();
if (!t.is_valid())
return {};
if (last_value == 0) {
last_value = x;
last_day_of_year = t.day_of_year;
return partial_sum;
}
if (t.day_of_year != last_day_of_year) {
last_day_of_year = t.day_of_year;
partial_sum = 0.0f;
}
partial_sum += x >= last_value ? (x - last_value) : (65536 + x - last_value);
last_value = x;
return partial_sum;
- platform: uptime
name: ${uptime}
Expand All @@ -348,8 +380,8 @@ sensor:

# Enable time component to reset energy at midnight
time:
- platform: homeassistant
id: homeassistant_time
- platform: sntp
id: sntp_time

binary_sensor:
- platform: ecodan
Expand Down
1 change: 1 addition & 0 deletions confs/ecodan-labels-en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substitutions:
output_power: Output Power
computed_output_power: Estimated Output Power
daily_computed_output_power: Estimated Total Daily Energy Produced
daily_repported_input_power: Reported Total Daily Energy Consumption
outside_temp: Outside Temp
hp_refrigerant_temp: Refrigerant Liquid Temp
hp_refrigerant_condensing_temp: Refrigerant Condensing Temp
Expand Down
1 change: 1 addition & 0 deletions confs/ecodan-labels-es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substitutions:
output_power: Potencia de Salida
computed_output_power: Potencia de Salida Estimada
daily_computed_output_power: Potencia de Salida Estimada (A diario)
daily_repported_input_power: Consumo Total Diario de Energía Reportado
outside_temp: Temp. Exterior
hp_refrigerant_temp: Temp. Líquido Refrigerante
hp_refrigerant_condensing_temp: Temp. Condensación del Refrigerante
Expand Down
1 change: 1 addition & 0 deletions confs/ecodan-labels-fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substitutions:
output_power: Puissance de sortie
computed_output_power: Puissance de sortie estimée
daily_computed_output_power: Puissance de sortie estimée (Tous les jours)
daily_repported_input_power: Consommation totale d'énergie quotidienne déclarée
outside_temp: Temp Ext
hp_refrigerant_temp: Temp Liquide Réfrigérant
hp_refrigerant_condensing_temp: Temp Condensation Liquide Réfrigérant
Expand Down
1 change: 1 addition & 0 deletions confs/ecodan-labels-it.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substitutions:
output_power: En. Prod.
computed_output_power: Stima En. Prod.
daily_computed_output_power: Stima En. Prod. (Giorno)
daily_repported_input_power: Consumo Energetico Giornaliero Totale Segnalato
outside_temp: T. Esterna
hp_refrigerant_temp: T. Mandata Liq. Refr.
hp_refrigerant_condensing_temp: T. Cond. Liq. Refr.
Expand Down
1 change: 1 addition & 0 deletions confs/ecodan-labels-nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substitutions:
output_power: Afgegeven vermogen
computed_output_power: Geschatte afgegeven vermogen
daily_computed_output_power: Geschatte afgegeven vermogen (Per dag)
daily_repported_input_power: Gerapporteerde opgenomen vermogen (Per dag)
outside_temp: Buiten temp
hp_refrigerant_temp: Koelmiddel temp
hp_refrigerant_condensing_temp: Koelmiddel condensatie temp
Expand Down

0 comments on commit 3048204

Please sign in to comment.