diff --git a/README.md b/README.md index bcf9bf7..847ff88 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ If you like it, help me code all night 😴 * SmartMeter readings via optical sensor [https://amzn.to/4sbL7va] * WaterMeter readings via [https://amzn.to/46uzGGs] * Controlling a Tecalor THZ 504 (or other Tecalor | Stiebel Eltron heat pumps) via ESP32 + CAN using an MCP2515 [https://amzn.to/4rJ538H] or the Waveshare Industrial ESP32-S3 Control Board with RS485 and CAN Communication [https://amzn.to/4scTlDk]. If you want a more reliable connection, ESP32-S3 ETH development board [https://amzn.to/40qj5zU] might the right choice. There is also a PoE version of that [https://amzn.to/4sbZjnS] +* Dallas DS18B20 1-Wire temperature sensors for precise return flow measurement: [https://amzn.to/4u8ExHr] ## Community Statistics diff --git a/yaml/features/analytics.yaml b/yaml/features/analytics.yaml index a429539..17b2432 100644 --- a/yaml/features/analytics.yaml +++ b/yaml/features/analytics.yaml @@ -16,13 +16,17 @@ esphome: - wait_until: mqtt.connected: - lambda: |- - // Publish Identity - std::string info_payload = id(heat_pump_variant) + "," + ${district}; + // Publish identity incl.. Git-Hash + // Format: variant,district,githash + std::string info_payload = id(heat_pump_variant) + "," + ${district} + "," + "${version_hash}"; id(analytics_mqtt).publish("analytics/v1/" + id(global_device_id).state + "/info", info_payload, 0, true); platformio_options: build_flags: - "-DANALYTICS" +substitutions: + version_hash: "c840a54" + text_sensor: - platform: template name: "Analytics Global Device ID" diff --git a/yaml/templates/wp_cop.yaml b/yaml/templates/wp_cop.yaml new file mode 100644 index 0000000..c49d928 --- /dev/null +++ b/yaml/templates/wp_cop.yaml @@ -0,0 +1,51 @@ +defaults: + accuracy_decimals: "2" + exposed: "true" + +sensor: + - platform: template + name: "${sensor_name}" + id: ${sensor_name} + update_interval: never + state_class: "measurement" + filters: + - or: + - throttle: 15min + - delta: 0.5 + - clamp: + min_value: 1 + max_value: 10 + ignore_out_of_range: true + - median: + lambda: |- + float energy_in = id(${input_property}).state; + float energy_out = id(${output_property}).state; + + // Only calculate if input is valid AND high enough to avoid reset-noise + if (energy_in > 0.5f && energy_out > 0.0f) { + return energy_out / energy_in; + } + return {}; + + - platform: template + id: !extend ${output_property} + on_value: + then: + - component.update: ${sensor_name} + + - platform: template + id: !extend ${input_property} + on_value: + then: + - component.update: ${sensor_name} + +esphome: + on_boot: + priority: 110.0 # AFTER_CONNECTION + then: + - lambda: |- + #if defined(ANALYTICS) + if(${exposed}) { + getWhitelistedEntities().insert(id(${sensor_name})); + } + #endif diff --git a/yaml/templates/wp_generic_combined.yaml b/yaml/templates/wp_generic_combined.yaml index 9837912..125cfc4 100644 --- a/yaml/templates/wp_generic_combined.yaml +++ b/yaml/templates/wp_generic_combined.yaml @@ -11,8 +11,12 @@ sensor: state_class: "measurement" accuracy_decimals: 3 internal: true + update_interval: ${update_interval} filters: - multiply: ${scaler} + lambda: |- + queueRequest(${target}, Property::k${scaled_property}); + return {}; - platform: template name: ${sensor_name} @@ -23,7 +27,6 @@ sensor: update_interval: ${update_interval} state_class: "total_increasing" lambda: |- - queueRequest(${target}, Property::k${scaled_property}); queueRequest(${target}, Property::k${property}); return {}; diff --git a/yaml/txx_base.yaml b/yaml/txx_base.yaml index 93efce1..762353f 100644 --- a/yaml/txx_base.yaml +++ b/yaml/txx_base.yaml @@ -10,19 +10,6 @@ substitutions: manager_can_id: "0x6a1" espclient_can_id: "0x6a2" -######################################### -# # -# Global variables # -# # -######################################### -globals: - - id: gCOP_WW_TAG - type: float - initial_value: "1.0" - - id: gCOP_HEIZ_TAG - type: float - initial_value: "1.0" - ######################################### # # # Home Assistant Sensors # @@ -61,34 +48,6 @@ sensor: queueTransmission(HK1, Property::kRAUMFEUCHTE, static_cast(x * 10.0f)); } -######################################### -# # -# Template Sensors # -# # -######################################### - - platform: template - name: "COP WW TAG" - update_interval: $interval_very_slow - state_class: "measurement" - filters: - - median - lambda: |- - if (id(WAERMEERTRAG_WW_TAG_SUMME_KWH).state && id(EL_ENERGIEAUFNAHME_WW_SUMME_KWH).state && id(EL_ENERGIEAUFNAHME_WW_SUMME_KWH).state != 0.0f) { - id(gCOP_WW_TAG) = id(WAERMEERTRAG_WW_TAG_SUMME_KWH).state / id(EL_ENERGIEAUFNAHME_WW_SUMME_KWH).state; - } - return id(gCOP_WW_TAG); - - platform: template - name: "COP HEIZ TAG" - update_interval: $interval_very_slow - state_class: "measurement" - filters: - - median - lambda: |- - if (id(WAERMEERTRAG_HEIZ_TAG_SUMME_KWH).state && id(EL_ENERGIEAUFNAHME_HEIZ_SUMME_KWH).state && id(EL_ENERGIEAUFNAHME_HEIZ_SUMME_KWH).state != 0.0f) { - id(gCOP_HEIZ_TAG) = id(WAERMEERTRAG_HEIZ_TAG_SUMME_KWH).state / id(EL_ENERGIEAUFNAHME_HEIZ_SUMME_KWH).state; - } - return id(gCOP_HEIZ_TAG); - ######################################### # # # Packages # @@ -97,9 +56,11 @@ sensor: packages: CORE: !include { file: core.yaml } - VERDICHTER_STARTS: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "VERDICHTER_STARTS" , scaled_property: "VERDICHTER_STARTS_K" , property: "VERDICHTER_STARTS" , unit: "" , accuracy_decimals: "0", scaler: "1000", icon: "mdi:counter" }} - WAERMEERTRAG_WW_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "WAERMEERTRAG_WW_SUMME_MWH" , scaled_property: "WAERMEERTRAG_WW_SUM_KWH" , property: "WAERMEERTRAG_WW_SUM_MWH" , unit: "MWh", accuracy_decimals: "3", icon: "mdi:fire" }} - WAERMEERTRAG_HEIZ_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "WAERMEERTRAG_HEIZ_SUMME_MWH" , scaled_property: "WAERMEERTRAG_HEIZ_SUM_KWH" , property: "WAERMEERTRAG_HEIZ_SUM_MWH" , unit: "MWh", accuracy_decimals: "3", icon: "mdi:fire" }} + VERDICHTER_STARTS: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "VERDICHTER_STARTS" , scaled_property: "VERDICHTER_STARTS_K" , property: "VERDICHTER_STARTS" , unit: "" , accuracy_decimals: "0", scaler: "1000", icon: "mdi:counter" }} + WAERMEERTRAG_WW_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "WAERMEERTRAG_WW_SUMME_MWH" , scaled_property: "WAERMEERTRAG_WW_SUM_KWH" , property: "WAERMEERTRAG_WW_SUM_MWH" , unit: "MWh", accuracy_decimals: "3", icon: "mdi:fire" }} + WAERMEERTRAG_HEIZ_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "WAERMEERTRAG_HEIZ_SUMME_MWH" , scaled_property: "WAERMEERTRAG_HEIZ_SUM_KWH" , property: "WAERMEERTRAG_HEIZ_SUM_MWH" , unit: "MWh", accuracy_decimals: "3", icon: "mdi:fire" }} + EL_ENERGIEAUFNAHME_WW_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "EL_ENERGIEAUFNAHME_WW_SUMME_MWH" , scaled_property: "EL_ENERGIEAUFNAHME_WW_SUM_KWH" , property: "EL_ENERGIEAUFNAHME_WW_SUM_MWH" , unit: "MWh", accuracy_decimals: "3", icon: "mdi:lightning-bolt" }} + EL_ENERGIEAUFNAHME_HEIZ_SUMME_MWH: !include { file: templates/wp_generic_combined.yaml, vars: { sensor_name: "EL_ENERGIEAUFNAHME_HEIZ_SUMME_MWH", scaled_property: "EL_ENERGIEAUFNAHME_HEIZ_SUM_KWH", property: "EL_ENERGIEAUFNAHME_HEIZ_SUM_MWH", unit: "MWh", accuracy_decimals: "3", icon: "mdi:lightning-bolt" }} SPEICHERSOLLTEMP: !include { file: templates/wp_temperature.yaml, vars: { property: "SPEICHERSOLLTEMP" }} SPEICHERISTTEMP: !include { file: templates/wp_temperature.yaml, vars: { property: "SPEICHERISTTEMP" , update_interval: $interval_medium }} @@ -122,3 +83,6 @@ packages: WAERMEERTRAG_HEIZ_TAG_SUMME_KWH: !include { file: templates/wp_daily_energy_combined.yaml, vars: { sensor_name: "WAERMEERTRAG_HEIZ_TAG_SUMME_KWH" , property_wh: "WAERMEERTRAG_HEIZ_TAG_WH" , property_kwh: "WAERMEERTRAG_HEIZ_TAG_KWH" }} HEATPUMP_DATETIME: !include { file: templates/wp_datetime.yaml } + + COP_WW_TAG: !include { file: templates/wp_cop.yaml, vars: { sensor_name: COP_WW_TAG , output_property: "WAERMEERTRAG_WW_TAG_SUMME_KWH" , input_property: "EL_ENERGIEAUFNAHME_WW_SUMME_KWH" }} + COP_HEIZ_TAG: !include { file: templates/wp_cop.yaml, vars: { sensor_name: COP_HEIZ_TAG, output_property: "WAERMEERTRAG_HEIZ_TAG_SUMME_KWH", input_property: "EL_ENERGIEAUFNAHME_HEIZ_SUMME_KWH" }} diff --git a/yaml/wpl13.yaml b/yaml/wpl13.yaml index 8a01809..8b14320 100644 --- a/yaml/wpl13.yaml +++ b/yaml/wpl13.yaml @@ -60,12 +60,6 @@ substitutions: # # ######################################### globals: - - id: gCOP_WW_TAG - type: float - initial_value: "0.0" - - id: gCOP_HEIZ_TAG - type: float - initial_value: "0.0" - id: heat_pump_variant type: std::string initial_value: '"WPL13"'