Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I cant get it log my meter - Multical 602 #3

Open
MBJ-M2BI opened this issue Feb 17, 2023 · 30 comments
Open

I cant get it log my meter - Multical 602 #3

MBJ-M2BI opened this issue Feb 17, 2023 · 30 comments
Assignees

Comments

@MBJ-M2BI
Copy link

MBJ-M2BI commented Feb 17, 2023

Hi there.
thank you for the very good application for the Multical Optical reading.
i just have the issue, that i cant get it read from my meter.

i get this error:
image

if i take it of the meter it get the this error you make the troubleshooting at:
image

my hardware is this one here:
https://www.ebay.com/itm/354359025520?hash=item5281719f70:g:BgcAAOSwPqxjWj~H

and here is my .yaml code

`substitutions:
device_name: multical602
friendly_name: Multical 602

esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
includes:
- kmp.h
- multical402.h

Enable logging

logger:
baud_rate: 0

Enable Home Assistant API

api:
encryption:
key: "S8FouGpCYDTCDmnP+uSO2m3/bIAChyGLBEtjORhjtFg="

ota:
password: "5050a1d09c9b1a4ad46202cc65d9aa21"

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: "Kamstrup-Multical"
password: "b1jzffPzfgBh"

#Multical UART
uart:

  • id: uart_bus
    rx_pin: GPIO03
    tx_pin: GPIO01
    baud_rate: 1200
    data_bits: 8
    parity: NONE
    stop_bits: 1

#Multical Custom Sensor (first variable is update interval in ms; 3600000 is 1 hour)
custom_component:

  • lambda: |-
    auto multical402 = new Multical402(
    10000,
    id(uart_bus),
    id(m_energy),
    id(m_power),
    id(m_tin),
    id(m_tout),
    id(m_tdiff),
    id(m_flow),
    id(m_volume));
    App.register_component(multical402);
    return {multical402};
    components:
    • id: multical

sensor:
#Multical Custom Sensors

  • name: "Multical Energy"
    platform: template
    id: m_energy
    icon: "mdi:lightning-bolt"
    unit_of_measurement: MWh
    accuracy_decimals: 3
    state_class: "total_increasing"
    device_class: "energy"
    force_update: true

  • name: "Multical Volume"
    platform: template
    id: m_volume
    unit_of_measurement: m3
    accuracy_decimals: 2
    state_class: "measurement"

  • name: "Multical Temperature In"
    platform: template
    id: m_tin
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Temperature Out"
    platform: template
    id: m_tout
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Temperature Diff"
    platform: template
    id: m_tdiff
    icon: "mdi:thermometer"
    unit_of_measurement: °C
    accuracy_decimals: 2
    state_class: "measurement"
    device_class: "temperature"

  • name: "Multical Power"
    platform: template
    id: m_power
    icon: "mdi:flash"
    unit_of_measurement: kW
    accuracy_decimals: 1
    state_class: "measurement"
    device_class: "power"

  • name: "Multical Flow"
    platform: template
    id: m_flow
    unit_of_measurement: l/h
    accuracy_decimals: 0
    state_class: "measurement"`

i see the red IR in the sensor make the blink every 10 sec.
i have tried to rotate the eye on the meter withou luck.

can you in some way help me out here ?

BR
/Mike

@0x414c49
Copy link
Contributor

@MBJ-M2BI
I'm not the GitHub owner, but did you try to press any button on the meter? You need to press play button, so the meter will activate the IR Port. It'll get deactivated if it didn't receive any activity either from the buttons or the IR port.

@0x414c49
Copy link
Contributor

And check you are connecting the IR head correctly.

@MBJ-M2BI
Copy link
Author

MBJ-M2BI commented Feb 17, 2023 via email

@0x414c49
Copy link
Contributor

Maybe 402 and 602 are different. You can try this repo which is for 602:

https://github.com/ProudElm/ESPHome_multical_sensor

@MBJ-M2BI
Copy link
Author

MBJ-M2BI commented Feb 18, 2023 via email

@0x414c49
Copy link
Contributor

0x414c49 commented Mar 7, 2023

I don't know anything about the pinout of the ESP Device you are using, but:

rx_pin: GPIO03
tx_pin: GPIO01

image

Maybe you need to work with IO0 and IO1

@MBJ-M2BI
Copy link
Author

MBJ-M2BI commented Mar 7, 2023 via email

@cenobitedk
Copy link
Owner

Hi @MBJ-M2BI

Did you get it working? I'm pretty sure it can work.

Here's the technical information for 602: https://documentation.kamstrup.com/docs/MULTICAL_602/en-GB/Technical_description/CONT90C6D93022A54253A84D8345A5325B55/?page=104

