Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Kannst du mal deinen code posten.Hab aber schon das Problem am Tag.
# which sensor to use for puls detection
magnetometer: "${project_id}_qmc5883ly"
#######################################################################
# Device config
#######################################################################
esphome:
name: ${project_name}
esp32:
board: esp32dev
framework:
type: arduino
#######################################################################
# 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
# global variables
globals:
- id: gas_counter_total
type: double
restore_value: no
initial_value: '20184.14'
- 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.10;
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:
# 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
# Gasmeter Y
field_strength_y:
name: "${friendly_name} - Gasmeter Y"
id: ${project_id}_qmc5883ly
accuracy_decimals: 0
filters:
- multiply: -1
# Gasmeter Z
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.96 (alt: 0.8934)
# Brennwert Flüssiggas: 11,474 (alt: 25,88)
filters:
lambda: |-
return (id(gas_counter_total) * (11.47) * (0.96));
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
type: custom:mini-graph-card
entities:
- entity: sensor.esp_waschhaus_gas_durchfluss
name: Pulse je10min/6h
show:
graph: bar
icon: false
name: true
state: true
hour24: true
aggregate_func: sum
group_by: interval
hours_to_show: 6
points_per_hour: 6
card_mod:
style: |
rect.bar:nth-of-type(6n) {
fill: #FFC107;
}
rect.bar:last-of-type {
fill: red;
}
Nö, denn das sind globale ESPHome Variablen, keine Sensoren.Bei deinen globals: fehlen die Einheiten
Ja sehe gerade der Sensor bekommt seine unit: weiter unten.Nö, denn das sind globale ESPHome Variablen, keine Sensoren.
The time when an accumulating sensor such as an electricity usage meter, gas meter, water meter etc. was initialized. If the time of initialization is unknown, set it to None. Note that the datetime.datetime returned by the last_reset property will be converted to an ISO 8601-formatted string when the entity's state attributes are updated. When changing last_reset, the state must be a valid number.
Und wie siehst du den Gesamtverbrauch in Summe dann in HA?K.A., da ich das restore auf no habe, damit der Flash speicher geschont wird.
Und da der Sensor auf totoal_increasing steht, brauche ich das nicht.