cenobitedk / esphome_multical402

Kamstrup Multical 402 for esphome
29 stars 6 forks source link

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

Open MBJ-M2BI opened 1 year ago

MBJ-M2BI commented 1 year ago

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:

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:

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

custom_component:

sensor:

Multical Custom Sensors

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 commented 1 year ago

@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 commented 1 year ago

And check you are connecting the IR head correctly.

MBJ-M2BI commented 1 year ago

I can try that again. But I have an original kamstrup optical eye connected to the raspberry pi where home assistant is installed and that one is getting data, but I would like to have it wireless on a esp unit, but could not get any values, I think I tried the play button, but could try again

Sendt fra min iPhone

Den 17. feb. 2023 kl. 22.07 skrev Ali Bahrami @.***>:



And check you are connecting the IR head correctly.

— Reply to this email directly, view it on GitHubhttps://github.com/cenobitedk/esphome_multical402/issues/3#issuecomment-1435268809, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5FPETB65DEIK3ZZMDOMOELWX7SCFANCNFSM6AAAAAAU72CR4Q. You are receiving this because you were mentioned.Message ID: @.***>

0x414c49 commented 1 year ago

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

https://github.com/ProudElm/ESPHome_multical_sensor

MBJ-M2BI commented 1 year ago

I have tried both this morning, without any luck, the one I use from kamstrup connected directly to the raspberry pi with HA is using the HACS 402 kamstrup integration, and that is just working.

But in the case I need it to be running on esp home, I hoped you could help me out with what I am doing wrong ? Maybe some settings in my .yaml is wrong or something like that, as I use esp_01s board as showed I the link about my hardware

Sendt fra min iPhone

Den 17. feb. 2023 kl. 23.18 skrev Ali Bahrami @.***>:



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

https://github.com/ProudElm/ESPHome_multical_sensor

— Reply to this email directly, view it on GitHubhttps://github.com/cenobitedk/esphome_multical402/issues/3#issuecomment-1435339752, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5FPETELZA4FMKI2CVE2JRTWX72MHANCNFSM6AAAAAAU72CR4Q. You are receiving this because you were mentioned.Message ID: @.***>

0x414c49 commented 1 year ago

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 commented 1 year ago

Thank you, i will try that

Sendt fra min iPhone

Den 7. mar. 2023 kl. 14.11 skrev Ali Bahrami @.***>:



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

rx_pin: GPIO03 tx_pin: GPIO01

[image]https://user-images.githubusercontent.com/57097646/223431405-4a3c3c16-dddb-47f4-a649-abdf85b1d833.png

Maybe you need to work with IO0 and IO1

— Reply to this email directly, view it on GitHubhttps://github.com/cenobitedk/esphome_multical402/issues/3#issuecomment-1458147115, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5FPETCJX2NUJBAA24HYVQLW24XZLANCNFSM6AAAAAAU72CR4Q. You are receiving this because you were mentioned.Message ID: @.***>

cenobitedk commented 1 year ago

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:

htvekov commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 12 months ago

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 commented 11 months ago

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 commented 11 months ago

That's great @htvekov!

How did you verify the CRC errors?

cenobitedk commented 11 months ago

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 commented 11 months ago

That's great @htvekov!

How did you verify the CRC errors?

Manipulated the code to calculate wrong CRC 😆

htvekov commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 10 months ago

@cenobitedk

Just FYI Kamstrup FlowIQ 220 water meter reference

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

cenobitedk commented 10 months ago

@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 commented 10 months ago

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 commented 10 months ago

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 commented 9 months ago

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.