If not try these options:

  • Looking at the tech sheet it seems you need to change the UART config to 2 stop bits. See the tech sheet.
  • Because the optical reader pcb is different, you might need to invert the polarity, https://esphome.io/components/uart#configuration-variables.
  • Try increasing the timeout value in the kmp.h file.
  • Make sure the register ID's are the same, or update the values in kmp.h. See link to tech sheet.

@cenobitedk cenobitedk self-assigned this Aug 28, 2023
@htvekov
Copy link

htvekov commented Sep 18, 2023

Hi' @cenobitedk

Just pulled your latest commit 14de2ea and confirm that it's working on Multical 602 without any changes.
Only installed some 15 mins. ago, so no long term experience - yet 😉
Took your advice and ordered ready made ir sensors with housing from AR Elektronik.

Any long term experience regarding battery drain issues using e.g. 10 min/hourly updates in production ?

Thank you for this ESPHome Custom Component. Really appreciated! 😎

Regards
Henning

@cenobitedk
Copy link
Owner

Hi' @cenobitedk

Just pulled your latest commit 14de2ea and confirm that it's working on Multical 602 without any changes. Only installed some 15 mins. ago, so no long term experience - yet 😉 Took your advice and ordered ready made ir sensors with housing from AR Elektronik.

That's great to hear, thanks @htvekov ! 🙏

Any long term experience regarding battery drain issues using e.g. 10 min/hourly updates in production ?

I actually don't know. The battery level is not available to read, and I'm not sure if it's available in the meter menu either. But for the same reason I have set it read out only 1 time per minute.

The tech sheet has some expected battery life time numbers, maybe that can help: https://documentation.kamstrup.com/docs/MULTICAL_602/en-GB/Technical_description/CONT90C6D93022A54253A84D8345A5325B55/?page=81

Thank you for this ESPHome Custom Component. Really appreciated! 😎

My pleasure! Happy to help ☺️

@htvekov
Copy link

htvekov commented Sep 20, 2023

To avoid ir port 'reading qouta' issues, as observed in other threads for other meters, I've for now set mine to 10 min. interval. That should be sufficient data for my district heating usage.

And as I'm using a Multical 602, I've revised my uart config to two stop bits. Can't see any difference in behaviour with one or two stop bits, though.

One thing has caught my attention. If I'm not consuming (power value zero on the Multical display) then the power sensor value isn't updated nor returned at all, leaving the sensor state in HA as unavailable for hours. I would expect the sensor to be updated with value zero when not consuming ? Haven't had time to look at the actual code - yet.

image

When consuming, the power sensor of course is returned with a value.

image

Next step is to check if I can read out anything from my Landis Gyr / Kamstrup UW50 cold water meter with a tweaked version of your repo 🤞🤞🤞😀Hopefully registers are identical. Couldn't really find anything usefull when searching for info for the UW50 meter.

@cenobitedk
Copy link
Owner

And as I'm using a Multical 602, I've revised my uart config to two stop bits. Can't see any difference in behaviour with one or two stop bits, though.

Okay, thanks for the info. Good to know.

One thing has caught my attention. If I'm not consuming (power value zero on the Multical display) then the power sensor value isn't updated nor returned at all, leaving the sensor state in HA as unavailable for hours. I would expect the sensor to be updated with value zero when not consuming ? Haven't had time to look at the actual code - yet.

Interesting. I'll take a look at the code and see if I can spot why it's not being published.

Next step is to check if I can read out anything from my Landis Gyr / Kamstrup UW50 cold water meter with a tweaked version of your repo 🤞🤞🤞😀Hopefully registers are identical. Couldn't really find anything usefull when searching for info for the UW50 meter.

As far as I can tell the UW50 sensor needs to be connected to a Multical meter. But Landis+Gyr only seem to make power meters, right?

@htvekov
Copy link

htvekov commented Sep 20, 2023

