HX711 output as percentage?

I have a HX711 set up as a filament spool weight sensor. I’m wondering is there anyway you have that output to home assistant as a percentage? Right now its just showing weight in kg. Thank you for any help.

Sure. Use a filter of some kind, or a template sensor. The template sensor has the advantage of letting you have both the weight and percentage still available.

sensor:
  - platform: hx711
    name: "HX711 Value"
    dout_pin: D0
    clk_pin: D1
    gain: 128
    update_interval: 60s
    on_value:
      - sensor.template.publish:
          id: percent_remain
          state: !lambda 'return x/4.2 * 100;' # formula for percentage of max weight
                 # 4.2 is the full weight, be clever and take into account spool weight 
                 # something like (x-.5)/3.7 * 100
              
  - platform: template
    name: "Percentage Remaining"
    id: percent_remain
    unit_of_measurement: "%"
1 Like

Thank you! I will give this a try!!

1 Like

Ok I got the empty and full weights. Im using rubber made food storage as dry boxes so there is always some weight.

Empty = .87kg
Full = 2.06kg

How can I right that so it shows the percentage of just the spool? This template stuff always confuses me. Thanks again for the help!

edit: would that be this…

“return - .87 / 2.06 * 100”

It would be something like this:

‘return (x - 0.87)/ (2.06 - 0.87) * 100;’

1 Like