## --------------------------------------------------------------------------- ## WMBUS METER D1 MINI 32 + CC1101 for Diehl IZAR RC 868 I R4 PL ## HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash ## ## This version shows data from the defined watermeter and ## uses the watermeterID (HEX) from the secrets.yaml file. ## ## usage: 1. Using the last wM-Bus component ## 2. Using Homassistant API (discovery + devices) ## --------------------------------------------------------------------------- substitutions: ## device settings device_name_short: "water-meter-d1mini32" device_description: "SIMPLE: Wasserzähler Wemos D1 Mini 32, CUL - CC1101, IZAR module (Diehl IZAR RC 868 I R4 PL (SzczepanLeon) - find watermeters" projectname: "Diehl IZAR RC 868.Watermeter-Test" appversion: "3.0.0" ## logger settings log_level: "WARN" # not that logging need memory, so in production mode use "WARN" log_wmbus: "ERROR" # Loglevel for wmbus meters component log_baudrate: "0" # 0 disable uart logger messages ## ---------------------------------------------------------------- ## HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash ## ---------------------------------------------------------------- esp32: board: wemos_d1_mini32 preferences: flash_write_interval: 1min # mdns: # disabled: false ## ---------------------------------------------------------------- ## APPLICATION ESPHOME ## ---------------------------------------------------------------- esphome: name: ${device_name_short} comment: ${device_description} # Automatically add the mac address to the name # so you can use a single firmware for all devices name_add_mac_suffix: false project: name: ${projectname} version: ${appversion} build_path: ./build/${device_name_short} on_boot: then: - globals.set: id: boot_counter value: !lambda "return id(boot_counter)+=1;" - logger.log: level: WARN tag: "system" format: "BOOTMESSAGE:${device_name_short} API is connected, Device ready!" - component.update: bootcounter on_shutdown: then: - logger.log: level: ERROR tag: "system" format: "BOOTMESSAGE:${device_name_short} is down!" ## --------------------------------------------------- ## External components ## --------------------------------------------------- external_components: # uses the version 3 from SzczepanLeon # https://github.com/SzczepanLeon/esphome-components # You can make ESPHome check the repository every time by setting this option to 0s - source: github://SzczepanLeon/esphome-components@version_3 refresh: 0s components: [wmbus] ## ---------------------------------------------------------------- ## GLOBALS VARIABLES ## ---------------------------------------------------------------- globals: - id: boot_counter type: int restore_value: yes initial_value: "0" ## --------------------------------------------------- ## WIFI Settings 3 wifis ## --------------------------------------------------- wifi: networks: - ssid: !secret ssid3_name password: !secret ssid3_pswd priority: 0 - ssid: !secret ssid1_name password: !secret ssid1_pswd priority: 1 - ssid: !secret ssid2_name password: !secret ssid2_pswd priority: 2 domain: !secret domain ## --------------------------------------------------- ## The captive portal component in ESPHome is a ## fallback mechanism for when connecting to the ## configured WiFi fails. ## --------------------------------------------------- captive_portal: ## --------------------------------------------------- ## LOGGER COMPONENT ## --------------------------------------------------- logger: id: appslogger level: ${log_level} baud_rate: ${log_baudrate} logs: wmbus: ${log_wmbus} wMBus-lib: ${log_wmbus} ## --------------------------------------------------- ## OTA COMPONENT ## --------------------------------------------------- ota: password: !secret ota_pswd platform: esphome on_begin: then: - logger.log: format: "OTA Start" tag: "OTA" level: WARN on_progress: then: - logger.log: level: WARN tag: "OTA" format: "OTA progress %0.1f%%" args: ["x"] on_end: then: - logger.log: format: "OTA End" tag: "OTA" level: WARN on_error: then: - logger.log: format: "OTA update error %d" tag: "OTA" level: ERROR args: ["x"] ## --------------------------------------------------- ## COMPONENT WEBSERVER ## --------------------------------------------------- web_server: port: 80 version: 2 js_url: !secret webserver_jsurl ## --------------------------------------------------- ## Home Assistant API COMPONENT ## --------------------------------------------------- api: id: espapi_wmbus_esp32 port: 6053 reboot_timeout: 0s ## --------------------------------------------------- ## SNTP Time server ## Change this to your timezone and ntp server ## --------------------------------------------------- time: - platform: sntp id: time_sntp timezone: Europe/Berlin servers: - !secret local_sntp - 0.at.pool.ntp.org - 0.pool.ntp.org on_time_sync: then: - logger.log: level: WARN tag: "system" format: "Synchronized sntp clock" ## ------------------------------------------------------------------------------------ ## WMBUS DEVICE D1MINI 32 --> CC1101 ## ------------------------------------------------------------------------------------ ## ## ANT ## CC1101 ╭――――――――――――――――――――――――――――――――――╮ CC1101 ## │ D1 MINI 32 │ ## │ BOTTOM │ ## │ │ ## 01│ [ ] GND TX RST GND [ ] │11 ## 02│ [ ] I027 RXD SVP RST [ ] │12 ## GDO2 3 ■ GIPO22 <--03│ [■] I025 I022 I026 SVN [ ] │13 ## GDO0 2 ■ GIPO21 <--04│ [■] I032 I021 I018 I035 [■] │14 GIPO18--> 5 ■ CLK ## 05│ [ ] TDI I017 I019 I033 [■] │15 GIPO19--> 4 ■ MISO ## 06│ [■] I04 I016 I023 I034 [■] │16 GIPO23--> 6 ■ MOSI ## GND 7 ■ <---------07│ [■] I00 GND I05 TMS [■] │17 GIPO5---> 1 ■ CSN ## 08│ [ ] IO2 VCC 3.3 3.3 [■] │18 --------> 8 ■ 3.3V ## 09│ [ ] SDi TDO TCK SD2 [ ] │19 ## 10│ [ ] CLK SDD SD3 CMD [ ] │10 ## │ │ ## │ ▓ Reset Switch ## │ │ ## ╰――――――――――――――――――――――――――――――――――╯ ## │ USB │ ## ╰―――――――――――――――╯ ## ## D1MINI32 ## ╭――――――――――――――――――――――――――――╮ ## │ CSN ■ │ 1 --> ■ 17 GIPO5 ## │ GDO0 ■ │ 2 --> ■ 04 GIPO21 ## │ ■ GND GDO2 ■ │ 3 --> ■ 03 GIPO22 ## │ ■ ANT CC1101 MISO ■ │ 4 --> ■ 15 GIPO19 ## │ ■ GND CLK ■ │ 5 --> ■ 14 GIPO18 ## │ MOSI ■ │ 6 --> ■ 16 GIPO23 ## │ GND ■ │ 7 --> ■ 07 GND ## │ 3.3V ■ │ 8 --> ■ 18 3.3V ## ╰――――――――――――――――――――――――――――╯ ## ## ## --------------------------------------------------- ## WMBUS DEVICE D1MINI 32 --> CC1101 ## --------------------------------------------------- wmbus: mosi_pin: GPIO23 # MOSI Attached to Hardware SPI controller MOSI SPI Interface miso_pin: GPIO19 # MISO Attached to Hardware SPI controller MISO SPI Interface clk_pin: GPIO18 # SCK Attached to Hardware SPI controller CLK cs_pin: GPIO5 # CSN Attached to Hardware SPI controller, Controls Boot Mode; CS SPI Interface 10k Pull-Down, boot fails if pulled high !!! gdo0_pin: GPIO21 # SDA Clock output. High Impedance ! gdo2_pin: GPIO22 # SCL FIFO status signals. High Impedance ! # log_unknown (Optional): Show telegrams from not configured meters in log. Defaults to False log_unknown: False ## --------------------------------------------------- ## SWITCHES ## --------------------------------------------------- switch: # reset boot counter value - platform: template name: Device Boot Counter reset turn_on_action: then: - lambda: |- id(boot_counter) = 0; id(bootcounter).publish_state(id(boot_counter)); - logger.log: level: WARN tag: "system" format: "${device_name_short} reset boot counter o.k!" - component.update: bootcounter - platform: restart name: "Device Restart" id: restart_switch ## --------------------------------------------------- ## SENSORS ## --------------------------------------------------- sensor: - platform: wmbus # Meter ID (usually from sticker). Can be specified as decimal or hex. # only hex is working for my watermeter ! # see: https://github.com/SzczepanLeon/esphome-components/issues/6 # edit watermeterid in the secrets file ## add_prefix settings to add the watermeterid to the lqi, rssi and total_water_m3 meter_id: !secret watermeterId type: izar add_prefix: false # The LQI value reported by the CC1101 is a 7 bit unsigned number with a range from 0 to 127. # Note that a lower value indicates a better link. # The LQI of a received packet will be bad (higher number) when there is lot of interference. lqi: id: wmbus_cc1101_lqi name: "Watermeter CC1101 LQI" entity_category: "diagnostic" unit_of_measurement: "lqi" state_class: "measurement" # The RSSI value reported by the CC1101 is a 8 bit signed number with an effective # range from -138 dBm to -10.5 dBm when the CC1101 is operating around 868 MHz. # RSSI stands for received signal strength (power) indication (in dBm). # A higher value indicates higher power. (internal only) rssi: id: wmbus_cc1101_rssi name: "Watermeter CC1101 RSSI" unit_of_measurement: "dbm" entity_category: "diagnostic" # get the total watermter m3 from the wmbus telegram total_water_m3: name: "Watermeter display" id: "waterdisplay" unit_of_measurement: "m³" state_class: total_increasing device_class: "water" accuracy_decimals: 3 icon: mdi:counter # water current month (wM-Bus v2.1.4) current_month_total_water_l: name: "Water current month" id: "watermonth" accuracy_decimals: 2 unit_of_measurement: "L" state_class: total_increasing device_class: "water" # get the last month total watermter m3 from the wmbus telegram (wM-Bus v2.1.4) last_month_total_water_m3: name: "Watermeter last month" id: "waterdisplay_lastmonth" unit_of_measurement: "m³" state_class: total_increasing device_class: "water" accuracy_decimals: 3 # get the battery life time (wM-Bus v2.1.4) remaining_battery_life_y: name: "Watermeter Battery Life" id: "watermeter_batterie" entity_category: "diagnostic" icon: mdi:battery # get the last transmit periode (wM-Bus v2.1.4) transmit_period_s: name: "Watermeter transmit periode" id: "watermeter_last_reading" entity_category: "diagnostic" icon: mdi:timelapse current_alarms: id: "watermeter_current_alarms" name: "Watermeter current alarm" entity_category: "diagnostic" icon: mdi:alarm-light previous_alarms: id: "watermeter_prev_alarms" name: "Watermeter previous alarm" entity_category: "diagnostic" icon: mdi:alarm-light # Wifi quality RSSI used by wifi_signal_db - platform: wifi_signal id: wifi_signal_db update_interval: 60s internal: true disabled_by_default: true # Wifi quality RSSI in percentage # Received Signal Strength (RSSI) is a measure of incoherent (raw) RF power in a channel. - platform: copy # Reports the WiFi signal strength in % source_id: wifi_signal_db name: "Device WLAN RSSI" filters: - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); unit_of_measurement: "%" entity_category: "diagnostic" # device boot counter - platform: template name: Device Boot counter id: bootcounter accuracy_decimals: 0 state_class: "measurement" entity_category: "diagnostic" lambda: return (id(boot_counter)); # Last boot timestamp - platform: template name: "Device Last Boot" disabled_by_default: true id: device_lastBoot_time icon: mdi:clock-start