I am trying to calculate a number prior to sending it in the rest command. This is a keg scale using a Tasmotized ESP8266 and MQTT.
I have the data come in as a sensor, then an automation gets called every 5 minutes to update taplist.io.
I also have a helper and a place I can enter the weight of the scale+keg in the dashboard.
What I need to do is not hardcode the “tare” value of my container that is sitting on the scale. So under the sensor value_template, the 44800 is the weight I need to subtract. This weight changes depending on the specific keg I place on my scale.
What I am looking for is a way to enter this number in the dashboard (right now as a helper), then have it either calculate in the sensor (I don’t think this is possible to use helpers in the sensor YAML) or calculate in the payload section.
My helper is called “input_number.tap_1_tare_weight”
How would I use the helper as a variable to subtract either in the sensor or the rest_command?
Thank you!
mqtt:
sensor:
- name: "Tap 1 ml"
state_topic: "tele/brewery/kegerator/tap/1/SENSOR"
value_template: "{{ (value_json.HX711.WeightRaw | float - 44800) | round(1) | abs }}"
rest_command:
tap_one_update:
url: https://api.taplist.io/api/v1/venues/my_name/taps/1/current-keg
method: PATCH
headers:
authorization: "token secret-xxxxx"
payload: '{"served_volume_ml": {{ states("sensor.tap_1_ml")}}}'
content_type: 'application/json; charset=utf-8'