155 lines
3.4 KiB
YAML
155 lines
3.4 KiB
YAML
esphome:
|
|
name: esptank32
|
|
platformio_options:
|
|
board_build.flash_mode: dio
|
|
|
|
esp32:
|
|
board: esp32-c3-devkitm-1
|
|
|
|
logger:
|
|
|
|
api:
|
|
password: !secret api_secret
|
|
|
|
ota:
|
|
platform: esphome
|
|
password: !secret ota_key
|
|
|
|
wifi:
|
|
ssid: !secret wireless_ssid
|
|
password: !secret wireless_key
|
|
domain: !secret wireless_domain
|
|
|
|
ap:
|
|
ssid: "ESPtank_Fallback"
|
|
password: !secret ap_secret
|
|
|
|
captive_portal:
|
|
|
|
web_server:
|
|
port: 80
|
|
|
|
time:
|
|
- platform: sntp
|
|
id: sntp_time
|
|
servers:
|
|
- 193.190.198.10
|
|
# timezone: "Europe/Brussels"
|
|
on_time_sync:
|
|
then:
|
|
- logger.log: "NTP : Synchronized sntp clock"
|
|
|
|
mqtt:
|
|
broker: !secret mqtt_broker
|
|
username: espsalon
|
|
password: !secret mqtt_espsalon
|
|
|
|
i2c:
|
|
sda: 1
|
|
scl: 0
|
|
scan: true
|
|
frequency: 300kHz
|
|
id: bus_a
|
|
|
|
globals:
|
|
- id: gaz_impulse
|
|
type: int
|
|
restore_value: no
|
|
initial_value: '0'
|
|
- id: gaz_volume
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0'
|
|
|
|
ads1115:
|
|
- address: 0x48
|
|
|
|
sensor:
|
|
- platform: ads1115
|
|
multiplexer: 'A0_GND'
|
|
gain: 6.144
|
|
name: "ADS1115 Channel A0"
|
|
id: ads0
|
|
update_interval: 3s
|
|
on_value:
|
|
then:
|
|
- component.update: waterlevel
|
|
- component.update: waterpercent
|
|
- component.update: watervolume
|
|
filters:
|
|
# - median:
|
|
# window_size: 20
|
|
# send_every: 5
|
|
# send_first_at: 3
|
|
- sliding_window_moving_average:
|
|
window_size: 60
|
|
send_every: 10
|
|
# 0.74 volts à vide.
|
|
# 2.8 volts plein.
|
|
# linéaire
|
|
|
|
- platform: template
|
|
name: water level
|
|
id: waterlevel
|
|
lambda: return ( id(ads0).state - 0.74 ) * 0.9;
|
|
icon: "mdi:arrow-expand-vertical"
|
|
unit_of_measurement: "m"
|
|
accuracy_decimals: 2
|
|
|
|
- platform: template
|
|
name: water percent
|
|
id: waterpercent
|
|
unit_of_measurement: "%"
|
|
icon: "mdi:water-percent"
|
|
accuracy_decimals: 0
|
|
lambda: return ( id(ads0).state - 0.74 ) * 0.9 / 2.0 * 100;
|
|
|
|
- platform: template
|
|
name: water volume
|
|
id: watervolume
|
|
unit_of_measurement: "l"
|
|
icon: "mdi:gauge"
|
|
lambda: return ( id(ads0).state - 0.74 ) * 0.9 / 2.0 * 5000.0;
|
|
accuracy_decimals: 0
|
|
|
|
- platform: template
|
|
name: gaz impulse
|
|
id: gaz_impulse_sensor
|
|
lambda: return id(gaz_impulse);
|
|
|
|
- platform: template
|
|
name: gaz volume
|
|
id: gaz_volume_sensor
|
|
lambda: return id(gaz_volume);
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: GPIO5
|
|
inverted: true
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
name: "gaz volume add"
|
|
id: gaz_volume_add
|
|
on_press:
|
|
- then:
|
|
- lambda: 'id(gaz_impulse) += 1; id(gaz_volume) += 0.01; '
|
|
- sensor.template.publish:
|
|
id: gaz_impulse_sensor
|
|
state: !lambda 'return id(gaz_impulse);'
|
|
|
|
button:
|
|
- platform: template
|
|
name: Reset counters
|
|
id: button_reset_counters
|
|
|
|
# Optional variables:
|
|
icon: "mdi:emoticon-outline"
|
|
on_press:
|
|
- logger.log: "Button pressed reset counters"
|
|
- lambda: 'id(gaz_impulse) = 0; id(gaz_volume) = 0.00; '
|
|
- sensor.template.publish:
|
|
id: gaz_impulse_sensor
|
|
state: !lambda 'return id(gaz_impulse);'
|