The tricky part to adapt this to a feeder bowl is what constitutes the "idle" state where you want to auto-tare to 0 all the time. You'll maybe have to keep track of the uneaten weight in a separate global, and add to it after a dispense event, and subtract from it after you pets have finished eating. The activity_detected could be as simple as a vibration boolean derived from the weight value itself:
sensor:
- platform: hx711
on_value:
# other stuff from above
- lambda: |- # Reading Stability
static float prev_value = 0.0;
if (abs(x - prev_value) < ${vibration_threshold}) {
id(vibration_detected).publish_state(false);
} else {
id(vibration_detected).publish_state(true);
}
prev_value = x;
binary_sensor:
- platform: template
device_class: vibration
entity_category: diagnostic
name: "Vibration"
id: vibration_detected
filters:
- delayed_off:
seconds: ${vibration_off_delay}
on_release:
- lambda: |-
id(food_weight) = std::max(id(food_weight) + id(weight_value).state, (double)0);
id(tare_value) = id(hx711_raw_value).state;
id(auto_tare_value) = 0;