Compare commits

..

2 commits

Author SHA1 Message Date
Mario Lang
213469defa feat: update doorbell to support multi-click 2025-08-09 15:15:40 +00:00
Mario Lang
f20540792f feat: add smart meter config 2025-08-09 12:48:25 +00:00
3 changed files with 162 additions and 47 deletions

31
common/base.yaml Normal file
View file

@ -0,0 +1,31 @@
time:
- platform: sntp
id: time_sntp
binary_sensor:
- platform: status
name: Status
id: ink_ha_connected
entity_category: diagnostic
sensor:
- platform: uptime
name: Uptime
type: timestamp
time_id: time_sntp
entity_category: diagnostic
- platform: wifi_signal
name: RSSI
update_interval: 60s
entity_category: diagnostic
button:
- platform: restart
icon: mdi:power-cycle
name: ESP Reboot
entity_category: diagnostic
text_sensor:
- platform: wifi_info
ip_address:
name: IP Address

View file

@ -5,10 +5,14 @@ esphome:
esp32:
board: esp32dev
framework:
type: esp-idf
packages: !include common/base.yaml
# Enable Home Assistant API
api:
web_server:
logger:
ota:
- platform: esphome
@ -18,15 +22,35 @@ wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
sensor:
- platform: uptime
name: Uptime
- platform: wifi_signal
name: WiFi Signal
update_interval: 10s
event:
- platform: template
name: Doorbell
id: doorbell
device_class: doorbell
event_types:
- short
- double
- long
on_event:
then:
- if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- light.turn_on:
id: ring
red: 0
green: 1
blue: 0.7
effect: pulse
- delay: 0.2s
- switch.turn_off: relay
- delay: 5s
- light.turn_off: ring
globals:
- id: chime
- id: should_ring
type: bool
restore_value: True
initial_value: 'true'
@ -42,60 +66,56 @@ switch:
name: Chime Active
restore_mode: RESTORE_DEFAULT_ON
lambda: |-
return id(chime);
return id(should_ring);
turn_on_action:
- globals.set:
id: chime
id: should_ring
value: 'true'
turn_off_action:
- globals.set:
id: chime
id: should_ring
value: 'false'
binary_sensor:
- platform: gpio
id: push_button
id: button_doorbell
internal: True
pin:
number: GPIO15
mode:
input: True
pulldown: True
filters:
- delayed_on: 50ms
- delayed_off: 8s
on_press:
then:
- light.turn_on:
id: ring
red: 0
green: 1
blue: 0.7
effect: pulse
- button.press: chime_button
on_release:
then:
- light.turn_off:
id: ring
transition_length: 1s
- platform: status
name: Status
- delayed_on: 20ms
- delayed_off: 20ms
on_multi_click:
# Single Short Click
- timing:
- ON for at most 750ms
- OFF for at least 300ms
then:
- event.trigger:
id: doorbell
event_type: short
button:
- platform: template
id: chime_button
name: Ring
icon: mdi:bell
on_press:
then:
- if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- delay: 0.3s
- switch.turn_off: relay
- platform: restart
name: Restart
# Double Click: two quick presses
- timing:
- ON for at most 750ms
- OFF for at most 300ms
- ON for at most 750ms
- OFF for at least 300ms
then:
- event.trigger:
id: doorbell
event_type: double
# Long Press only
- timing:
- ON for at least 750ms
then:
- event.trigger:
id: doorbell
event_type: long
output:
- platform: ledc
@ -125,4 +145,4 @@ light:
transition_length: 1s
update_interval: 1s
default_transition_length:
milliseconds: 200
milliseconds: 100

64
smart-meter-reader.yaml Normal file
View file

@ -0,0 +1,64 @@
esphome:
name: smart-meter
friendly_name: Smart Meter
name_add_mac_suffix: True
packages: !include common/base.yaml
esp8266:
board: d1_mini
logger:
baud_rate: 0
level: INFO
api:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: Smart Meter Fallback Hotspot
sensor:
- platform: sml
name: Total Energy Consumed
obis_code: 1-0:1.8.0
unit_of_measurement: kWh
accuracy_decimals: 1
device_class: energy
state_class: total_increasing
filters:
- multiply: 0.0001
- platform: sml
name: Current Power
obis_code: 1-0:16.7.0
unit_of_measurement: W
accuracy_decimals: 0
device_class: power
state_class: measurement
filters:
- multiply: 0.01
text_sensor:
- platform: sml
name: Manufacturer
obis_code: 1-0:96.50.1
format: text
# - platform: sml
# name: Serial Number
# obis_code: 1-0:96.1.0
# format: text
uart:
id: uart_main
tx_pin: TX
rx_pin: RX
baud_rate: 9600
sml:
uart_id: uart_main
id: sml_main