SzczepanLeon / esphome-components

112 stars 40 forks source link

need some help with Qwater #98

Open alkue1 opened 1 month ago

alkue1 commented 1 month ago

Hi, recently i got watermeters from Qundis installed and stumbled over (https://github.com/zibous/ha-watermeter). But now i´m stuck with wmbus. it seems to be an error with decoding??

[14:16:57][D][mbus:013]: Processing C1 A frame [14:16:57][D][crc:035]: calculated: 0x0DF9, read: 0x800D !!! [14:16:57][D][mbus:013]: Processing C1 A frame [14:16:57][D][sensor:094]: '0x00 Watermeter CC1101 LQI': Sending state 128.00000 lqi with 0 decimals of accuracy [14:16:57][D][sensor:094]: '0x00 Watermeter CC1101 RSSI': Sending state -48.00000 % with 0 decimals of accuracy [14:16:57][D][wmbus:182]: Meter ID [0x52339899] RSSI: -48 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344999833521A07780DFF5F350082D00000F00007C113FFFF42030000FFFF000000001F3568020000008000800080008000800080008000800080008000801A002F046D100D0236 (74) [14:16:58][D][sensor:094]: 'Device Boot counter': Sending state 25.00000 with 0 decimals of accuracy [14:17:02][D][mbus:013]: Processing C1 A frame [14:17:02][D][sensor:094]: '0x00 Watermeter CC1101 LQI': Sending state 129.00000 lqi with 0 decimals of accuracy [14:17:02][D][sensor:094]: '0x00 Watermeter CC1101 RSSI': Sending state -74.00000 % with 0 decimals of accuracy [14:17:02][D][wmbus:182]: Meter ID [0x15565139] RSSI: -74 dBm LQI: 129 Frame: C1 A not found in configuration T: 49449344395156153608780DFF5F350082A90000EF0007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D100D0236 (74) [14:17:05][D][sensor:094]: 'wifi_signal_db': Sending state -35.00000 dBm with 0 decimals of accuracy [14:17:05][D][sensor:094]: 'Device WLAN Signal': Sending state 100.00000 % with 0 decimals of accuracy [14:17:27][D][mbus:013]: Processing C1 A frame [14:17:27][D][crc:035]: calculated: 0x2D45, read: 0xED1E !!! [14:17:36][D][mbus:013]: Processing C1 A frame [14:17:36][D][sensor:094]: '0x00 Watermeter CC1101 LQI': Sending state 131.00000 lqi with 0 decimals of accuracy [14:17:36][D][sensor:094]: '0x00 Watermeter CC1101 RSSI': Sending state -87.00000 % with 0 decimals of accuracy [14:17:36][D][wmbus:182]: Meter ID [0x14157183] RSSI: -87 dBm LQI: 131 Frame: C1 A not found in configuration T: 574468508371151494088C0029900F002C25BC210E00F6F1A8015CBE84EA7ABC00300710F6E033014C9F6FDE4A4FCCD55CCE006B865ECDC56F023BA59490EBCD66376C3C9502220327B4C5CD0D880C109852D5D40FBD4986 (88) [14:17:47][D][mbus:013]: Processing C1 A frame [14:17:47][D][sensor:094]: '0x00 Watermeter CC1101 LQI': Sending state 137.00000 lqi with 0 decimals of accuracy [14:17:47][D][sensor:094]: '0x00 Watermeter CC1101 RSSI': Sending state -83.00000 % with 0 decimals of accuracy [14:17:47][D][wmbus:182]: Meter ID [0x52180675] RSSI: -83 dBm LQI: 137 Frame: C1 A not found in configuration T: 49449344750618521A06780DFF5F350082460000F10007C113FFFF81010000FFFF000000001F3545010000008000800080008000800080008000800300000000000B002F046D110D0236 (74)

This is my config

esp32:
  board: az-delivery-devkit-v4
  framework:
    type: arduino

## ----------------------------------------------------------------
## EXTERNAL COMPONENTS
## ----------------------------------------------------------------
external_components:

  # uses the latest version 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@main
    refresh: 0s

  # use local component from
  # https://github.com/zdzichu6969/esphome-components
  #- source:
  #    type: local
  #    path: custom_components
  #  components: [backup]

  # use local component from
  # https://github.com/TheStaticTurtle/esphome_syslog
  # - source:
  #     type: local
  #     path: custom_components
  #   components: [syslog]

## ---------------------------------------------------
## syslog service
## tail -f /var/log/syslog | grep "water-meter"
## ---------------------------------------------------
# syslog:
#   ip_address: !secret syslog_server
#   port: !secret syslog_port
#   min_level: DEBUG
#   enable_logger: true

# ----------------------------------------------------------------
# Save your ESPHome device configuration in firmware and and
# recover it if you lost source files.
# ----------------------------------------------------------------
#backup:
#  auth:
#    username: !secret web_username
#    password: !secret web_password
#  force_update: false

## ----------------------------------------------------------------
## Global variables
## ----------------------------------------------------------------
globals:

  - id: boot_counter
    type: int
    restore_value: yes
    initial_value: "0"

  - id: last_value
    type: float
    restore_value: yes
    initial_value: "0.00"

  - id: alarm_error_text
    type: std::vector<std::string>
    restore_value: no
    initial_value: '{"no error", "general_alarm","leakage","meter_blocked","back_flow","underflow","overflow","submarine","sensor_fraud","mechanical_fraud"}'

## ---------------------------------------------------
## 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

## ---------------------------------------------------
## mDNS Component
## ---------------------------------------------------
mdns:
  # if mDNS is disabled, they will no longer be able to automatically find your devices.
  disabled: false

## ---------------------------------------------------
## 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
  safe_mode: false
  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 COMPONENT
## ---------------------------------------------------
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:
        - logger.log:
            tag: "system"
            level: INFO
            format: "Synchronized sntp clock"

## ------------------------------------------------------------------
##           WMBUS CC1101 --> ESP32 az-delivery-devkit-v4
## ------------------------------------------------------------------
##
##
##                                                               o 1 (3.3V)
##                                                               |
##   ╭――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x――o―╮
##   |                                                             |
##   |                                                             |
## - | 5v               az-delivery-devkit-v4                      | -- ANT
##   |                                                             |
##   |                          16 17 5  18 19               23    |
##   ╰――x――x――x――x――x――x――x――x――o――x――o――o――o――o――o――o――o――o――o――o―╯
##                              |  |  |  |  |                 |   |
##                              o  |  |  o  |                 |   ╰-o - 2 (GND)
##                              7  o  |  4  o                 o
##                            GDO0 6  | CLK 5                 3
##                               GD02 o    MISO              M0SI
##                                    8
##                                   CSN
##
## ------------------------------------------------------------------
wmbus:
  mosi_pin: GPIO23    ## SI:   braun
  miso_pin: GPIO19    ## SO:   grün
  clk_pin: GPIO18     ## SCLK: violett
  cs_pin: GPIO05      ## CSN:  orange
  gdo0_pin: GPIO16    ## GD00: gelb (rx)
  gdo2_pin: GPIO17    ## GD02: weiss (tx)

  # log_unknown (Optional): Show telegrams from not configured meters in log.
  # Defaults to False
  log_unknown: True

## ---------------------------------------------------
## 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: safe_mode
    name: "Device Restart (Safe Mode)"

  - platform: restart
    name: "Restart"
    id: restart_switch

  - platform: factory_reset
    name: Device Restart Factory

## ---------------------------------------------------
## 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
    meter_id: 0
    type: qwater
    add_prefix: true
    # 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"
      unit_of_measurement: "lqi"
      entity_category: "diagnostic"

    # 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.
    rssi:
      id: wmbus_cc1101_rssi
      name: "Watermeter CC1101 RSSI"
      unit_of_measurement: "%"
      entity_category: "diagnostic"

    # reports the watermeter display value
    total_water_m3:
      id: "waterdisplay"
      name: "Watermeter Display"
      unit_of_measurement: "m³"
      state_class: total_increasing
      device_class: "water"
      accuracy_decimals: 3
      icon: mdi:counter
      # update and calulatet all watermeter data values
      on_value:
        then:
          - lambda: |-
              ESP_LOGI("wmbus", "Water Display value: %.3f, last value: %.3f", id(waterdisplay).state, id(last_value));
              id(last_value)=id(waterdisplay).state;

    # get the last month total watermter m3 from the wmbus telegram  (wM-Bus 2.1.10)
    last_month_total_water_m3:
      name: "Water last month"
      id: "waterdisplay_lastmonth"
      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 battery life time (wM-Bus v2.1.4)
    remaining_battery_life_y:
      name: "Watermeter Battery Life"
      id: "watermeter_batterie"
      accuracy_decimals: 2
      unit_of_measurement: "Years"
      icon: mdi:battery

    # get the last transmit periode (wM-Bus v2.1.4)
    transmit_period_s:
      name: "Watermeter transmit periode"
      id: "watermeter_transmit_periode"
      unit_of_measurement: "sec"
      accuracy_decimals: 2
      icon: mdi:timelapse

    ## get the current watermeter alarms and publish the text message (wM-Bus 2.1.10)
    current_alarms:
      id: "watermeter_current_alarms"
      name: "Watermeter current alarm code"
      icon: mdi:alarm-light
      entity_category: "diagnostic"

    ## get the prevois watermeter alarms and publish the text message (wM-Bus 2.1.10)
    previous_alarms:
      id: "watermeter_previous_alarms"
      name: "Watermeter pervious alarm code"
      icon: mdi:alarm-light
      entity_category: "diagnostic"

  # Wifi quality RSSI, internal used to calculate the Wifi quality RSSI in percentage
  - 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 Signal"
    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
    icon: mdi:counter
    accuracy_decimals: 0
    state_class: "measurement"
    entity_category: "diagnostic"
    lambda: return (id(boot_counter));

And this is the result of wmbusmeters.org : https://wmbusmeters.org/analyze/49449344989833521A07780DFF5F3500827500007E0007C113FFFF57040000FFFF000000001F35220300000080008000800080008000800080008000800080008020002F046D040D0236:qwater

Could you help me finding the Problem?

SzczepanLeon commented 1 month ago

Please set proper meter-id in configuration.

alkue1 commented 1 month ago

thanks for your quick reply!

changing it to:

- 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
    meter_id: 0x52339899
    type: qwater
    add_prefix: true

made this specific device disapear in my logs. :

[14:49:33][D][mbus:013]: Processing C1 A frame
[14:49:33][D][wmbus:182]: Meter ID [0x15565137] RSSI: -50 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344375156153608780DFF5F350082A00000F10007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D310D0236 (74)
[14:49:33][D][mbus:013]: Processing C1 A frame
[14:49:33][D][wmbus:182]: Meter ID [0x52180675] RSSI: -84 dBm LQI: 130 Frame: C1 A not found in configuration T: 49449344750618521A06780DFF5F3500824A0000800007C113FFFF81010000FFFF000000001F3545010000008000800080008000800080008000800300000000000B002F046D310D0236 (74)
[14:49:35][D][mbus:013]: Processing C1 A frame
[14:49:35][D][wmbus:182]: Meter ID [0x15565144] RSSI: -87 dBm LQI: 135 Frame: C1 A not found in configuration T: 49449344445156153608780DFF5F350082CB00005F0107B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D310D0236 (74)
[14:49:42][D][mbus:013]: Processing C1 A frame
[14:49:42][D][wmbus:182]: Meter ID [0x52180680] RSSI: -48 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344800618521A06780DFF5F350082C000005F0107C113FFFF23010000FFFF000000001F35830000000080008000800080008000800080008003000000000005002F046D310D0236 (74)
[14:49:49][D][sensor:094]: 'wifi_signal_db': Sending state -33.00000 dBm with 0 decimals of accuracy
[14:49:49][D][sensor:094]: 'Device WLAN Signal': Sending state 100.00000 % with 0 decimals of accuracy
[14:49:55][D][mbus:013]: Processing C1 A frame
[14:49:55][D][crc:035]:     calculated: 0x9BDA, read: 0xA097  !!!
[14:50:05][D][mbus:013]: Processing C1 A frame
[14:50:05][D][crc:035]:     calculated: 0xCAAC, read: 0xC959  !!!
[14:50:14][D][sensor:094]: 'Device Boot counter': Sending state 26.00000  with 0 decimals of accuracy
[14:50:26][D][mbus:013]: Processing C1 A frame
[14:50:26][D][wmbus:182]: Meter ID [0x15565139] RSSI: -65 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344395156153608780DFF5F350082AD0000100007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D320D0236 (74)
[14:50:34][D][mbus:013]: Processing C1 A frame
[14:50:34][D][crc:035]:     calculated: 0x9C2C, read: 0xC120  !!!
[14:50:49][D][sensor:094]: 'wifi_signal_db': Sending state -31.00000 dBm with 0 decimals of accuracy
[14:50:49][D][sensor:094]: 'Device WLAN Signal': Sending state 100.00000 % with 0 decimals of accuracy
[14:50:54][D][mbus:013]: Processing C1 A frame
[14:50:54][D][wmbus:182]: Meter ID [0x67555767] RSSI: -56 dBm LQI: 128 Frame: C1 A not found in configuration T: 58449344675755673C377807796757556793443C040DFF5F350082DD0000F00007C006FFFF71400100FF2C549900001F35234001002B023D025B0248028C02BC02E802DF02D4023803690391032F02FD170000046D040E0236 (89)
[14:51:00][D][mbus:013]: Processing C1 A frame
[14:51:14][D][mbus:013]: Processing C1 A frame
[14:51:14][D][crc:035]:     calculated: 0xBF38, read: 0x6BED  !!!
[14:51:14][D][sensor:094]: 'Device Boot counter': Sending state 26.00000  with 0 decimals of accuracy
[14:51:16][D][mbus:013]: Processing C1 A frame
[14:51:16][D][wmbus:182]: Meter ID [0x15565134] RSSI: -78 dBm LQI: 132 Frame: C1 A not found in configuration T: 49449344345156153608780DFF5F3500828D0000100007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D330D0236 (74)
[14:51:23][D][mbus:013]: Processing C1 A frame
[14:51:23][D][wmbus:182]: Meter ID [0x15565138] RSSI: -55 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344385156153608780DFF5F350082A70000EF0007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D330D0236 (74)
[14:51:25][D][mbus:013]: Processing C1 A frame
[14:51:25][D][wmbus:182]: Meter ID [0x15565136] RSSI: -80 dBm LQI: 131 Frame: C1 A not found in configuration T: 314493443651561536087A9A0000200B6E0000004B6E000000426CFFFFCB086E000000C2086C1F35326CFFFF046D330D0236 (50)
[14:51:28][D][mbus:013]: Processing C1 A frame
[14:51:28][D][wmbus:182]: Meter ID [0x15565137] RSSI: -50 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344375156153608780DFF5F350082A000007E0007B06EFFFF00000000FFFF000000001F35000000000080008000800080008000800080008000800080008000802F046D330D0236 (74)
[14:51:33][D][mbus:013]: Processing C1 A frame
[14:51:33][D][wmbus:182]: Meter ID [0x15565134] RSSI: -79 dBm LQI: 131 Frame: C1 A not found in configuration T: 314493443451561536087A8E0000200B6E0000004B6E000000426CFFFFCB086E000000C2086C1F35326CFFFF046D330D0236 (50)
[14:51:33][D][mbus:013]: Processing C1 A frame
[14:51:33][D][wmbus:182]: Meter ID [0x52180680] RSSI: -46 dBm LQI: 128 Frame: C1 A not found in configuration T: 49449344800618521A06780DFF5F350082C00000F00007C113FFFF23010000FFFF000000001F35830000000080008000800080008000800080008003000000000005002F046D330D0236 (74)
[14:51:49][D][sensor:094]: 'wifi_signal_db': Sending state -36.00000 dBm with 0 decimals of accuracy
[14:51:49][D][sensor:094]: 'Device WLAN Signal': Sending state 100.00000 % with 0 decimals of accuracy
[14:51:54][D][mbus:013]: Processing C1 A frame
[14:51:54][D][crc:035]:     calculated: 0x249C, read: 0x7990  !!!
[14:52:14][D][sensor:094]: 'Device Boot counter': Sending state 26.00000  with 0 decimals of accuracy
[14:52:16][D][mbus:013]: Processing C1 A frame

what does these calaculation (eg 'calculated: 0x249C, read: 0x7990 !!!') mean?

SzczepanLeon commented 1 month ago

It is CRC. From frame and/or calculated.

alkue1 commented 1 month ago

Do you have any suggestions why there is no result for the meters? is there a point i could start investigating /debug?

SzczepanLeon commented 1 month ago

Are you 100% sure that meter is transmitting wMBus frames on that frequency?

alkue1 commented 1 month ago

i assumed that, because when i enter these packets (from the log) to the online wmbus website it shows me the correct meter values (link in my first post).... the meter is "Qwater", but there are also some Qcaloric devices shown in the log.

sippeeey commented 3 weeks ago

Hi @alkue1, i have a similar problem with the Qwater 5.5 Device.

My telegram data looks: https://wmbusmeters.org/analyze/49449344708828521a072198780dff5f350082a70035865B2883cf79596625201701faccdcedd4506930ee48B78676cf439BeB7e6054de780a19938a15235695B5c3e7af7140e85Bfaefe1dd046d011307365690:qwater

but my actual consumption is: 1885m³

Is there a solution?