From aec6d5dd418a8cf3fe06acdbcc973d1b5337a9a2 Mon Sep 17 00:00:00 2001 From: Bram Kelchtermans Date: Mon, 6 May 2024 22:26:27 +0200 Subject: [PATCH] bedscale --- bed-scale/.gitignore | 5 +++ bed-scale/bed_scale.yaml | 66 +++++++++++++++++++++++++++++++++++++++ bed-scale/raw_output.yaml | 36 +++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 bed-scale/.gitignore create mode 100644 bed-scale/bed_scale.yaml create mode 100644 bed-scale/raw_output.yaml diff --git a/bed-scale/.gitignore b/bed-scale/.gitignore new file mode 100644 index 0000000..d8b4157 --- /dev/null +++ b/bed-scale/.gitignore @@ -0,0 +1,5 @@ +# Gitignore settings for ESPHome +# This is an example and may include too much for your use-case. +# You can modify this file to suit your needs. +/.esphome/ +/secrets.yaml diff --git a/bed-scale/bed_scale.yaml b/bed-scale/bed_scale.yaml new file mode 100644 index 0000000..196089d --- /dev/null +++ b/bed-scale/bed_scale.yaml @@ -0,0 +1,66 @@ +esphome: + name: bedscale + +esp8266: + board: d1_mini + +# Enable logging +logger: + level: DEBUG + +# Enable Home Assistant API +api: + password: "" + +ota: + password: "" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Bed-Scale Fallback Hotspot" + password: !secret hotspot_password + +captive_portal: + + +globals: + - id: constant_weight + type: float + +sensor: + - platform: hx711 + id: bed + internal: true + dout_pin: D4 + clk_pin: D3 + update_interval: 3s + gain: 128 + filters: + - calibrate_linear: + - 2827100 -> 0 + - 5170670 -> 103.9 + on_value: + - if: + condition: + - lambda: |- + static float last = 0.0; + float diff = x - last; + last = x; + return x < 10.0 && diff < 1.0 && diff > - 1.0; + then: + - lambda: 'id(constant_weight) = x;' + + - platform: template + name: Bedscale + icon: mdi:weight-kilogram + update_interval: 3s + unit_of_measurement: kg + lambda: 'return id(bed).state;' + filters: + - lambda: 'return x - id(constant_weight);' + - lambda: 'return x >= 10.0 ? x : 0;' + - delta: 0.5 \ No newline at end of file diff --git a/bed-scale/raw_output.yaml b/bed-scale/raw_output.yaml new file mode 100644 index 0000000..977964f --- /dev/null +++ b/bed-scale/raw_output.yaml @@ -0,0 +1,36 @@ +esphome: + name: bedscale + +esp8266: + board: d1_mini + +# Enable logging +logger: + level: DEBUG + +# Enable Home Assistant API +api: + password: "" + +ota: + password: "" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Bed-Scale Fallback Hotspot" + password: !secret hotspot_password + +captive_portal: + +sensor: + - platform: hx711 + name: "HX711 Value" + dout_pin: D4 + clk_pin: D3 + gain: 128 + update_interval: 3s + \ No newline at end of file