Brian Wente
Published © GPL3+

PillMinder for ESPHome

Manage pill reminders with ESPHome and Home Assistant, using a button to reset or decrement a counter and an LED for alerts.

BeginnerFull instructions provided1 hour694
PillMinder for ESPHome

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
Push Button
×1
Flashing LED, Green
Flashing LED, Green
×1

Software apps and online services

Home Assistant
Home Assistant

Story

Read more

Code

ESPHome YAML

YAML
esphome:
  name: pillminder
  friendly_name: PillMinder

esp8266:
  board: d1_mini_lite

# Enable logging
logger:

globals:
  - id: countdown_counter
    type: int
    restore_value: yes
    initial_value: '0'

# Enable Home Assistant API
api:
  encryption:
    key: "YOUR_API_ENCRYPTION_KEY"

sensor:
  - platform: template
    name: "Reminder Countdown"
    id: reminder_countdown 
    update_interval: 10s
    lambda: |-
      return id(countdown_counter);

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      mode: INPUT_PULLUP
      inverted: true
    name: "Reminder Acknowledge Button"
    internal: true  # This ensures the button state is only processed locally
    id: reminder_button
    on_press:
      then:
        - delay: 1500ms  # Wait for 1.5 seconds for long press
        - if:
            condition:
              binary_sensor.is_on: reminder_button  # Check if button is still pressed
            then:
              - lambda: |-
                  id(countdown_counter) = 100;
                  id(reminder_countdown).publish_state(id(countdown_counter));
                  id(reminder_led).turn_off();
            else:
              - lambda: |-
                  id(countdown_counter) = id(reminder_countdown).state;
                  id(countdown_counter)--;
                  id(reminder_countdown).publish_state(id(countdown_counter));
                  id(reminder_led).turn_off();

light:
  - platform: binary
    name: "Reminder LED"
    id: reminder_led
    output: reminder_led_output

output:
  - id: reminder_led_output
    platform: gpio
    pin: D4

ota:
  password: "YOUR_OTA_PASSWORD"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Pillminder Fallback Hotspot"
    password: "YOUR_HOTSPOT_PASSWORD"

captive_portal:

Credits

Brian Wente
6 projects • 8 followers
Contact

Comments

Please log in or sign up to comment.