How I Track Water Bottle Refills With an NFC Tag in Home Assistant

Watch on YouTube ↗Get the code ↗Explore the gear →

I usually have a good idea how many bottles I filled yesterday. Ask me again on Friday and I’m guessing. We already fill our 40-ounce bottles at the water cooler, so that’s where I put a little NFC sticker. A tap there gives Home Assistant a record I can look back at with my sleep and activity.

NFC sticker at the water cooler for tracking bottle refills

Write the sticker on your phone

Open the Home Assistant Companion App on the iPhone you’ll use to log refills. In Settings, search for Tags, then tap Add tag. I called mine Water Bottle Refill. Leave the generated ID in place and choose Create and write. Hold the top of the phone near the sticker until it says Tag Written!

Try scanning it before sticking it down. Open the Home Assistant banner and check that the tag’s last-scanned time changes. Test it again against the side of the cooler before peeling the backing. If it reads on the table and stops reading on metal, try a plastic section of the cooler or an on-metal tag.

Connect one full bottle to one phone

Here’s a one-person example for a Home Assistant package. Replace both quoted IDs with the tag and scanning device from your setup. You can find them by listening for tag_scanned in Developer Tools → Events while scanning the sticker. Change 40 if you use a different bottle.

counter:
  water_bottle_refills:
    name: Water Bottle Refills
    restore: true

automation:
  - alias: Log my full water bottle
    triggers:
      - trigger: tag
        tag_id: "YOUR_TAG_ID"
        device_id: "YOUR_SCANNING_PHONE_DEVICE_ID"
    actions:
      - action: counter.increment
        target:
          entity_id: counter.water_bottle_refills
      - delay: "00:00:30"
    mode: single
    max_exceeded: silent

template:
  - sensor:
      - name: Water Refilled Total
        unique_id: water_refilled_total
        unit_of_measurement: "fl oz"
        state_class: total_increasing
        availability: "{{ is_number(states('counter.water_bottle_refills')) }}"
        state: "{{ states('counter.water_bottle_refills') | int(0) * 40 }}"

utility_meter:
  water_refilled_today:
    source: sensor.water_refilled_total
    cycle: daily
    periodically_resetting: false
  water_refilled_this_week:
    source: sensor.water_refilled_total
    cycle: weekly
    periodically_resetting: false

The 30-second delay absorbs a second tap from the same phone. For a second person, give their phone its own automation, counter, total sensor and meters, and reuse the tag ID. Both people can fill up back to back. In our dashboard I can also hold my Water Total tile and confirm a refill when I forget to scan.

What my health coach gets from a tap

The three water tiles beneath sleep show total ounces, today and this week. Filling my bottle twice adds 80 US fl oz to the running total. If I fill one before bed and finish it the next morning, the refill stays on the date I filled it. My nutrition coach can say how much I logged and leave the drinking time open. A day with no scans could just mean I forgot my phone.

I used a couple of clips from my walking and weight-loss video in this walkthrough. You can read the hydration package YAML, follow the project build notes or read the Home Assistant tags documentation.

NFC sticker pack on Amazon (affiliate link). As an Amazon Associate I earn from qualifying purchases.

Watch the NFC water refill walkthrough on YouTube.

Advertisement

Keep building

The next useful idea, in your inbox.

Get new vCloudInfo posts by email.

Get new posts