I took the entire text of my question with Ctrl-A Ctrl-C and pasted it into ChatGPT.
Wow. Just wow. No wonder they say computer programming isn’t going to be the career it used to be.
Consider the hx711 sensor in this component. From experience, if no weight is on the scale, the sensor reports anything from 0.01 to 3 lbs. How can this be modified so that the component continuously examines the average of the last 5 readings, and if:
0.05 < A < 3.00
then the Tare button should be “pressed”. Yes, there might be a better auto-tare function out there, but i am more interested on how to implement it in this fashion.
esphome:
name: "funky-scale"
on_boot:
- delay: 1s
# to change password, uncomment on lambda and password, comment out ota_password and run. then restofe comments
# - lambda: |-
# id(my_ota).set_auth_password("xxx");
ota:
- platform: esphome
password: !secret ota_password
id: my_ota
# on_abort:
# - delay: 15sec
# - lambda: id(my_ota).clean_rtc();
# safe_mode:
# id: my_safe_mode
# disabled: false
# boot_is_good_after: 45s
# num_attempts: 10
# reboot_timeout: 5min
# # on_safe_mode: SOME ACTION
# # ... other safe_mode configuration
# on_boot:
# - delay: 1s
# - lambda: id(my_ota).clean_rtc();
esp8266:
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 1min
fast_connect: true
manual_ip:
static_ip: 172.16.68.72
gateway: 172.16.68.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "hx711B Fallback Hotspot"
password: "3IexvKFhv5qd"
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
reboot_timeout: 15sec
captive_portal:
sensor:
- platform: hx711
name: "HX711 Value"
dout_pin: D2
clk_pin: D3
# ... Other HX711 options
gain: 128
update_interval: 2s
accuracy_decimals: 2
unit_of_measurement: lbs
filters:
- calibrate_linear:
- -4516200 -> 0
- -4579200 -> 10
- lambda: |-
id(weight_no_tare).publish_state(x);
return (x - id(weight_tare));
- platform: template
id: weight_no_tare
internal: True
accuracy_decimals: 2
globals:
- id: weight_tare
type: float
restore_value: False
initial_value: '0.0'
button:
- platform: template
id: weight_tare_set
name: 'Tare'
on_press:
- lambda: id(weight_tare) = id(weight_no_tare).state;
- logger.log: "Tare pressed"
- platform: restart
id: scale_restart
name: "Restart Button"
on_press:
- logger.log: "Restart Button"
switch:
- platform: restart
id: scale_switch
name: "Restart Switch"
on_turn_on:
- logger.log: "Restart Switch"