mirror of
https://github.com/nuttytree/ESPHome-Devices.git
synced 2024-08-30 18:12:19 +00:00
Add coffee maker
This commit is contained in:
parent
4b9e559291
commit
bba03c156d
141
coffee_maker.yaml
Normal file
141
coffee_maker.yaml
Normal file
@ -0,0 +1,141 @@
|
||||
substitutions:
|
||||
device_id: coffee_maker
|
||||
device_name: Coffee Maker
|
||||
platform: ESP8266
|
||||
board: nodemcuv2
|
||||
|
||||
esphome:
|
||||
<<: !include common/esphome.yaml
|
||||
|
||||
<<: !include common/common.yaml
|
||||
<<: !include common/logger.yaml
|
||||
|
||||
binary_sensor:
|
||||
<<: !include common/binary_sensors.yaml
|
||||
- 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;
|
||||
}
|
||||
|
||||
sensor:
|
||||
<<: !include common/sensors.yaml
|
||||
|
||||
switch:
|
||||
<<: !include common/switches.yaml
|
||||
- platform: template
|
||||
id: power_switch
|
||||
name: "Coffee Maker"
|
||||
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"
|
||||
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
|
||||
|
||||
text_sensor:
|
||||
<<: !include common/text_sensors.yaml
|
@ -1,2 +1 @@
|
||||
---
|
||||
<<: !include ../secrets.yaml
|
Loading…
Reference in New Issue
Block a user