Great if you could look at the code 🙂
AFAIK Landis Gyr has abandoned some meter types now and stick mainly with power meters (but I'm not 100% certain about this)
Don't believe they make cold water meters any longer. I had hoped it used the KMP protocol for the IR port, but I get no responses at all. Other Landis Gyr water meters stick with the 62056-21 standard. But I don't have any details at all.

My cold water meter is this type depicted below. My version has an IR port at the red marked circle.

image

@cenobitedk
Copy link
Owner

Great if you could look at the code 🙂

I looked and the issue is actually fairly evident. During readout the value starts as 0 and is overwritten with the meter value. If the value is still 0 after a complete readout, the value is not published, because 0 is equal to any error case (timeout, CRC error, bad data, etc.).

A large part of the code is sourced from other repositories, and it is not sophisticated enough to distinguish between an error situation or an actual 0 value.

I don't have a solution for this atm. But it could be possible to utilize the force_update option eventually.

However, I'm a bit surprised you get 0 power. The lowest number I have over the past 10 days is 0.1, and typically around 0.3 in idle state. I'm not sure how power is calculated, but I'd presume it involves the temp diff, which I can see is as low as 1.3° on your first screenshot, where mine is around 3°. Maybe your equipment is newer and more efficient, that could explain it.

... Other Landis Gyr water meters stick with the 62056-21 standard. But I don't have any details at all.

I see a lot of their meters use the EN 62056-21:2002 standard, so I would try that. See this https://aquaticus.info/iec62056.html and this https://community.home-assistant.io/t/new-iec62056-21-component/555236.
I can't figure if DLMS is the same, but could be relevant https://www.google.dk/search?q=esphome+dlms

@htvekov
Copy link

htvekov commented Sep 20, 2023

I guess using force_update on the esphome sensor won't work, as the sensor isn't updated with the zero value. So forcing the update to HA will just force the sensors prior value. But at least HA's sensor won't show as unavailable.
I'll test this and get back to you.

Great with the 62056 ESPHome component reference 🎉😎
I had missed that one completely doing my searches, thank a lot. I expect to be able to make progress with this.

@cenobitedk
Copy link
Owner

I guess using force_update on the esphome sensor won't work, as the sensor isn't updated with the zero value. So forcing the update to HA will just force the sensors prior value. But at least HA's sensor won't show as unavailable. I'll test this and get back to you.

No it won't work as is now. I'll need to update the code to check for force_update before it can work. :)

Great with the 62056 ESPHome component reference 🎉😎 I had missed that one completely doing my searches, thank a lot. I expect to be able to make progress with this.

Happy to help! 🍻

@htvekov
Copy link

htvekov commented Sep 21, 2023

At no time are any negative values read from the meter and pushed to the sensors, So I've made a crude temporary quickfix by setting the rval float startvalue to -1

// kamReadReg - read a Kamstrup register
    float Read(unsigned int registerId)
    {

        char recvmsg[40]; // buffer of bytes to hold the received data
        float rval = -1;   // this will hold the final value

And just checking for that value when pushing the state instead of checking for a non zero value

void update() override
  {
    ESP_LOGD(TAG, "Start update");

    float energy = _kmp->HeatEnergy();
    if (energy != -1)
      sensor_energy->publish_state(energy);

    float volume = _kmp->Volume();
    if (volume != -1)
      sensor_volume->publish_state(volume);
      ...
[16:16:38][D][uart_debug:114]: >>> 80:3F:10:01:00:1B:BF:1B:F2:44:0D
[16:16:39][W][Multical402:102]: Decoded data: 0.000000
[16:16:39][D][sensor:093]: 'Multical Power': Sending state 0.00000 kW with 1 decimals of accuracy
[16:16:39][D][uart_debug:114]: <<< 40:3F:10:00:1B:BF:00:04:00:00:00:00:00:10:93:0D

This will for sure work when values are correctly read without any errors and if no bytes are read at all (timeout)
Haven't checked what happens if CRC errors occurs. Perhaps it will also work 🤔 (if no bytes are returned 🤞)

A proper and more correct solution could be to introduce an error flag and instead push states according to that flag

@htvekov
Copy link

htvekov commented Sep 22, 2023

Just tested if the quickfix would handle CRC errrors as well. It did. So basically all happy/error flows will be handled properly with that quickfix.

Not pretty, but it works 🙂

@cenobitedk
Copy link
Owner

That's great @htvekov!

How did you verify the CRC errors?

@cenobitedk
Copy link
Owner

At no time are any negative values read from the meter

In this specific use case you are right. But for other Multical meters this might be an issue if one were to create a general KMP esphome component.

A proper and more correct solution could be to introduce an error flag and instead push states according to that flag

Absolutely. This was my original idea, but it took much more time than I anticipated and ended up with a simple solution to get going.

@htvekov
Copy link

htvekov commented Sep 25, 2023

That's great @htvekov!

How did you verify the CRC errors?

Manipulated the code to calculate wrong CRC 😆

@htvekov
Copy link

htvekov commented Sep 25, 2023

At no time are any negative values read from the meter

In this specific use case you are right. But for other Multical meters this might be an issue if one were to create a general KMP esphome component.

Yep. As I wrote: Not pretty, but it works 🙂
Can't really think of any value from a production environment that could be negative besides electricity house consumption total (export to grid). But as any kind of register values could be read with a generic component, an error flag must be introduced for a proper solution. But in 99% of all use cases I guess -1 value as flag would work perfectly.

@htvekov
Copy link

htvekov commented Sep 25, 2023

Absolutely. This was my original idea, but it took much more time than I anticipated and ended up with a simple solution to get going.

Is a PR in the pipeline then ?

@cenobitedk
Copy link
Owner

cenobitedk commented Sep 28, 2023

Is a PR in the pipeline then ?

Sort of. I want to make it, but first I want to make a sensor for my electricity meter. It has an optical port but unfortunately is using and old ANSI C 12.18 standard which I haven't found any implementation for. I did find a library for ESP but it needs to be adapted to work with esphome.
But once that's working I'll return to the general KMP component.

@htvekov
Copy link

htvekov commented Sep 28, 2023

Sort of. I want to make it, but first I want to make a sensor for my electricity meter. It has an optical port but unfortunately is using and old ANSI C 12.18 standard which I haven't found any implementation for. I did find a library for ESP but it needs to be adapted to work with esphome. But once that's working I'll return to the general KMP component.

No rush 🙂
I've a perfectly working solution now for my environment.
But when you get the job done I'll switch to generic component. Happy to do some tests when you get there 👍

Currently I've other issues to attend. I'm struggling with my touchline climate component (underfloor heating system) trying to implement a forced state change based on current- and target temperature calculation. The client doesn't provide registers for the valves states, so they're hardcoded to heating . The real challenge (for me) is that it's Python and I've zero knowledge about this 🙄😫 😁

@htvekov
Copy link

htvekov commented Nov 8, 2023

@cenobitedk

Just FYI
Kamstrup FlowIQ 220 water meter reference

https://community.home-assistant.io/t/kamstrup-flowiq-2200/403109/7

@cenobitedk
Copy link
Owner

@htvekov Cool! I have the exact same meter as well, and I'm working on that atm. 😆

However I'm not using the optical port for this, but wireless mbus. I had to pay for the decryption key (KEM file) however, but since I only have 2 optical readers (I need the 2nd for the power-meter), and I don't have a generic KMP component yet, I wanted to try something else.
I'm using this repo and modifying it (since it's a little messy), https://github.com/pthalin/esp32-multical21 and it's working well. Right now I want to improve the MQTT integration so that HA sees it automatically.

I was hoping to use this (https://github.com/SzczepanLeon/esphome-components) but it doesn't support B frames and I haven't been able to make it work yet, and I will need to write a driver as well, so a bit more work.

Fun thing though. I found out that my Multical 402 also have a wireless mbus module and bursts out updates. But I don't have the encryption key for this, and don't want to pay again since it's already working fine with the optical reader.

@htvekov
Copy link

htvekov commented Nov 9, 2023

I had aquired two IR probes, so basically that's why I tested the optical solution first for the water meter, before going down the wireless mbus route. I'm a bit baffled that you actually had to pay for keys to access your own data... Perhaps I should try and email my supplier and ask for the keys for both the district heating- and water meter.

Have you managed to find any documentation regarding the actual registers in the FlowIQ 2200 meter (or the Multical 21) ?
I'm looking for documentation on how the info register is organized. Guess it's a bit register for the different 'events' - Burst, leaking, reverse flow, tamper etc. But I'm not really interested in discovering these the 'hard way' by actually leaving the tap open and running for 24 hours or bursting a pipe for that matter 😆The meter should also report the water temperature, ambiance temperature and some average temperature values.

So far (three days and counting), I've not experienced any register read throttle issues as has been reported from all other users trying to read out data using the optical port. I guess my meter is a newer version that hopefully doesn't have that throttle restriction in the firmware. The meter itself also seems to be an altered version when I compare with pictures on the web. The mbus radio is installed in a 'plastic cap' kind of module that can be removed from the meter. I guess the module could be replaced with whatever communication module needed for that specific country/region.

I'll put up my production configuration for the IQ2200 meter as well, when I'm done and ready locating the last registers.

@htvekov
Copy link

htvekov commented Nov 9, 2023

Just by accident I found a price sheet for Sabro Vandværk here in Denmark. 700 dkk + VAT for keys to be able to read your own data....
Seems to be a new profitable way to earn some easy money for the utility companies.
Incredible that this behaviour is actually legal. I had the naive idea that utility companies could only charge customers with the documented expence. Seems I need to reconsider that...

@cenobitedk
Copy link
Owner

I'm a bit baffled that you actually had to pay for keys to access your own data...

Incredible that this behaviour is actually legal.

I was surprised as well but the explanation makes sense. I gain wireless access to the meter, and if/when I move they will have to replace the meter, so I no longer have access. I'm assuming here that they don't have means to change the decryption key remotely, or that it require physical access, or that it's only Kamstrup can do it. Something along those lines.

Have you managed to find any documentation regarding the actual registers in the FlowIQ 2200 meter (or the Multical 21) ?

Unfortunately no, but I think you can get technical documentation from Kamstrup. According to this issue (https://stackoverflow.com/questions/29392226/wm-bus-extended-layer-decoding) a user was provided documentation when requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants