-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
# Variables | ||
substitutions: | ||
name: eau | ||
|
||
# Name | ||
esphome: | ||
name: ${name} | ||
|
||
# Board model | ||
esp32: | ||
board: esp32dev | ||
framework: | ||
type: arduino | ||
|
||
# W-Fi configuration | ||
wifi: | ||
ssid: !secret wifi_ssid | ||
password: !secret wifi_password | ||
reboot_timeout: 15min | ||
|
||
# Enable fallback hotspot (captive portal) in case wifi connection fails | ||
ap: | ||
ssid: "${name} Fallback Hotspot" | ||
password: !secret hotspot_password | ||
|
||
captive_portal: | ||
|
||
# Enable logging | ||
logger: | ||
baud_rate: 0 | ||
level: INFO | ||
# level: DEBUG | ||
|
||
# Enable Home Assistant API | ||
api: | ||
|
||
ota: | ||
|
||
web_server: | ||
port: 80 | ||
|
||
time: | ||
- platform: homeassistant | ||
id: homeassistant_time | ||
|
||
# Reset sensors at 00h | ||
on_time: | ||
- seconds: 57 | ||
minutes: 59 | ||
hours: 23 | ||
then: | ||
|
||
- sensor.template.publish: | ||
id: eau_conso_veille | ||
state: !lambda return id(eau_conso_jour).state; | ||
|
||
- pulse_meter.set_total_pulses: | ||
id: eau | ||
value: 0 | ||
|
||
- sensor.template.publish: | ||
id: eau_m3_veille | ||
state: !lambda return id(eau_m3_jour).state; | ||
|
||
- lambda: |- | ||
id(eau_m3_jour) = 0; | ||
|
||
# Add sensors | ||
|
||
sensor: | ||
# Wi-Fi signal | ||
- platform: wifi_signal | ||
name: "WiFi Signal Sensor" | ||
update_interval: 60s | ||
unit_of_measurement: dB | ||
accuracy_decimals: 0 | ||
force_update: false | ||
icon: mdi:wifi | ||
|
||
# Uptime | ||
- platform: uptime | ||
id: uptime_seconds | ||
name: "Uptime Sensor" | ||
update_interval: 60s | ||
unit_of_measurement: s | ||
accuracy_decimals: 0 | ||
force_update: false | ||
icon: mdi:timer | ||
|
||
|
||
|
||
########### EAU ############################################################################### | ||
# Eau usage | ||
- platform: pulse_meter | ||
id: eau | ||
pin: 17 | ||
unit_of_measurement: "l/mn" | ||
icon: mdi:water | ||
internal_filter: 100ms | ||
name: "Debit Eau (l)" | ||
state_class: measurement | ||
filters: | ||
- lambda: return (x * 10); # 1 impulsion = 10 l | ||
|
||
######################### | ||
# Total eau usage today | ||
total: | ||
unit_of_measurement: "l" | ||
name: 'Eau Consommation Jour' | ||
filters: | ||
- multiply: 0.01 # (pour avoir des m3) | ||
accuracy_decimals: 3 | ||
icon: mdi:water | ||
id: eau_conso_jour | ||
device_class: "water" | ||
|
||
######################### | ||
# Total eau usage yesterday | ||
- platform: template | ||
name: "Eau Consommation Veille" | ||
state_class: measurement | ||
device_class: "water" | ||
id: eau_conso_veille | ||
unit_of_measurement: "l" | ||
accuracy_decimals: 3 | ||
icon: mdi:water | ||
update_interval: 10s | ||
|
||
######################### | ||
# Total gaz power today | ||
- platform: template | ||
name: "Eau m3 Jour" | ||
lambda: |- | ||
return id(eau_conso_jour).state * 10.01; | ||
device_class: water | ||
unit_of_measurement: "m³" | ||
accuracy_decimals: 3 | ||
id: eau_m3_jour | ||
state_class: total_increasing | ||
|
||
######################### | ||
# Total gaz power today | ||
- platform: template | ||
name: "Eau m3 Veille" | ||
state_class: total_increasing | ||
device_class: water | ||
id: eau_m3_veille | ||
unit_of_measurement: "m³" | ||
accuracy_decimals: 3 | ||
icon: mdi:water | ||
update_interval: 10s | ||
|
||
########### EAU ############################################################################### | ||
|
||
|
||
|
||
binary_sensor: | ||
# ESP Status | ||
- platform: status | ||
name: "Eau (Statut)" | ||
|
||
switch: | ||
# Restart button | ||
- platform: restart | ||
name: "${name} reboot" | ||
|
||
text_sensor: | ||
# Uptime human readable | ||
- platform: template | ||
name: ${name} - Uptime | ||
update_interval: 60s | ||
icon: mdi:clock-start | ||
lambda: |- | ||
int seconds = (id(uptime_seconds).state); | ||
int days = seconds / (24 * 3600); | ||
seconds = seconds % (24 * 3600); | ||
int hours = seconds / 3600; | ||
seconds = seconds % 3600; | ||
int minutes = seconds / 60; | ||
seconds = seconds % 60; | ||
if ( days ) { | ||
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() }; | ||
} else if ( hours ) { | ||
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() }; | ||
} else if ( minutes ) { | ||
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() }; | ||
} else { | ||
return { (String(seconds) +"s").c_str() }; | ||
} | ||
# Expose ESPHome version as sensor. | ||
- platform: version | ||
name: ${name} - Version | ||
# Expose WiFi information as sensors. | ||
- platform: wifi_info | ||
ip_address: | ||
name: ${name} - IP | ||
bssid: | ||
name: ${name} - BSSID | ||
|
||
################################################################################################ |