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

Problem with Energyintelligence P1 #37

Closed TheBigDaddyT closed 2 years ago

TheBigDaddyT commented 2 years ago

Version of the custom_component

2022.4.0

Configuration

//configuration.yaml //**** //# Loads default set of integrations. Do not remove. //default_config: // //# Text to speech //tts: // - platform: google_translate // //automation: !include automations.yaml //script: !include scripts.yaml //scene: !include scenes.yaml // //logger: // default: info // logs: // custom_components.amshan: debug

Describe the bug

I have a set up with the energy meter Landis+Gyr E360 and have then connected a P1-reader from Energyintelligence.se. When I configure my Mosquitto to listen to topic "esp32_C45130/raw/#" my P1-reader it receives messages. For example: "Message 459 received on esp32_C45130/raw/Current/Instant/L1/value at 11:33 AM: 004.5 QoS: 0 - Retain: false"

And

"Message 907 received on esp32_C45130/raw/raw at 11:35 AM: /LGF5E360

0-0:1.0.0(220627103550W) 1-0:1.8.0(00000153.252kWh) 1-0:2.8.0(00000070.244kWh) 1-0:3.8.0(00000013.973kVArh) 1-0:4.8.0(00000026.544kVArh) 1-0:1.7.0(0000.000kW) 1-0:2.7.0(0003.531kW) 1-0:3.7.0(0000.209kVAr) 1-0:4.7.0(0000.000kVAr) 1-0:21.7.0(0000.000kW) 1-0:22.7.0(0001.003kW) 1-0:41.7.0(0000.000kW) 1-0:42.7.0(0000.392kW) 1-0:61.7.0(0000.000kW) 1-0:62.7.0(0002.135kW) 1-0:23.7.0(0000.000kVAr) 1-0:24.7.0(0000.215kVAr) 1-0:43.7.0(0000.584kVAr) 1-0:44.7.0(0000.000kVAr) 1-0:63.7.0(0000.000kVAr) 1-0:64.7.0(0000.160kVAr) 1-0:32.7.0(237.7V) 1-0:52.7.0(235.1V) 1-0:72.7.0(238.1V) 1-0:31.7.0(004.3A) 1-0:51.7.0(003.0A) 1-0:71.7.0(009.0A) !0C6A QoS: 0 - Retain: false"

But when I try to configure AMS HAN meter via MQTT I get the error "Timeout reading data". Have tried whit different topics but the same error message for all: esp32_C45130/raw esp32_C45130/raw/raw esp32_C45130/ esp32_C45130/# esp32_C45130/raw/# esp32_C45130/raw/raw/#

Debug log

This is all I can find when searching for amshan in the logs:

2022-06-27 13:54:17 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-06-27 13:54:29 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-06-27 13:54:41 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-06-27 13:54:53 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-06-27 13:55:05 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-06-27 13:55:17 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure.

TheBigDaddyT commented 2 years ago

When I try with the topic "esp32_C45130/raw/#" I get this in the log:

Log Details (ERROR)

Logger: homeassistant.util.logging

Source: util/logging.py:116 First occurred: 2:02:48 PM (1 occurrences) Last logged: 2:02:48 PM

Exception in message_received when handling msg on 'esp32_C45130/raw/device/packet-status/Unknown/dirty': 'b'1'' Traceback (most recent call last): File "/config/custom_components/amshan/config_flow.py", line 410, in message_received meter_message = get_meter_message(mqtt_message) File "/config/custom_components/amshan/metercon.py", line 140, in get_meter_message message = _try_read_meter_message(mqtt_message.payload) File "/config/custom_components/amshan/metercon.py", line 233, in _try_read_meter_message else bytes.fromhex(payload.decode("utf8")) ValueError: non-hexadecimal number found in fromhex() arg at position 1

toreamun commented 2 years ago

Is it possible that you have an old firmware? Another user had trouble caused by a bug in the Energyintelligence firemware.

Can you try to dump to hex (mosquitto_sub -F %X) or enable debug logging

TheBigDaddyT commented 2 years ago

Hi!

I have firmware "3.2_ATOM_20220224-131301" I thought that was the latest but when I look at the old issue and his screendumps in the beginning I can see that he also has "3.2_ATOM_20220224-131301". I have mailed Energyintelligence and asked for a newer firmware.

I thought I had debug logging on? I have this in my configuration.yaml

logger: default: warning logs: custom_components.amshan: debug

And I have created and called the "logger.set_level"

And this is what I get in the logfile

2022-07-11 08:22:27 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration amshan which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-07-11 08:22:27 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-07-11 08:22:30 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly 2022-07-11 08:22:30 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=14 from 2022-07-11 06:21:48.524919) 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of application_credentials is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_button is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of zone is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of counter is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_datetime is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_boolean is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_number is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_select is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of tag is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of input_text is taking over 10 seconds. 2022-07-11 08:23:09 WARNING (MainThread) [homeassistant.setup] Setup of timer is taking over 10 seconds. 2022-07-11 08:59:53 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:00:05 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:00:17 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:00:29 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:00:41 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:00:53 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:03:31 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:03:43 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:03:55 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:04:07 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:04:19 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 09:04:31 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure.

TheBigDaddyT commented 2 years ago

Updated to latest firmware, "3.3_ATOM_20220502-082159" and tried again but same error ("Timeout reading data") when configuring AMS HAN Meter - MQTT. Nothing new in the log still: 2022-07-11 14:07:33 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:07:45 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:07:57 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:08:09 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:08:21 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:08:33 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:10:01 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:10:13 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:10:25 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:10:37 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:10:49 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure. 2022-07-11 14:11:01 DEBUG (MainThread) [custom_components.amshan.config_flow] Timout waiting 12 seconds for meter measure.

Ran the command "mosquitto_sub -t esp32_C45130/raw/# -F %X" don´t know if the syntax was correct :-) But I get this every 10 sek or so:

2F4C474635453336300D0A0D0A302D303A312E302E302832323037313131333432353057290D0A312D303A312E382E302830303030303833342E3139352A6B5768290D0A312D303A322E382E302830303030303331342E3537342A6B5768290D0A312D303A332E382E302830303030303037302E3636352A6B56417268290D0A312D303A342E382E302830303030303133372E3634382A6B56417268290D0A312D303A312E372E3028303030302E3030302A6B57290D0A312D303A322E372E3028303030352E3039372A6B57290D0A312D303A332E372E3028303030302E3137312A6B564172290D0A312D303A342E372E3028303030302E3030302A6B564172290D0A312D303A32312E372E3028303030302E3030302A6B57290D0A312D303A32322E372E3028303030322E3331342A6B57290D0A312D303A34312E372E3028303030302E3030302A6B57290D0A312D303A34322E372E3028303030302E3530332A6B57290D0A312D303A36312E372E3028303030302E3030302A6B57290D0A312D303A36322E372E3028303030322E3238302A6B57290D0A312D303A32332E372E3028303030302E3030302A6B564172290D0A312D303A32342E372E3028303030302E3230372A6B564172290D0A312D303A34332E372E3028303030302E3532362A6B564172290D0A312D303A34342E372E3028303030302E3030302A6B564172290D0A312D303A36332E372E3028303030302E3030302A6B564172290D0A312D303A36342E372E3028303030302E3134382A6B564172290D0A312D303A33322E372E30283233372E392A56290D0A312D303A35322E372E30283233332E372A56290D0A312D303A37322E372E30283233362E362A56290D0A312D303A33312E372E30283030392E372A41290D0A312D303A35312E372E30283030332E312A41290D0A312D303A37312E372E30283030392E362A41290D0A21434335390D0A 30303030303833342E313935 6B5768 30303030303331342E353734 6B5768 30303030303037302E363635 6B56417268 30303030303133372E363438 6B56417268 303030302E303030 6B57 303030352E303937 6B57 303030302E313731 6B564172 303030302E303030 6B564172 303030302E303030 6B57 303030322E333134 6B57 303030302E303030 6B57 303030302E353033 6B57 303030302E303030 6B57 303030322E323830 6B57 303030302E303030 6B564172 303030302E323037 6B564172 303030302E353236 6B564172 303030302E303030 6B564172 303030302E303030 6B564172 303030302E313438 6B564172 3233372E39 56 3233332E37 56 3233362E36 56 3030392E37 41 3030332E31 41 3030392E36 41 323035 323032322D30372D31312031323A34323A353120555443

