Skip to content

Instantly share code, notes, and snippets.

@unlobito
Created September 19, 2024 13:36
Show Gist options
  • Save unlobito/e96e84d5df966392b317af8fa41e9e07 to your computer and use it in GitHub Desktop.
Save unlobito/e96e84d5df966392b317af8fa41e9e07 to your computer and use it in GitHub Desktop.
esphome:
name: kitchen-esp32display
esp32:
board: lolin32
framework:
type: esp-idf #arduino
version: recommended
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32Test Fallback Hotspot"
password: !secret wifi_ap_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
platform: esphome
password: !secret api_password
time:
- platform: homeassistant
id: esptime
esp32_ble_tracker:
# scan_parameters:
# interval: 150ms
# window: 100ms
# active: false
bluetooth_proxy:
active: True
sensor:
- platform: homeassistant
id: home_instant_electricity
entity_id: sensor.smart_meter_electricity_power
internal: true
- platform: homeassistant
id: octopus_current_price
entity_id: sensor.octopus_energy_electricity_x_x_current_rate
internal: true
on_value_range:
- above: 0.20
then:
- light.control:
id: ws2812
state: true
brightness: 60%
red: !lambda |-
return (id(octopus_current_price).state-0.20) / 0.10;
green: 0
blue: 0
effect: "none"
- above: 0.10
below: 0.20
then:
- light.control:
id: ws2812
state: true
brightness: 60%
red: !lambda |-
return (id(octopus_current_price).state-0.10) / 0.10;
green: !lambda |-
return (id(octopus_current_price).state-0.10) / 0.10;
blue: 0
effect: "none"
- above: 0.0
below: 0.10
then:
- light.control:
id: ws2812
state: true
brightness: 60%
red: 0
green: !lambda |-
return (id(octopus_current_price).state-0.0) / 0.10;
blue: 0
effect: "none"
- below: 0.0
then:
- light.control:
id: ws2812
state: true
brightness: 60%
red: 0
green: 0
blue: 1
effect: "strobe"
font:
- file: "Arial.ttf"
id: font1
size: 14
i2c:
sda: 5
scl: 4
scan: True
frequency: 400kHz
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
contrast: "80%"
#reset_pin: D0
id: my_display
address: 0x3C
pages:
- id: page1
lambda: |-
it.clear();
// Print time in HH:MM format in top center.
if (id(home_instant_electricity).has_state()) {
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER , "%.3fkW", id(home_instant_electricity).state);
}
if (id(octopus_current_price).has_state()) {
it.printf(64, 16, id(font1), TextAlign::TOP_CENTER , "%.4fp-kWh", id(octopus_current_price).state);
}
// if (id(electricity_current_cost).has_state()) {
// it.printf(64, 32, id(font1), TextAlign::TOP_CENTER , "GBP%.2f", id(electricity_current_cost).state);
// }
// Print time in HH:MM format
it.strftime(127, 60, id(font1), TextAlign::BASELINE_RIGHT, "%H:%M", id(esptime).now());
light:
- platform: esp32_rmt_led_strip
chipset: WS2812
id: ws2812
internal: true
pin: 15
default_transition_length: 10ms
num_leds: 1
rmt_channel: 0
rgb_order: GRB
name: "NeoPixelBus WS2812 Light"
restore_mode: ALWAYS_OFF
effects:
- strobe:
colors:
- state: True
brightness: 60%
red: 0%
green: 0%
blue: 100%
duration: 500ms
- state: True
brightness: 70%
red: 0%
green: 0%
blue: 100%
duration: 500ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment