Skip to content

Instantly share code, notes, and snippets.

@grischard
Created December 5, 2021 01:01
Show Gist options
  • Save grischard/9d57ed32473fe5c05b22dd290cecf8b0 to your computer and use it in GitHub Desktop.
Save grischard/9d57ed32473fe5c05b22dd290cecf8b0 to your computer and use it in GitHub Desktop.
dishwasher s31 esphome
# Dishwasher is a Sonoff S31
substitutions:
device: dishwasher
name: Dishwasher
reboot_timeout: 1h
update_interval: 60s
delayed_on_off: 100ms
esphome:
name: ${device}
platform: ESP8266
board: esp01_1m
<<: !include common/common.yaml
#<<: !include common/logger.yaml
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
# Component sensor.cse7766 requires component uart.
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- !include common/binary_sensor/status.yaml
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "${name} Button"
on_press:
- switch.toggle: fakebutton
- platform: template
name: "${name} done"
id: bin_done
# filters:
# - delayed_off: 15s
# lambda: |-
# if (isnan(id(power).state)) {
# return {};
# } else if (id(power).state < 4) {
# // Finito
# return true;
# } else {
# // Running
# return false;
# }
switch:
- platform: template
name: "${name} Relay"
optimistic: true
id: fakebutton
turn_on_action:
- switch.turn_on: relay
- light.turn_on: blue_led
turn_off_action:
- switch.turn_off: relay
- light.turn_off: blue_led
- platform: gpio
id: relay
pin: GPIO12
restore_mode: ALWAYS_ON
output:
- platform: esp8266_pwm
id: pow_blue_led
pin:
number: GPIO13
light:
- platform: monochromatic
name: "${name} Blue LED"
output: pow_blue_led
id: blue_led
sensor:
- !include common/sensor/wifi-signal.yaml
- !include common/sensor/uptime.yaml
# Power sensor
- platform: cse7766
# Current sensor
current:
name: ${name} current
unit_of_measurement: A
accuracy_decimals: 3
# Voltage sensor
voltage:
name: ${name} voltage
unit_of_measurement: V
accuracy_decimals: 1
# Power sensor
power:
id: power
name: ${name} power
unit_of_measurement: W
accuracy_decimals: 0
on_value_range:
- above: 4.0
then:
- light.turn_on: blue_led
- below: 3.0
then:
- light.turn_off: blue_led
- delay: 61s
- if:
condition:
for:
time: 2min
condition:
sensor.in_range:
id: power
below: 3.0
then:
- binary_sensor.template.publish:
id: bin_done
state: ON
- delay: 15s
- binary_sensor.template.publish:
id: bin_done
state: OFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment