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
147 stars 10 forks source link

Amsleser (AmsToMqttBridge) timeout #51

Open mariusaad opened 2 years ago

mariusaad commented 2 years ago

Version of the custom_component

2022.10.2

Configuration


Kaifa MA105H2E -> POW-U+ (amsleser.no) -> MQTT payload type: Raw data (bytes) -> mosquitto broker in home assistant -> amshan

Describe the bug

Possibly same as #44, but not quite same debug message.

Trying to integrate amshan in home assistant using a POW-U+ reader from amsleser.no with AmsToMqttBridge, gives a timeout error as shown in picture below:

bilde

Using the payload type: Raw data (bytes) as mqtt setup in AmsToMqttBridge software. Debug info pasted below.

Let me know if you need any other debug info, or if this is a problem with the format from the AmsToMqttBridge software.

Debug log


2022-10-16 20:26:56.672 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323341
2022-10-16 20:26:58.623 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323431
2022-10-16 20:27:00.993 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 303230393039303734423436344435463330333033313039313033363339333733303336333333313334333033313330333633323334333033373039303834443431333133303335343833323435303630303030303233363036303030303030303030363030303030303030303630303030303042333036303030303041363130363030303030393132
2022-10-16 20:27:02.665 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323434
2022-10-16 20:27:04.668 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323337
2022-10-16 20:27:06.659 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323343
dagtommy commented 1 year ago

Having the same issue using POW-K from amsleser. Worth mention that I run 2.1.11 on the AMS reader

davols commented 1 year ago

Same issue with POW-U from amsleser. Running 2.1.13 With home-assistant payload:

2022-11-13 00:31:49.215 DEBUG (MainThread) [custom_components.amshan.metercon] Ignore JSON in payload without HDLC framing from topic amsreader/realtime: {'max': 1.8, 'peaks': [2.51, 1.39, 1.6], 'threshold': 5, 'hour': {'use': 0.29, 'cost': 0.0, 'produced': 0.0}, 'day': {'use': 0.29, 'cost': 0.0, 'produced': 0.0}, 'month': {'use': 79.34, 'cost': 0.0, 'produced': 0.0}}
2022-11-13 00:31:51.117 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure.
2022-11-13 00:31:51.245 DEBUG (MainThread) [custom_components.amshan.metercon] Ignore JSON in payload without HDLC framing from topic amsreader/power: {'P': 626}

With json payload:

2022-11-13 00:10:13.480 DEBUG (MainThread) [custom_components.amshan.metercon] Ignore JSON in payload without HDLC framing from topic amsreader: {'id': '58:CF:79:A0:48:2E', 'name': 'amsreader', 'up': 189, 't': 1668294610, 'vcc': 3.297, 'rssi': -72, 'temp': -127.0, 'data': {'lv': 'KFM_001', 'id': '6970631400789862', 'type': 'MA105H2E', 'P': 624, 'Q': 0, 'PO': 0, 'QO': 473, 'I1': 3.58, 'I2': 0.0, 'I3': 0.0, 'U1': 238.7, 'U2': 0.0, 'U3': 0.0}, 'realtime': {'h': 0.03, 'd': 0.0, 't': 5, 'x': 1.83, 'he': 0.0, 'de': 0.0}}

With raw values (full):

2022-11-13 00:20:25.770 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure.

With raw values (bytes):

2022-11-13 00:22:40.892 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323433
2022-11-13 00:22:43.239 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 303230393039303734423436344435463330333033313039313033363339333733303336333333313334333033303337333833393338333633323039303834443431333133303335343833323435303630303030303234373036303030303030303030363030303030303030303630303030303144433036303030303044343530363030303030393531
2022-11-13 00:22:44.954 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323431
2022-11-13 00:22:46.923 DEBUG (MainThread) [custom_components.amshan.metercon] Got payload without HDLC framing from topic amsreader: 3032303130363030303030323438

In all situations I've verified that POW-U is sending data to MQTT by listening at homeassistant.local:8123/config/mqtt Gui says there is an v2.1.14 available but upgrading does nothing.

or perhaps my issue is related to https://github.com/toreamun/amshan-homeassistant/issues/29

Sending it as home assistant seems to work since I have a device with 41 entities in MQTT. But I can't connect amshan to MQTT regardless of payload in POW-U.

toreamun commented 1 year ago

AmsToMqttBridge encodes the binary data as hex before sending. If I hex decode "30323031303630303030303234332" (from your log) i get 02010600000243. This is just a fragment of the frame (message) from the meter. The integration expect the mqtt message to be full frame as sent from the meter, or the full APDU of the frame. Only the notification-body part of the APDU is in the messages from your log. Timestamp, headers, checksums etc is missing.

AmsToMqttBridge did previously send the full APDU. I can read from the release log that version 2.1.17 had a related fix: "Fixed MQTT raw bytes, now sending full frame as well as application frame". I think the fix may have been broken in later versions, because your samples is not the full frame. Not even the full APDU. See https://github.com/gskjold/AmsToMqttBridge/issues/210 for more info about the expected format.

I am sorry, but I don't have a quick fix to make the integration work with only the nofification-body of the APDU.

ChillZwix commented 10 months ago

Did follow the guide with a Pulse from Tibber. I can see it sending with mqtt explorer, but the AMS integration just keep "Timeout reading data" when I try to add it to my system.

Home Assistant Core 2023.12.3 Supervisor 2023.11.6 Operating System 11.2 Frontend 20231208.2