Skip to content

Commit

Permalink
Create sl32.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
zuidwijk authored Oct 10, 2022
1 parent 718ffcd commit 3ce0971
Showing 1 changed file with 165 additions and 0 deletions.
165 changes: 165 additions & 0 deletions sl32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
substitutions:
device_name: sl32
device_description: "DIY P1 module to read your smart meter"

esphome:
name: ${device_name}
comment: "${device_description}"
name_add_mac_suffix: false
project:
name: zuidwijk.slimmelezer
version: "2.0"
on_boot:
then:
- if:
condition:
lambda: return id(has_key);
then:
- lambda: |-
std::string key(id(stored_decryption_key), 32);
id(dsmr_instance).set_decryption_key(key);
else:
- logger.log:
level: info
format: "Not using decryption key. If you need to set a key use Home Assistant service 'ESPHome: ${device_name}_set_dsmr_key'"

esp32:
board: esp32dev
framework:
type: arduino

# Enable logging
logger:
baud_rate: 115200

# Enable Home Assistant API
api:
services:
service: set_dsmr_key
variables:
private_key: string
then:
- logger.log:
format: Setting private key %s. Set to empty string to disable
args: [private_key.c_str()]
- globals.set:
id: has_key
value: !lambda "return private_key.length() == 32;"
- lambda: |-
if (private_key.length() == 32)
private_key.copy(id(stored_decryption_key), 32);
id(dsmr_instance).set_decryption_key(private_key);
ota:

dashboard_import:
package_import_url: github://zuidwijk/slimmelezer-wt32-eth01/sl32.yaml@main

uart:
id: uart_dsmr
baud_rate: 115200
rx_pin: GPIO5
rx_buffer_size: 1700

web_server:
port: 80

ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 1
power_pin: GPIO16

globals:
- id: has_key
type: bool
restore_value: yes
initial_value: "false"
- id: stored_decryption_key
type: char[32]
restore_value: yes

dsmr:
uart_id: uart_dsmr
id: dsmr_instance
max_telegram_length: 1700
# For Luxembourg users set here your decryption key
#decryption_key: !secret decryption_key // enable this when using decryption for Luxembourg; key like '00112233445566778899AABBCCDDEEFF'

sensor:
- platform: dsmr
energy_delivered_lux:
name: "Energy Consumed Luxembourg"
energy_delivered_tariff1:
name: "Energy Consumed Tariff 1"
energy_delivered_tariff2:
name: "Energy Consumed Tariff 2"
energy_returned_lux:
name: "Energy Produced Luxembourg"
energy_returned_tariff1:
name: "Energy Produced Tariff 1"
energy_returned_tariff2:
name: "Energy Produced Tariff 2"
power_delivered:
name: "Power Consumed"
accuracy_decimals: 3
power_returned:
name: "Power Produced"
accuracy_decimals: 3
electricity_failures:
name: "Electricity Failures"
icon: mdi:alert
electricity_long_failures:
name: "Long Electricity Failures"
icon: mdi:alert
voltage_l1:
name: "Voltage Phase 1"
voltage_l2:
name: "Voltage Phase 2"
voltage_l3:
name: "Voltage Phase 3"
current_l1:
name: "Current Phase 1"
current_l2:
name: "Current Phase 2"
current_l3:
name: "Current Phase 3"
power_delivered_l1:
name: "Power Consumed Phase 1"
accuracy_decimals: 3
power_delivered_l2:
name: "Power Consumed Phase 2"
accuracy_decimals: 3
power_delivered_l3:
name: "Power Consumed Phase 3"
accuracy_decimals: 3
power_returned_l1:
name: "Power Produced Phase 1"
accuracy_decimals: 3
power_returned_l2:
name: "Power Produced Phase 2"
accuracy_decimals: 3
power_returned_l3:
name: "Power Produced Phase 3"
accuracy_decimals: 3
gas_delivered:
name: "Gas Consumed"
gas_delivered_be:
name: "Gas Consumed Belgium"
- platform: uptime
name: "SlimmeLezer Uptime"


text_sensor:
- platform: dsmr
identification:
name: "DSMR Identification"
p1_version:
name: "DSMR Version"
p1_version_be:
name: "DSMR Version Belgium"
- platform: version
name: "ESPHome Version"
hide_timestamp: true

0 comments on commit 3ce0971

Please sign in to comment.