mirror of
https://github.com/nuttytree/ESPHome-Devices.git
synced 2024-08-30 18:12:19 +00:00
136 lines
4.0 KiB
YAML
136 lines
4.0 KiB
YAML
substitutions:
|
|
device_id: coffee-maker
|
|
device_name: Coffee Maker
|
|
board: nodemcuv2
|
|
ip_address: !secret coffee-maker-ip
|
|
ota_pwd: !secret coffee-maker-ota-pwd
|
|
api_pwd: !secret coffee-maker-api-pwd
|
|
ap_wifi_pwd: !secret coffee-maker-ap-pwd
|
|
|
|
packages:
|
|
device_base: !include ../packages/device_base_esp8266.yaml
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
id: power_light
|
|
pin:
|
|
number: D5
|
|
mode: INPUT
|
|
inverted: True
|
|
filters:
|
|
- delayed_on: 50ms
|
|
- delayed_off: 50ms
|
|
- platform: gpio
|
|
id: bold_light
|
|
pin:
|
|
number: D6
|
|
mode: INPUT
|
|
inverted: True
|
|
filters:
|
|
- delayed_on: 50ms
|
|
- delayed_off: 50ms
|
|
|
|
interval:
|
|
- interval: 1s
|
|
then:
|
|
- lambda: |-
|
|
// Coffee tastes better if allowed to "bloom" (wet the coffee and then let it sit for 30 seconds to release any trapped CO2 before completing brewing)
|
|
// This logic automates this process regardless of how the coffee maker was turned on
|
|
static int brewStage = 0; // 0=Off, 1=Pre-Wet, 2=Bloom, 3=Brew
|
|
static unsigned long brewStageChange = 0;
|
|
static bool isBoldBrew = false;
|
|
|
|
// Coffee maker was off but now is on so it is in the pre-wet stage
|
|
if (id(power_switch).state && brewStage == 0) {
|
|
brewStage = 1; //Pre-Wet
|
|
brewStageChange = millis() + 75000;
|
|
isBoldBrew = id(bold_switch).state;
|
|
}
|
|
|
|
// Coffee should be wet now so turn off and let it bloom
|
|
else if (id(power_switch).state && brewStage == 1 && millis() >= brewStageChange) {
|
|
id(power_switch).turn_off();
|
|
brewStage = 2; //Bloom
|
|
brewStageChange = millis() + 45000;
|
|
}
|
|
|
|
// Coffee has bloomed so turn back on to finish brewing
|
|
else if (!id(power_switch).state && brewStage == 2 && millis() >= brewStageChange) {
|
|
if (isBoldBrew && !id(bold_switch).state) {
|
|
id(bold_switch).turn_on();
|
|
}
|
|
id(power_switch).turn_on();
|
|
brewStage = 3; //Brew
|
|
}
|
|
|
|
// Manually powered off during Pre-Wet stage
|
|
else if (!id(power_switch).state && brewStage == 1) {
|
|
brewStage = 0;
|
|
}
|
|
|
|
// Manualy powered on during Bloom stage
|
|
else if (id(power_switch).state && brewStage == 2) {
|
|
brewStage = 3;
|
|
}
|
|
|
|
// Done brewing
|
|
else if (!id(power_switch).state && brewStage == 3) {
|
|
brewStage = 0;
|
|
}
|
|
|
|
switch:
|
|
- platform: template
|
|
id: power_switch
|
|
name: "Coffee Maker"
|
|
icon: mdi:coffee
|
|
lambda: 'return id(power_light).state;'
|
|
turn_on_action:
|
|
then:
|
|
- lambda: |-
|
|
if (!id(power_light).state) {
|
|
id(power_switch_physical).turn_on();
|
|
delay(200);
|
|
id(power_switch_physical).turn_off();
|
|
delay(100);
|
|
}
|
|
turn_off_action:
|
|
then:
|
|
- lambda: |-
|
|
if (id(power_light).state) {
|
|
id(power_switch_physical).turn_on();
|
|
delay(200);
|
|
id(power_switch_physical).turn_off();
|
|
delay(100);
|
|
}
|
|
- platform: gpio
|
|
id: power_switch_physical
|
|
pin: D0
|
|
inverted: true
|
|
- platform: template
|
|
id: bold_switch
|
|
name: "Coffee Maker Bold Setting"
|
|
icon: mdi:coffee
|
|
lambda: 'return id(bold_light).state;'
|
|
turn_on_action:
|
|
then:
|
|
- lambda: |-
|
|
if (!id(bold_light).state) {
|
|
id(bold_switch_physical).turn_on();
|
|
delay(200);
|
|
id(bold_switch_physical).turn_off();
|
|
delay(100);
|
|
}
|
|
turn_off_action:
|
|
then:
|
|
- lambda: |-
|
|
if (id(bold_light).state) {
|
|
id(bold_switch_physical).turn_on();
|
|
delay(200);
|
|
id(bold_switch_physical).turn_off();
|
|
delay(100);
|
|
}
|
|
- platform: gpio
|
|
id: bold_switch_physical
|
|
pin: D1
|
|
inverted: true
|