The Essence Vault Ceramic Electric Diffuser - ESPHome + D1 Mini

Using Inspiration from here for wiring:

I have managed to make my dumb diffuser into a smart one with a D1 Mini + ESPHome!

Parts (so far)
Wemos D1 Mini
100 ohm resistor
Wire
Optocoupler PC817

Working:
On (mimics 1 button press)
Off (mimics a further 4 button presses)
ON/OFF State (Reads Voltage via ADC pin to + pin on Ultrasonic Disc)

To do (help appreciated)
LED control (runs off a rotary encoder - need to work out how to mimic the output of this with the D1 mini to control LED light)

ESPHome Code:

## ---------------------------------------------------
## ESPHome
## ---------------------------------------------------
esphome:
  name: fragrance-diffuser
  friendly_name: fragrance-diffuser

esp8266:
  board: esp01_1m
## ---------------------------------------------------
## Log Settings
## ---------------------------------------------------
logger:
  level: DEBUG
## ---------------------------------------------------
## Home Assistant API
## ---------------------------------------------------
api:
  encryption:
    key: "here"
## ---------------------------------------------------
## Enable OTA
## ---------------------------------------------------
ota:
  - platform: esphome
    password: "here"
## ---------------------------------------------------
## WIFI Settings
## ---------------------------------------------------
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Fragrance-Diffuser"
    password: "here"

captive_portal:
## ---------------------------------------------------
## Web Server
## ---------------------------------------------------
web_server:
  port: 80
  version: 3
## ---------------------------------------------------
## GPIO Relay Switch + Template Switch
## ---------------------------------------------------
switch:
  - platform: gpio
    pin: GPIO4
    name: "ON/OFF"
    icon: 'mdi:light-switch'
    internal: True
    id: relay
    on_turn_on:
    - delay: 100ms
    - switch.turn_off: relay

  - platform: template
    name: "ON/OFF Switch"
    icon: 'mdi:scent'
    lambda: |-
      if (id(binary_switch).state) {
        return true;
      } else {
        return false;
      }
    id: on_cycle
    turn_on_action:
    - switch.turn_on: relay
    turn_off_action:
      then:
        - if:
            condition:
               binary_sensor.is_on: binary_switch
            then:
              - switch.turn_on: relay
              - delay: 500ms
              - switch.turn_on: relay
              - delay: 500ms
              - switch.turn_on: relay
              - delay: 500ms
              - switch.turn_on: relay
## ---------------------------------------------------
## Voltage Sensor
## ---------------------------------------------------
binary_sensor:
  - platform: template
    name: "ON/OFF Status"
    icon: 'mdi:power'
    id: binary_switch

sensor:
  - platform: adc
    id: sensor_adc
    pin: A0
    internal: True
    update_interval: 5s
    filters:
      - multiply: 3.3
    on_value_range:
      - above: 0.01
        then:
        - binary_sensor.template.publish:
            id: binary_switch
            state: ON
      - below: 0.01
        then:
        - binary_sensor.template.publish:
            id: binary_switch
            state: OFF

I will add more photos and information on wiring later

Any help with how to control LED light would be great! Plan on measuring remaining pins on the rotary encoder to see what they read when being turned.

2 Likes