Giter Club home page Giter Club logo

Comments (5)

turbokongen avatar turbokongen commented on May 26, 2024 1

Fixed in #91 v1.9.8 Thank you for reporting

from hass-ams.

turbokongen avatar turbokongen commented on May 26, 2024

Can you enable debug, and attach the log. I may have an Idea of what is wrong, but I need the logs to confirm. 👍

from hass-ams.

joernnilsson avatar joernnilsson commented on May 26, 2024

Attached log, from boot to having seen the issue at least once

ams.log

from hass-ams.

joernnilsson avatar joernnilsson commented on May 26, 2024

I printed the parsed states as well, and it seems to happen when a larger chunk of data is read:

2022-11-07 09:44:38.838 DEBUG (Thread-3 (connect)) [custom_components.ams] data read from port=[126, 160, 39, 1, 2, 1, 16, 90, 135, 230, 231, 0, 15, 64, 0, 0, 0, 9, 12, 7, 230, 11, 7, 1, 9, 44, 38, 255, 128, 0, 0, 2, 1, 6, 0, 0, 2, 37, 242, 181, 126]
2022-11-07 09:44:38.839 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_import (state: 549)
2022-11-07 09:44:38.839 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_export (state: 0.0)
2022-11-07 09:44:38.840 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_import (state: 0)
2022-11-07 09:44:38.840 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_export (state: 81)
2022-11-07 09:44:38.840 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l1 (state: 0.787)
2022-11-07 09:44:38.840 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l2 (state: 1.874)
2022-11-07 09:44:38.841 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l3 (state: 2.108)
2022-11-07 09:44:38.841 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l1 (state: 231.7)
2022-11-07 09:44:38.841 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l2 (state: 0.0)
2022-11-07 09:44:38.841 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l3 (state: 234.8)
2022-11-07 09:44:41.291 DEBUG (Thread-3 (connect)) [custom_components.ams] data read from port=[126, 160, 121, 1, 2, 1, 16, 128, 147, 230, 231, 0, 15, 64, 0, 0, 0, 9, 12, 7, 230, 11, 7, 1, 9, 44, 40, 255, 128, 0, 0, 2, 13, 9, 7, 75, 70, 77, 95, 48, 48, 49, 9, 16, 54, 57, 55, 48, 54, 51, 49, 52, 48, 52, 49, 50, 57, 57, 53, 52, 9, 8, 77, 65, 51, 48, 52, 72, 51, 69, 6, 0, 0, 2, 34, 6, 0, 0, 0, 0, 6, 0, 0, 0, 0, 6, 0, 0, 0, 81, 6, 0, 0, 3, 13, 6, 0, 0, 7, 37, 6, 0, 0, 8, 14, 6, 0, 0, 9, 16, 6, 0, 0, 0, 0, 6, 0, 0, 9, 44, 111, 222, 126]
2022-11-07 09:44:41.291 DEBUG (Thread-3 (connect)) [custom_components.ams.parsers.kaifa] kaifa meter_type length is 8
2022-11-07 09:44:41.292 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_import (state: 100663298)
2022-11-07 09:44:41.292 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_export (state: 0.0)
2022-11-07 09:44:41.293 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_import (state: 0)
2022-11-07 09:44:41.293 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_export (state: 81)
2022-11-07 09:44:41.294 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l1 (state: 0.781)
2022-11-07 09:44:41.294 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l2 (state: 1.829)
2022-11-07 09:44:41.295 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l3 (state: 2.062)
2022-11-07 09:44:41.295 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l1 (state: 232.0)
2022-11-07 09:44:41.296 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l2 (state: 0.0)
2022-11-07 09:44:41.296 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l3 (state: 234.8)
2022-11-07 09:44:42.899 DEBUG (Thread-3 (connect)) [custom_components.ams] data read from port=[126, 160, 39, 1, 2, 1, 16, 90, 135, 230, 231, 0, 15, 64, 0, 0, 0, 9, 12, 7, 230, 11, 7, 1, 9, 44, 42, 255, 128, 0, 0, 2, 1, 6, 0, 0, 2, 48, 68, 253, 126]
2022-11-07 09:44:42.900 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_import (state: 560)
2022-11-07 09:44:42.901 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_active_power_export (state: 0.0)
2022-11-07 09:44:42.901 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_import (state: 0)
2022-11-07 09:44:42.901 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_reactive_power_export (state: 81)
2022-11-07 09:44:42.901 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l1 (state: 0.781)
2022-11-07 09:44:42.902 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l2 (state: 1.829)
2022-11-07 09:44:42.902 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_current_l3 (state: 2.062)
2022-11-07 09:44:42.902 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l1 (state: 232.0)
2022-11-07 09:44:42.902 DEBUG (Thread-3 (connect)) [custom_components.ams.sensor] Updating sensor ams_voltage_l2 (state: 0.0)

from hass-ams.

joernnilsson avatar joernnilsson commented on May 26, 2024

_LOGGER.debug("kaifa meter_type length is %s", pkt[61])
_offset = 0
if pkt[61] == 7:
_LOGGER.debug("set kaifa _offset to 1")
_offset = 1
han_data[HAN_METER_TYPE] = (
METER_TYPE.get(field_type(fields=pkt[62:70 - _offset], enc=chr), UNKNOWN_METER)
)
han_data["active_power_p"] = byte_decode(fields=pkt[70:74])
sensor_data["ams_active_power_import"] = {
SENSOR_STATE: han_data["active_power_p"],
SENSOR_ATTR: {
"timestamp": han_data["date_time"],
HAN_METER_MANUFACTURER: han_data[
HAN_LIST_VER_ID].title(),
HAN_METER_TYPE: han_data[HAN_METER_TYPE],
HAN_METER_SERIAL: han_data[HAN_METER_SERIAL],
SENSOR_UOM: "W",
SENSOR_ICON: "mdi:gauge",
},
}

Changing the call on line 100 to byte_decode(fields=pkt[71:75]) seems to give correct results on my setup. I wouldn't presume to know the history of these parsers well enough to say it's a solution, but perhaps you have an opinion @turbokongen.

If this is merely an index issue, I can create a PR with the change. If this change brakes something else, we'll have to go a bit deeper.

from hass-ams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.