toreamun / amshan-homeassistant

Home Assistant integrasjon for strømmålere (AMS/HAN/P1). Integrasjonen støter både streaming (serieport/TCP-IP) og MQTT (Tibber Pulse, energyintelligence.se etc)
MIT License
146 stars 9 forks source link

Scale value problem for cumulative data #43

Open StarkJohan opened 2 years ago

StarkJohan commented 2 years ago

With the default config dialog scale value of 1 all sensors report correctly (power, current, voltage) except the cumulative values that in my case would need a scale value of 0.1. E.g. the meter has used 38062 kWh in total (as read on the display) but the "Cumulative hourly active import energy (A+) (Q1+Q4)" reports 380620 kWh. As this is the sensor I would like to use as the total consumption for the Energy dashboard in HA this setup does not currently work for this meter.

Not sure what the best solution would be but if the meter reports "incorrect" values maybe more than one scale value is needed in the configuration dialog? I.e. one general scale value and one for the cumulative measurements?

For now I've changed the scale values in sensor.py to fit my needs as a workaround.

toreamun commented 2 years ago

Are you able to provide raw sample data from MQTT topic?

toreamun commented 1 year ago

@StarkJohan Are you able to provide raw sample data from MQTT topic?

StarkJohan commented 1 year ago

Sorry for not getting back to you on this Tore. I've had to prioritize other things. I would be able to provide data but I've been using AmsToMqttBridge which has been spot on for the hourly data for 4-5 weeks at this point. As it "just works" (after a few code adjustments to fit my needs, e.g. the above mentioned scale values) I will have to return to help you get this sorted at a later date. BTW I'm pretty sure this is not a bug in your code but an error in Kamstrups ability to conform to the standards as I have the exact same issue when decoding the data with AmsToMqttBridge or the HAN python library.

papaste commented 1 year ago

image

@toreamun Just installed. What an amazing integration! I am also getting incorrectly scalead cumulative values. It would be correct with a scaling of 0.1. Everything else is scaled properly.

eribi commented 10 months ago

I do have the same issue. How can I help to solve this?

papaste commented 10 months ago

@eribi Here is a the workaround I am using: Disable the faulty entities: image

Add the following to your configuration.yaml:

sensor:
  - platform: integration
    source: sensor.kamstrup_active_power_import
    name: Energy import (kWh)
    unit_prefix: k
    round: 2
  - platform: integration
    source: sensor.kamstrup_active_power_export
    name: Energi export (kWh)
    unit_prefix: k
    round: 2
epideme commented 6 months ago

@toreamun Here's a snippet of a hex dump of the hourly data packet over MQTT from Kamstrup_V0001: Raw file and hex translation also attached. Kamstrup_V0001-pulse-mqtt.zip

00000dc0: 7ea1 2c2b 2113 fc04 e6e7 000f 0000 0000  ~.,+!...........
00000dd0: 0c07 e802 1604 1000 37ff 8000 0002 230a  ........7.....#.
00000de0: 0e4b 616d 7374 7275 705f 5630 3030 3109  .Kamstrup_V0001.
00000df0: 0601 0100 0005 ff0a 1035 3730 3635 3637  .........5706567
00000e00: 3334 3631 3533 3335 3409 0601 0160 0101  346153354....`..
00000e10: ff0a 1236 3834 3131 3338 424e 3234 3531  ...6841138BN2451
00000e20: 3031 3039 3209 0601 0101 0700 ff06 0000  01092...........
00000e30: 0c8a 0906 0101 0207 00ff 0600 0000 0009  ................
00000e40: 0601 0103 0700 ff06 0000 05aa 0906 0101  ................
00000e50: 0407 00ff 0600 0000 0009 0601 011f 0700  ................
00000e60: ff06 0000 0258 0906 0101 3307 00ff 0600  .....X....3.....
00000e70: 0001 e709 0601 0147 0700 ff06 0000 01c8  .......G........
00000e80: 0906 0101 2007 00ff 1200 e809 0601 0134  .... ..........4
00000e90: 0700 ff12 00ec 0906 0101 4807 00ff 1200  ..........H.....
00000ea0: ea09 0600 0101 0000 ff09 0c07 e802 1604  ................
00000eb0: 1000 37ff 8000 0009 0601 0101 0800 ff06  ..7.............
00000ec0: 0100 92b2 0906 0101 0208 00ff 0600 1c23  ...............#
00000ed0: 0d09 0601 0103 0800 ff06 003b b9eb 0906  ...........;....
00000ee0: 0101 0408 00ff 0600 1a5c 0d75 297e 0a    .........\.u)~.