From 4e46128cd6d5a8502232ae806a56742306d5fb84 Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Sat, 18 May 2024 01:43:01 +0200 Subject: [PATCH 1/2] added smart_scale_hx711_value_raw_diagnostic template sensor, which contains the initial raw sensor value, to ease initial calibration setup --- esphome_hx711_smart_scale.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/esphome_hx711_smart_scale.yaml b/esphome_hx711_smart_scale.yaml index 5de898f..329e486 100644 --- a/esphome_hx711_smart_scale.yaml +++ b/esphome_hx711_smart_scale.yaml @@ -128,6 +128,16 @@ sensor: - sensor.template.publish: id: smart_scale_hx711_value state: !lambda 'return id(smart_scale_hx711_value_raw).state;' + - if: + condition: + - lambda: |- + auto n = id(smart_scale_hx711_value_raw_diagnostic).state; + auto n_str = to_string(n); + return str_equals_case_insensitive(n_str, "NaN"); + then: + - sensor.template.publish: + id: smart_scale_hx711_value_raw_diagnostic + state: !lambda 'return id(smart_scale_hx711_value_raw).state;' - if: condition: and: @@ -150,6 +160,10 @@ sensor: - lambda: |- id(auto_tare_difference) -= 10; + - platform: template + id: smart_scale_hx711_value_raw_diagnostic + name: "Smart Scale Initial HX711 Raw Value" + entity_category: "diagnostic" # Mapped value to KG - platform: template From 1fef4859e5e5e9ed987c487214b7d35ecd2b8ba5 Mon Sep 17 00:00:00 2001 From: Markus Ressel Date: Sat, 18 May 2024 01:49:10 +0200 Subject: [PATCH 2/2] update raw diagnostic value when using the "manual tare" button action --- esphome_hx711_smart_scale.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome_hx711_smart_scale.yaml b/esphome_hx711_smart_scale.yaml index 329e486..697637d 100644 --- a/esphome_hx711_smart_scale.yaml +++ b/esphome_hx711_smart_scale.yaml @@ -59,6 +59,9 @@ button: on_press: - lambda: |- id(auto_tare_difference) = id(initial_zero) - id(smart_scale_hx711_value_raw).state; + - sensor.template.publish: + id: smart_scale_hx711_value_raw_diagnostic + state: !lambda 'return id(smart_scale_hx711_value_raw).state;' switch: ## Switch to enable/disable the auto tare feature