#######################################################################
# Substitutions - use like $substitution_key or ${substitution_key}
#######################################################################
substitutions:
# Project Name, upper/lowercase characters, digits and underscores.
# Used as: hostname, mdns name, folder name
project_name: 'esp-wh'
project_id: 'esp_wh'
# Used as: AP SSID, Common (Wifi, Uptime, Switch) Sensors
friendly_name: 'esp Waschhaus'
# Wifi Configuration
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
static_ip: 192.168.1.161
# AP (Access Point) Configuration
ap_password: !secret ap_password
ap_channel: '6'
ap_timeout: '5min'
# API Configuration
api_password: !secret api_password
# OTA Configuration
ota_password: !secret ota_password
# Log Level
log_level: DEBUG
# which sensor to use for puls detection
magnetometer: "${project_id}_qmc5883ly"
#######################################################################
# Device config
#######################################################################
esphome:
name: ${project_name}
esp8266:
board: d1_mini
#######################################################################
# Include common config
#######################################################################
packages:
common: !include common/common.yaml
wifi_sensors: !include common/wifi.diag.yaml
uptime: !include common/uptime.diag.yaml
preferences:
flash_write_interval: 3min
i2c:
scan: true # Default true
frequency: 100kHz # Default 50kHz. Values: 10kHz, 50kHz, 100kHz, 200kHz, … 800kHz
# Dallas Temp. Sensoren, Dreibein
dallas:
- pin: D4
# global variables
globals:
- id: gas_counter_total
type: double
restore_value: no
# initial_value: '2717.94'
- id: gas_counter
type: int
restore_value: no
initial_value: '0'
- id: gas_high
type: bool
restore_value: no
initial_value: 'false'
- id: magnetometer_last_value
type: int
restore_value: no
- id: heating
type: bool
restore_value: no
- id: heating_paused
type: bool
restore_value: no
# run actions at fixed time intervals
interval:
- interval: 5s
then:
# convert magnetometer values to boolean gas_hight for counting pulses.
# adapt numbers regarding your measured values
- lambda: |-
if (id($magnetometer).state >= 500 && !id(gas_high)) {
id(gas_counter_total) += 0.01;
id(gas_counter) += 1;
id(gas_high) = true;
ESP_LOGD("Gas", "+1");
} else if (id($magnetometer).state <= 150 && id(gas_high)) {
id(gas_high) = false;
}
- interval: 10s
then:
# boolean sensor for heating on/off to show when burner is on
# ESP_LOGD("Gas", "+1");
- lambda: |-
// ESP_LOGI("Gas", "letzter Wert: %d", int(id(magnetometer_last_value)))
// ESP_LOGI("Gas", " aktuel. Wert: %d", int(id(${magnetometer}_delta).state));
if (int(id(magnetometer_last_value)) == int(id(${magnetometer}_delta).state)) {
if (id(heating_paused)) {
id(${project_id}_heating).publish_state(false);
}else{
id(heating_paused) = true;
}
} else {
id(heating_paused) = false;
id(${project_id}_heating).publish_state(true);
}
id(magnetometer_last_value) = id(${magnetometer}_delta).state;
binary_sensor:
# burner on/of
- platform: template
name: "${friendly_name} - Heizung heizt"
id: ${project_id}_heating
icon: 'mdi:fire'
device_class: heat
sensor:
# Dallas Temperatur Sensor
# Waschhaus, Gasleitung
- platform: dallas
address: 0xf200000a304a6328
id: ${project_id}_ds18b20_gas
name: "${friendly_name} - Temperatur Gasleitung"
device_class: temperature
unit_of_measurement: "°C"
# Magnetometer / Gasmeter
# there are similar sensors - hmc5883l and qmc5883l
# if it looks like a hmc5883l, but dont work consider it may be a qmc5883l
- platform: qmc5883l
address: 0x0D
# Gasmeter X
field_strength_x:
name: "${friendly_name} - Gasmeter X"
id: ${project_id}_qmc5883lx
accuracy_decimals: 0
filters:
- multiply: -1
# Gasmeter Y
field_strength_y:
name: "${friendly_name} - Gasmeter Y"
id: ${project_id}_qmc5883ly
accuracy_decimals: 0
filters:
- multiply: -1
# Gasmeter Z
field_strength_z:
name: "${friendly_name} - Gasmeter Z"
id: ${project_id}_qmc5883lz
accuracy_decimals: 0
filters:
- multiply: -1
oversampling: 64x
range: 800uT
update_interval: 1s
# Gasfluss für An/Aus Erkennung
# ich habe versucht, hier einen möglichst eindeutigen Impuls zu bekommen, ohne Impulse zu verpassen, wenn er sich schnell dreht.
# Wenn der Magnet an einer ungünstigen Stelle stehen bleibt, wackelt der Wert furchtbar herum.
# ausprobieren!
- platform: template
name: "${friendly_name} - Gasmeter Y Delta"
id: ${magnetometer}_delta
lambda: |-
return id($magnetometer).state/2;
update_interval: 2s
accuracy_decimals: 0
icon: 'mdi:fire'
device_class: gas
state_class: measurement
unit_of_measurement: "uT"
filters:
- max:
# window_size: 3
# send_every: 5
# send_first_at: 3
- delta: 5
# Gas Durchfluss/min
- platform: template
name: "${friendly_name} - Gas Durchfluss"
id: ${project_id}_gas_momentan
lambda: |-
int temp = id(gas_counter);
id(gas_counter) -= temp;
return temp;
update_interval: 60s
unit_of_measurement: "Pulse"
# Gas gesamt
- platform: template
name: "${friendly_name} - Gas Gesamt"
id: "${project_id}_gas_total"
lambda: |-
return id(gas_counter_total);
update_interval: 600s
unit_of_measurement: "m³"
accuracy_decimals: 2
icon: 'mdi:fire'
device_class: gas
state_class: total_increasing
# Gas kWh
- platform: template
name: "${friendly_name} - Gas kWh"
id: "${project_id}_gas_kwh"
# Gasvolumen in m³ x Zustandszahl x Brennwert = Gasverbrauch in kWh
# Zustandszahl: 0.8934
# Brennwert Flüssiggas: 25,88
filters:
lambda: |-
return (id(gas_counter_total) * (25.88));
update_interval: 5s
unit_of_measurement: "kWh"
accuracy_decimals: 2
icon: 'mdi:fire'
device_class: energy
state_class: total_increasing
# Gas Liter
# 1 m³ = 3,93 Liter
- platform: template
name: "${friendly_name} - Gas Liter"
id: "${project_id}_gas_liter"
filters:
lambda: |-
return (id(gas_counter_total) * (3.93));
update_interval: 60s
unit_of_measurement: "L"
accuracy_decimals: 2
icon: 'mdi:waves'
device_class: gas
state_class: total_increasing