Hello there,
I made a semi smart water bottle with an esp8266-12, mercury switch, Li-Po battery and charging circuit. It all fits in a 3D-printed ring sleeve around the bottle and can be charged with micro USB. Basically, all it does is register an “on” state in a binary sensor when you flip the bottle, which get counted, thus logging how many times I drink water every day. And it also notifies me if I am not drinking enough.
ESPHome:
esphome:
name: water_bottle
platform: ESP8266
board: esp01_1m
wifi:
ssid: "SSID HERE"
password: "PASSWORD HERE"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Water Bottle Fallback Hotspot"
password: "FALLBACK PWD"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: 9
mode: INPUT_PULLUP
name: "Water Bottle Tilt Sensor"
filters:
- delayed_on: 200ms
sensor:
- platform: adc
pin: VCC
name: "Water Bottle Battery Voltage"
update_interval: 600s
Counter in configuration.yaml:
counter:
water_drinking:
initial: 0
step: 1
minimum: 0
Automattions:
- alias: Water Counting
trigger:
platform: state
entity_id:
- binary_sensor.water_bottle_tilt_sensor
to: 'on'
action:
service: counter.increment
target:
entity_id: counter.water_drinking
- alias: Reset water drinking counter every hour
trigger:
platform: time_pattern
minutes: 2
action:
- service: counter.reset
entity_id: counter.water_drinking
- alias: Notify when time to drink water
trigger:
platform: time_pattern
minutes: 1
condition:
condition: and
conditions:
- condition: state
entity_id: person.me
state: home
- condition: numeric_state
entity_id: counter.water_drinking
below: 5
- condition: time
after: "06:00:00"
before: "23:59:59"
action:
- service: notify.mobile_app_my_mobile
data:
message: "Drink Water! You only had {{states.counter.water_drinking.state}} zips"
data:
ttl: 0
priority: high
importance: high