Files
esphome/test_esplan.yaml
Paweł Szafer ddb23d6057 add multiclick
2022-08-03 07:34:10 +02:00

189 lines
4.1 KiB
YAML

substitutions:
devicename: wt32
esphome:
name: ${devicename}
platform: ESP32
board: esp-wrover-kit
on_boot:
then:
ds1307.read_time:
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 1
power_pin: GPIO16
id: eth
external_components:
- source: github://ell249/esphome-PCT2075@master
components: [ pct2075 ]
- source: github://btomala/esphome-LM75@v1
components: [ lm75 ]
font:
- file: "fonts/DejaVuSans.ttf"
id: fontSmall
size: 9
- file: "fonts/danube__.ttf"
id: danube
size: 15
logger:
level: DEBUG
baud_rate: 0 #Important. You can't use serial port
api:
ota:
web_server:
port: 80
i2c:
- id: bus_b
sda: 14
scl: 15
scan: true
time:
- platform: ds1307
update_interval: never
- platform: homeassistant
on_time_sync:
then:
ds1307.write_time:
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
address: 0x3C
id: my_display
pages:
- id: page1
lambda: |-
it.print(3, 3, id(danube), "bone");
it.print(53, 3, id(danube), "iO");
it.print(3, 22, id(fontSmall), "Host: ${devicename}");
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
it.printf(3, 32, id(fontSmall), "IP Address: 192.168.1.1");
it.printf(3, 42, id(fontSmall), "Uptime: %s", (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str());
- id: page2
lambda: |-
it.printf(0, 0, id(fontSmall), "MCP1_1: %s", id(switch_mcp_out1_1).state ? "ON" : "OFF");
it.print(0, 10, id(fontSmall), "This is page 2!");
sensor:
- platform: mcp9808
name: "Living Room Temperature"
update_interval: 60s
- platform: uptime
id: uptime_sensor
- platform: lm75
id: temperature
name: "Board temperature measurement"
update_interval: 60s
address: 0x48
# sensor:
# it.printf(3, 32, id(fontSmall), "Wi-Fi: %.1s", id(eth).state);
# - platform: pct2075
# address: 0x18
# temperature:
# name: "PCT2075 Temperature"
# update_interval: 30s
mcp23017:
- id: 'mcp23017_out1'
address: 0x20
- id: 'mcp23017_out2'
address: 0x21
- id: 'mcp23017_out3'
address: 0x22
- id: 'mcp23017_out4'
address: 0x23
# # Individual outputs
switch:
- platform: gpio
id: switch_mcp_out1_1
name: "MCP23017 Pin A0"
pin:
mcp23xxx: mcp23017_out1
number: 0
mode:
output: true
inverted: false
- platform: gpio
name: "MCP23017_1 Pin A0"
pin:
mcp23xxx: mcp23017_out2
number: 0
mode:
output: true
inverted: false
# # Individual inputs
binary_sensor:
- platform: gpio
id: internal_button
pin:
number: GPIO4
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 10ms
on_press:
then:
- display.page.show_next: my_display
- platform: gpio
id: binary_sensor1
name: "MCP23017 Pin A0"
pin:
mcp23xxx: mcp23017_out4
number: 0
mode:
output: false
inverted: false
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 0.3s
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.turn_on: switch_mcp_out1_1
- logger.log: "Double-Clicked"
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- switch.toggle: switch_mcp_out1_1
- logger.log: "Single-Clicked"
# name: "MCP23017 Pin B7"
# pin:
# mcp23xxx: mcp23017_hub
# # Use pin B7
# number: 15
# # One of INPUT or INPUT_PULLUP
# mode:
# input: true
# pullup: true
# inverted: false