toreamun commented 2 years ago

It seems that your firmware has correct line endings (0d0a). This must be something else. Give me a few days and I will try to debug it using you hex dump.

TheBigDaddyT commented 2 years ago

Thanks a lot!

//Rasmus

toreamun commented 2 years ago

The topic should not end with '#'.

From the documentation, it seems like the correct topic is esp32_C45130/raw, but from your log the correct seems to be esp32_C45130/raw/raw.

Can you provide me with mosquitto hex dumps with a single message from both esp32_C45130/raw and esp32_C45130/raw/raw?

TheBigDaddyT commented 2 years ago

mosquitto_sub -t esp32_C45130/raw/raw -F %X

2F4C474635453336300D0A0D0A302D303A312E302E302832323037313430363334333057290D0A312D303A312E382E302830303030303934342E3437362A6B5768290D0A312D303A322E382E302830303030303337362E3632302A6B5768290D0A312D303A332E382E302830303030303038312E3239362A6B56417268290D0A312D303A342E382E302830303030303136312E3237342A6B56417268290D0A312D303A312E372E3028303030302E3030302A6B57290D0A312D303A322E372E3028303030312E3631342A6B57290D0A312D303A332E372E3028303030302E3030302A6B564172290D0A312D303A342E372E3028303030302E3136392A6B564172290D0A312D303A32312E372E3028303030302E3030302A6B57290D0A312D303A32322E372E3028303030302E3931332A6B57290D0A312D303A34312E372E3028303030302E3036392A6B57290D0A312D303A34322E372E3028303030302E3030302A6B57290D0A312D303A36312E372E3028303030302E3030302A6B57290D0A312D303A36322E372E3028303030302E3737302A6B57290D0A312D303A32332E372E3028303030302E3030302A6B564172290D0A312D303A32342E372E3028303030302E3135362A6B564172290D0A312D303A34332E372E3028303030302E3037362A6B564172290D0A312D303A34342E372E3028303030302E3030302A6B564172290D0A312D303A36332E372E3028303030302E3030302A6B564172290D0A312D303A36342E372E3028303030302E3038382A6B564172290D0A312D303A33322E372E30283233352E332A56290D0A312D303A35322E372E30283233352E332A56290D0A312D303A37322E372E30283233332E332A56290D0A312D303A33312E372E30283030332E392A41290D0A312D303A35312E372E30283030302E342A41290D0A312D303A37312E372E30283030332E332A41290D0A21303539350D0A

mosquitto_sub -t esp32_C45130/raw -F %X

Does not catch anything

Olverine commented 2 years ago

Hello! Firmware developer at Energy Intelligence here. Have you changed the MQTT base topic in the web interface by any chance?

TheBigDaddyT commented 2 years ago

Hi

I have tried a couple of different topic in order to get it to work but for everything I have written in this thread the topic has been the "standard one", _esp32C45130/raw

image

Olverine commented 2 years ago

The base topic is not supposed to include /raw this explains why the message gets sent to esp32_C45130/raw/raw instead of esp32_C45130/raw. raw is a subtopic of the base topic. Different data points parsed from the raw data is also published to various other sub topics.

TheBigDaddyT commented 2 years ago

Ahhhhhh so I should just change it to esp32_C45130? That worked a lot better :-)

Thanks for all the help, the installation of AMS HAN Meter worked now.

//Rasmus