esphome: name: filament friendly_name: filament includes: - filament.h
esp8266: board: nodemcu
logger:
api: encryption: key: "+3vxGeHwGfsiIqB3hbb0g3Z2QXDkDWwhXbZEsbO8uW0="
ota: password: "66cd52cdbd7b04b8e3a092cb3779aec1"
wifi: ssid: !secret wifi_ssid password: !secret wifi_password
ap: ssid: "Filament Fallback Hotspot" password: !secret ap_password
captive_portal:
web_server: version: 2
font:
-
file: "fonts/comic.ttf" id: my_font size: 15
-
file: "fonts/comic.ttf" id: big_font size: 25
binary_sensor: #physical buttom
- platform: gpio
pin: D7
name: button1
filters:
- delayed_off: 30ms
globals:
-
id: initial_zero type: float restore_value: yes
initial_value: "-227236"
-
id: auto_tare_enabled type: bool restore_value: yes initial_value: "true"
-
id: auto_tare_difference type: float restore_value: yes initial_value: "0"
sensor:
-
platform: template id: smart_scale_initial_zero name: "Smart Scale Initial Zero" lambda: |- return id(initial_zero); update_interval: 1s
-
platform: template id: smart_scale_auto_tare_difference name: "Smart Scale Auto Tare Difference" lambda: |- return id(auto_tare_difference); update_interval: 1s
- platform: hx711
id: smart_scale_hx711_value_raw
dout_pin: D5
clk_pin: D6
gain: 128
update_interval: 0.2s
filters:
- quantile:
window_size: 10
send_every: 1
send_first_at: 1
quantile: .9
on_value:
then:
- sensor.template.publish: id: smart_scale_hx711_value state: !lambda "return id(smart_scale_hx711_value_raw).state;"
- if: condition: and: - lambda: "return id(auto_tare_enabled);" # current smart scale value is below approx. 10KG (raw value -275743) aka nobody is standing on the scale - lambda: "return id(smart_scale_hx711_value).state < 1.0;" then: - if: condition: # current raw scale value is below expected zero value - lambda: "return id(smart_scale_hx711_value_raw).state < (id(initial_zero) - id(auto_tare_difference));" then: # INcrease Auto-Tare offset to slowly align real zero value with expected zero value - lambda: |- id(auto_tare_difference) += 1; else: # DEcrease Auto-Tare offset to slowly align real zero value with expected zero value - lambda: |- id(auto_tare_difference) -= 1;
- quantile:
window_size: 10
send_every: 1
send_first_at: 1
quantile: .9
on_value:
then:
-
platform: template id: smart_scale_hx711_value name: "Smart Scale HX711 Value" internal: False filters:
- lambda: "return x + id(auto_tare_difference);"
- calibrate_linear:
so measure 0 G and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)
- "-227236 -> 0"
- "-120101 -> 530"
- lambda: |- if (x <= 0.1) { return 0.0; } else { return x; }
-
platform: template name: "Spool Weight"
- platform: homeassistant name: "Filament Spool Weight" id: joya_blue_spool_weight entity_id: sensor.joya_blue_pla attribute: "filament_spool_weight"
- platform: homeassistant name: "Filament Weight" id: joya_blue_weight entity_id: sensor.joya_blue_pla attribute: "remaining_weight"
button:
-
platform: template name: "Next Page" id: next_page
icon: "mdi:emoticon-outline" on_press:
- display.page.show_next: my_display
switch:
- platform: template
id: smart_scale_continuous_tare_enabled
name: "Smart Scale Continuous Tare Enabled"
lambda: |-
return id(auto_tare_enabled);
turn_on_action:
- lambda: |- id(auto_tare_enabled) = true; turn_off_action:
- lambda: |- id(auto_tare_enabled) = false;
i2c: sda: D1 scl: D2 frequency: 800kHz
display:
- platform: ssd1306_i2c
model: "SSD1306 128x32"
reset_pin: D0
address: 0x3C
id: my_display
pages:
- id: scale lambda: |- //it.printf(0, 0, id(my_font),"%.0f", id(smart_scale_hx711_value).state - id(joya_blue_spool_weight).state); it.printf(50, 0, id(big_font),"%.0f", id(smart_scale_hx711_value).state);
- id: filament_scale lambda: |- //it.printf(0, 0, id(my_font),"%.0f", id(smart_scale_hx711_value).state - id(joya_blue_spool_weight).state); it.printf(50, 0, id(big_font),"%.0f", id(smart_scale_hx711_value).state);
http_request: useragent: esphome/device timeout: 10s id: http_request_data interval:
-
interval: 1min then:
- logger.log: format: "Filament weight with spool is is %1.0f" args: ["id(joya_blue_spool_weight).state + id(joya_blue_weight).state"]
-
interval: 5sec then:
- logger.log: format: "current weight is %f" args: ["id(smart_scale_hx711_value).state"]