SzczepanLeon / esphome-components

116 stars 40 forks source link

Feature Request: More Kamstrup Multical 21 water meter data :) #90

Open jascdk opened 3 months ago

jascdk commented 3 months ago

Hi

Great work on this project. We have in our holiday house a Kamstrup Multical 21 Watermeter, which I have been using for a couple of years now. The hardware is a Wemos D1 mini together with the little green CC1101 board, that is used in this project here.

My formerly code was a hardcoded piece of software, which sends the data via mqtt - it works great, but I hate the hardcoded software - I like Esphome much better. It was a pleasure finding this GitHub repo here.

My request is for delivering more data via the multical water meter.

The Multical21 provides the following meter values:

total counter - total water consumption in m³ (supported by this code so far) target counter - water consumption until 1. day of the current month (supported by this code so far) medium temperature - in °C (not supported yet) ambient temperature - in °C (not supported yet) info codes - BURST, LEAK, DRY, REVERSE, TAMPER, RADIO OFF (not supported yet)

The code I used before is from this repo:

https://github.com/chester4444/esp-multical21

Is it possible to review this above code for getting the rest of the sensors?

Or do you need a VERY_VERBOSE log?

All the Best

Jacob from Denmark

jascdk commented 3 months ago

And the VERY_VERBOSE logs:

logs_watermeter_logs.txt

cenobitedk commented 1 day ago

@jascdk Hi Jacob. Latest version supports these features as well, except for the status. Support for the status would require far more work as it is should be a string to make sense (it is just a number value from the meter) and the functions that reads and publish the value can not work with strings. A work around would be to publish the raw status code and use a text template sensor with a lambda function to convert it to a string. Would that be a viable solution?

Example:


sensor:
  - platform: wmbus
    meter_id: ...
    type: multical21
    key: "..."
    mode: C1
    lqi:
      name: "LQI"
    rssi:
      name: "RSSI"
    total_water_m3:
      name: "Total Water m3"
    target_water_m3:
      name: "Target Water m3"
    flow_temperature_c:
      name: "Flow Temperature °C"
    external_temperature_c:
      name: "Ambient Temperature °C"
    status_code:
      id: status_code
      name: "Status Code"

text_sensor:
  - platform: template
    name: "Status"
    lambda: |-
      if (id(status_code).state = 1) {
        return {"DRY"};
      } else if (id(status_code).state = 2) {
        return {"REVERSE"};
      } else if (id(status_code).state = 4) {
        return {"LEAK"};
      } else if (id(status_code).state = 8) {
        return {"BURST"};
      } else {
        return {"OK"};
      }