substitutions: device_name: "esphome-watermeter" esp8266: board: d1_mini restore_from_flash: true esphome: name: ${device_name} friendly_name: "ESPHome Watermeter" project: name: "Watermeter IZAR.Watermeter" version: "2.0" build_path: ./build/${device_name} on_boot: - priority: -100.00 then: - globals.set: id: boot_counter value: !lambda "return id(boot_counter)+=1;" - logger.log: level: ERROR tag: "system" format: "BOOTMESSAGE:${device_name} API is connected, Device ready!" - component.update: bootcounter - priority: 800 then: - logger.log: level: ERROR tag: "system" format: "BOOTMESSAGE:${device_name} hardware initialization of vital components is executed " on_shutdown: priority: 700 then: - logger.log: level: ERROR tag: "system" format: "BOOTMESSAGE:${device_name} is down!" external_components: - source: github://SzczepanLeon/esphome-components@main refresh: 0s components: [wmbus] debug: update_interval: 5s mdns: disabled: false preferences: flash_write_interval: 1min # Enable logging logger: id: appslogger level: "ERROR" baud_rate: "0" logs: wmbus: "ERROR" wMBus-lib: "ERROR" ota: captive_portal: web_server: port: 80 wifi: ssid: !secret wifi_ssid password: !secret wifi_password ap: # Fallback hotspot ssid: "Esphome-Web-Watermeter" password: !secret fallback_hotspot_password globals: - id: boot_counter type: int restore_value: yes initial_value: "0" - id: last_value type: float restore_value: yes initial_value: "0.00" wmbus: mosi_pin: GPIO13 #D7 MOSI miso_pin: GPIO12 #D6 MISO clk_pin: GPIO14 #D5 SCK cs_pin: GPIO15 #D8 CSN gdo0_pin: GPIO04 #D1 SDA gdo2_pin: GPIO05 #D2 SCL log_unknown: False time: - platform: sntp id: time_sntp timezone: Europe/Berlin servers: - 0.at.pool.ntp.org - 0.pool.ntp.org - 1.pool.ntp.org on_time_sync: then: - if: condition: lambda: 'return id(device_lastBoot_time).state == "";' then: - text_sensor.template.publish: id: device_lastBoot_time state: !lambda return id(time_sntp).now().strftime("%Y-%m-%dT%H:%M:%S %Z"); - logger.log: level: ERROR tag: "system" format: "Synchronized sntp clock" api: # Home Assistant API encryption: key: "7G+TTPJPcJM1krI/LVpI+P0EG19K/MAmZpSqMiK/E7Q=" id : "esphome_watermeter" reboot_timeout: "0s" port: "6053" sensor: - platform: wmbus # Meter ID (usually from sticker). Can be specified as decimal or hex. meter_id: !secret watermeter_id type: izar add_prefix: false lqi: # The LQI value reported by the CC1101 is a 7 bit unsigned number with a range from 0 to 127 (lower is better). name: "CC1101 LQI" id: wmbus_cc1101_lqi entity_category: "diagnostic" state_class: "measurement" unit_of_measurement: "lqi" rssi: # 8 bit signed received signal strength with range from -138 dBm to -10.5 dBm (higher is better) name: "CC1101 RSSI" id: wmbus_cc1101_rssi unit_of_measurement: "dBm" icon: mdi:rss state_class: "measurement" entity_category: "diagnostic" total_water_m3: # total watermter reading in m3 name: "Watermeter total(m³)" id: "watermeter_total_m3" unit_of_measurement: "m³" state_class: total_increasing device_class: "water" accuracy_decimals: 3 icon: mdi:counter on_value: then: - lambda: |- ESP_LOGD("system", "Water total(m3): %f, last value: %f", id(watermeter_total_m3).state, id(last_value)); id(last_value)=id(watermeter_total_m3).state; current_month_total_water_l: # water current month name: "Water current month (l)" id: "watermeter_current_month_l" accuracy_decimals: 2 unit_of_measurement: "L" state_class: total_increasing device_class: "water" last_month_total_water_m3: # get the last month total watermter m3 from the wmbus telegram name: "Water last month (m³)" id: "watermeter_last_month_m3" unit_of_measurement: "m³" state_class: total_increasing device_class: "water" accuracy_decimals: 3 icon: mdi:counter remaining_battery_life_y: # get the battery life time name: "Watermeter battery life" id: "watermeter_battery" entity_category: "diagnostic" state_class: "measurement" accuracy_decimals: 2 icon: mdi:battery transmit_period_s: # get the last transmit periode name: "Watermeter transmit period" id: "watermeter_transmit_period" entity_category: "diagnostic" state_class: "measurement" icon: mdi:timelapse current_alarms: # get the current alarmcode id: "watermeter_current_alarm" name: "Watermeter current alarm" entity_category: "diagnostic" icon: mdi:alarm-light previous_alarms: # get the previous alarmcode id: "watermeter_prev_alarm" name: "Watermeter previous alarm" entity_category: "diagnostic" icon: mdi:alarm-light - platform: wifi_signal # Wifi quality RSSI (%) name: Device WLAN Signal id: wifi_signal_db update_interval: 60s filters: - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); entity_category: "diagnostic" unit_of_measurement: "%" - platform: debug # The debug component can be used to debug problems with ESPHome.. free: # Free heap size in bytes. name: "Heap Free" entity_category: "diagnostic" fragmentation: # Fragmentation metric of the heap (0% is clean) name: "Heap Fragmentation" entity_category: "diagnostic" block: # Reports the largest contiguous free RAM block on the heap in bytes. name: "Heap Max Block" entity_category: "diagnostic" loop_time: # Reports the longest time between successive iterations of the main loop. name: "Application Loop Time" entity_category: "diagnostic" - platform: template # device boot counter name: Boot counter id: bootcounter accuracy_decimals: 0 state_class: "measurement" entity_category: "diagnostic" lambda: |- return (id(boot_counter)); text_sensor: - platform: debug # Reports the device information: device: name: "Device Info" entity_category: "diagnostic" reset_reason: # Reports the last reboot reason in a human-readable form. name: "Reset Reason" entity_category: "diagnostic" - platform: template # Last boot timestamp name: "Last Boot timestamp" disabled_by_default: true id: device_lastBoot_time icon: mdi:clock-start