bookkeeping
This commit is contained in:
198
utilities2a (2).yaml
Normal file
198
utilities2a (2).yaml
Normal file
@ -0,0 +1,198 @@
|
||||
|
||||
|
||||
substitutions:
|
||||
device_name: utilities2
|
||||
friendly_name: um2
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
project:
|
||||
name: d1.utilities-meter
|
||||
version: "1.0.0"
|
||||
name_add_mac_suffix: true
|
||||
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
restore_from_flash: true
|
||||
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret api_encryption_key
|
||||
reboot_timeout: 30min
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
manual_ip:
|
||||
static_ip: 192.168.1.171
|
||||
gateway: 192.168.1.254
|
||||
subnet: 255.255.255.0
|
||||
dns1: 192.168.1.1
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: !secret ap_ssid
|
||||
password: !secret ap_password
|
||||
|
||||
captive_portal:
|
||||
|
||||
web_server:
|
||||
port: 80
|
||||
ota:
|
||||
- platform: !secret ota_platform
|
||||
password: !secret ota_password
|
||||
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO02
|
||||
inverted: true
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
|
||||
i2c:
|
||||
sda: GPIO04
|
||||
scl: GPIO05
|
||||
scan: true
|
||||
id: bus_a
|
||||
frequency: 400kHz
|
||||
# Display configuration (SSD1306 128x64 OLED)
|
||||
display:
|
||||
- platform: ssd1306_i2c
|
||||
model: "SH1106 128x32"
|
||||
address: 0x3C
|
||||
id: my_display
|
||||
update_interval: 0.5s
|
||||
lambda: |-
|
||||
it.clear();
|
||||
it.printf(0, 0, id(fontPPT), "Menu: %s",
|
||||
id(menu_level) == 1 ? "Status" :
|
||||
id(menu_level) == 2 ? "Settings" : "Overview");
|
||||
|
||||
// Content for each menu level
|
||||
if (id(menu_level) == 1) {
|
||||
it.printf(0, 11, id(fontBody), "Uptime: %ds", (int)(millis() / 1000));
|
||||
it.printf(0, 22, id(fontBody), "Uptime: %ds", (int)(millis() / 1000));
|
||||
it.printf(0, 32, id(fontBody), "Uptime: %ds", (int)(millis() / 1000));
|
||||
} else if (id(menu_level) == 2) {
|
||||
it.clear();
|
||||
//it.printf(0, 1, id(fontBody), "BLmax_time2run: %ds", id(BLmax_time2run));
|
||||
//it.printf(0, 12, id(fontBody), "BLruntime: %ds", id(BLruntime));
|
||||
//it.printf(0, 23, id(fontBody), "BLruntimeX: %ds", id(BLruntimeX));
|
||||
// it.printf(0, 11, id(fontBody), "WiFi: %.0f dBm", 22.0);
|
||||
} else {
|
||||
it.printf(0, 11, id(fontBody), "Button: %s", id(display_button).state ? "Pressed" : "Released");
|
||||
}
|
||||
# Button configuration
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO013
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
name: "Display Button"
|
||||
id: display_button
|
||||
on_press:
|
||||
- logger.log: "Button pressed"
|
||||
- lambda: |-
|
||||
if (id(oled_on)==true){// als oled aan is dan pas door het menu stappen
|
||||
id(menu_level) = (id(menu_level) % 3) + 1; // Cycle through 1, 2, 3
|
||||
}
|
||||
id(my_display).update(); // Force display update
|
||||
- script.execute: reset_oled_timeout #start de displaytijd opnieuw
|
||||
filters:
|
||||
- delayed_on: 30ms
|
||||
- delayed_off: 30ms
|
||||
light:
|
||||
- platform: monochromatic
|
||||
name: displayBL
|
||||
id: displayBL
|
||||
output: my_display1
|
||||
# restore_mode: ALWAYS_ON
|
||||
initial_state:
|
||||
state: true
|
||||
on_turn_on:
|
||||
- logger.log:
|
||||
format: "Display On begin: %d"
|
||||
args: [ 'id(oled_on)' ]
|
||||
# - lambda: id(my_display).turn_on();
|
||||
- script.execute: reset_oled_timeout
|
||||
|
||||
on_turn_off:
|
||||
then:
|
||||
- logger.log:
|
||||
format: "Display Off: %d"
|
||||
args: [ 'id(oled_on)' ]
|
||||
- lambda: id(my_display).turn_off();
|
||||
globals:
|
||||
- id: oled_on
|
||||
type: bool
|
||||
restore_value: no
|
||||
initial_value: "true"
|
||||
- id: menu_level
|
||||
type: int
|
||||
restore_value: no
|
||||
initial_value: '1' # Start at Status menu
|
||||
|
||||
interval:
|
||||
- interval: 5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- not:
|
||||
- script.is_running: oled_timeout
|
||||
then:
|
||||
- script.execute: oled_timeout
|
||||
|
||||
script:
|
||||
- id: reset_oled_timeout
|
||||
then:
|
||||
- lambda: |-
|
||||
id(oled_on) = true;
|
||||
- light.turn_on: displayBL #synchronize the button in HA
|
||||
- lambda: id(my_display).turn_on();
|
||||
- script.stop: oled_timeout
|
||||
- script.execute: oled_timeout
|
||||
|
||||
- id: oled_timeout
|
||||
mode: restart
|
||||
then:
|
||||
- delay: 5s
|
||||
- lambda: |-
|
||||
id(oled_on) = false;
|
||||
# id(displayBL).publish_state(false);
|
||||
- lambda: id(my_display).turn_off();
|
||||
- light.turn_off: displayBL #synchronize the button in HA
|
||||
|
||||
output:
|
||||
- platform: template
|
||||
id: my_display1
|
||||
type: float
|
||||
write_action:
|
||||
then:
|
||||
- lambda: id(my_display).set_contrast(state);
|
||||
|
||||
text_sensor:
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: "IP Address"
|
||||
ssid:
|
||||
name: "WiFi SSID"
|
||||
bssid:
|
||||
name: "WiFi BSSID"
|
||||
|
||||
- platform: version
|
||||
name: "ESPHome Version"
|
||||
hide_timestamp: false
|
||||
|
||||
# Font for display
|
||||
font:
|
||||
- file: "fonts/Helvetica.ttf" # You'll need to upload this font file
|
||||
id: fontPPT
|
||||
size: 12
|
||||
- file: "fonts/Helvetica.ttf" # You'll need to upload this font file
|
||||
id: fontBody
|
||||
size: 10
|
Reference in New Issue
Block a user