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

Timeout reading data #44

Closed ozqar closed 2 years ago

ozqar commented 2 years ago

Hi! and thanks for the amazing worker! I am running into trouble on the last step of set-up. Using a tibber puls(han). I am getting the strings on the topic both in homasitent and separate mqtt client. Any tips on the next step of troubleshooting? the log does not produce any useful pointer so I might be looking in the wrong place.

Screenshot 2022-08-31 at 21 58 09
toreamun commented 2 years ago

Have you tried this?

ozqar commented 2 years ago

Thanks for the quick response! Yes I hav check fore the hex strings on the topic and der are som status messages ass wel. So they are there but Amshan dust den to see them. after turning up logging to debug with log shod it aper in?

ozqar commented 2 years ago

okay new update here. Gott the logg working butt dos dis men I don't have a supported meter? it is a Aidon 6534(Aidon_V2) from Norrtälje energi. sam as this maybe?

2022-09-01 20:58:42.517 DEBUG (MainThread) [custom_components.amshan.metercon] Got valid frame of expected length with correct checksum from topic tibber: 7ea2434108831385ebe6e7000f4000000000011b020209060000010000ff090c07e6090104133a32ff8000ff020309060100010700ff060000034702020f00161b020309060100020700ff060000000002020f00161b020309060100030700ff060000000002020f00161d020309060100040700ff060000011d02020f00161d0203090601001f0700ff10001102020fff1621020309060100330700ff10000802020fff1621020309060100470700ff10000c02020fff1621020309060100200700ff12090d02020fff1623020309060100340700ff12091902020fff1623020309060100480700ff12091902020fff1623020309060100150700ff060000019202020f00161b020309060100160700ff060000000002020f00161b020309060100170700ff060000000002020f00161d020309060100180700ff060000004a02020f00161d020309060100290700ff06000000af02020f00161b0203090601002a0700ff060000000002020f00161b0203090601002b0700ff060000000002020f00161d0203090601002c0700ff060000005502020f00161d0203090601003d0700ff060000010502020f00161b0203090601003e0700ff060000000002020f00161b0203090601003f0700ff060000000002020f00161d020309060100400700ff060000007b02020f00161d020309060100010800ff0602a7bbe302020f00161e020309060100020800ff060000000002020f00161e020309060100030800ff0600a831fc02020f001620020309060100040800ff0600228b2f02020f001620fbb87e

2022-09-01 20:58:42.539 DEBUG (MainThread) [custom_components.amshan.config_flow] Decoded measure data is missing required info.

ozqar commented 2 years ago

I haw not fund a solution for this. data gets reported and while analysing the frame and comparing it with the example from Aidon it looks alright. My python skills are not up for finding the function responsible for the info walidaition.

owangen commented 2 years ago

I have the same problem as described. Only thing that I have changed as far as I know is to upgrade AmsToMqttBridge from 2.1.2 to latest 2.1.7

owangen commented 2 years ago

Tried to revert AmsToMqttBridge to 2.1.2, and then all works fine. Will dig more into when I have time to pinpoint where the problem is.

JenusL commented 2 years ago

I have the exact same issue but with a network socket connection and not a MQTT connection.

2022-09-22 22:15:20.720 DEBUG (MainThread) [han.hdlc] Frame of expected length 579 received with good checksum.
2022-09-22 22:15:20.770 DEBUG (MainThread) [custom_components.amshan.config_flow] Decoded measure data is missing required info.
JenusL commented 2 years ago

And I think I found the issue... AMSHAN has several checks for FIELD_METER_MANUFACTURER_ID and FIELD_METER_ID. None of those are in the data from Swedish meters because of GDPR rules. So we would need some way of adding in our own ID when we add the integration and connect to the meter.

BarbaGrump commented 2 years ago

I also get the timeout-message trying to set up the integration in HA (MQTT, Sweden). I see MQTT messages from Pulse in HA (and in MQTT Explorer), so thats working as expected Although I should point out that I've yet to connect my Pulse to my meter...I was promised a new meter, but now they've (OneNordic) pushed it one month due to "internal education"??? WTF! :-(

stamp commented 2 years ago

I can confirm that the issue is the missing FIELD_METER_MANUFACTURER_ID and FIELD_METER_ID parameters that's the issue.

I locally removed all sections from the integration that relates to FIELD_METER_MANUFACTURER_ID and FIELD_METER_ID. Not a perfect solution but it worked.

I have an Swedish Aidon 6484SE meter with a Tibber Pulse HAN connected to it.

stamp_2022-09-30_104712

Can share some raw data from the meter if someone needs it

aherbjornsen commented 2 years ago

I locally removed all sections from the integration that relates to FIELD_METER_MANUFACTURER_ID and FIELD_METER_ID. Not a perfect solution but it worked.

Can you share the changes you made? It's not entirely obvious to me how to change the code without breaking anything.

stamp commented 2 years ago

Sure!

I just searched for FIELD_METER_ID and FIELD_METER_MANUFACTURER_ID and commented out all code that seamed relevant. I also hardcoded meter_id = 1 and manufacturer_id = 1 in _ensure_entities_are_created. I suppose that hardcoded id numbers will have the effect that the integration only can have one meter connected. In my case that is not a problem since the Tibber Pulse thingie is connected directly to my only meter.

diff --git a/custom_components/amshan/config_flow.py b/custom_components/amshan/config_flow.py

index 470ceb9..269b03d 100644
--- a/custom_components/amshan/config_flow.py
+++ b/custom_components/amshan/config_flow.py
@@ -328,13 +328,13 @@ class ConfigFlowValidation:
             if measure is not None:
                 decoded_measure = decoder.decode_message(measure)
                 if decoded_measure:
-                    if (
-                        obis_map.FIELD_METER_ID in decoded_measure
-                        and obis_map.FIELD_METER_MANUFACTURER in decoded_measure
-                    ) or (obis_map.FIELD_METER_MANUFACTURER_ID in decoded_measure):
-                        return MeterInfo.from_measure_data(decoded_measure)
+                    #if (
+                    #    obis_map.FIELD_METER_ID in decoded_measure
+                    #    and obis_map.FIELD_METER_MANUFACTURER in decoded_measure
+                    #) or (obis_map.FIELD_METER_MANUFACTURER_ID in decoded_measure):
+                    return MeterInfo.from_measure_data(decoded_measure)

-                    _LOGGER.debug("Decoded measure data is missing required info.")
+                    #_LOGGER.debug("Decoded measure data is missing required info.")

         raise TimeoutError()

diff --git a/custom_components/amshan/sensor.py b/custom_components/amshan/sensor.py

index 738c187..972a905 100644
--- a/custom_components/amshan/sensor.py
+++ b/custom_components/amshan/sensor.py
@@ -58,18 +58,18 @@ class AmsHanSensorEntityDescription(SensorEntityDescription):
 SENSOR_TYPES: dict[str, AmsHanSensorEntityDescription] = {
     sensor.key: sensor
     for sensor in [
-        AmsHanSensorEntityDescription(
-            key=obis_map.FIELD_METER_ID,
-            entity_category=entity.EntityCategory.DIAGNOSTIC,
-            name="Meter ID",
-            use_configured_scaling=False,
-        ),
-        AmsHanSensorEntityDescription(
-            key=obis_map.FIELD_METER_MANUFACTURER,
-            entity_category=entity.EntityCategory.DIAGNOSTIC,
-            name="Meter manufacturer",
-            use_configured_scaling=False,
-        ),
+        #AmsHanSensorEntityDescription(
+        #    key=obis_map.FIELD_METER_ID,
+        #    entity_category=entity.EntityCategory.DIAGNOSTIC,
+        #    name="Meter ID",
+        #    use_configured_scaling=False,
+        #),
+        #AmsHanSensorEntityDescription(
+        #    key=obis_map.FIELD_METER_MANUFACTURER,
+        #    entity_category=entity.EntityCategory.DIAGNOSTIC,
+        #    name="Meter manufacturer",
+        #    use_configured_scaling=False,
+        #),
         AmsHanSensorEntityDescription(
             key=obis_map.FIELD_METER_TYPE,
             entity_category=entity.EntityCategory.DIAGNOSTIC,
@@ -266,16 +266,16 @@ class AmsHanEntity(SensorEntity):
             raise TypeError("entity_description is required")
         if measure_data is None:
             raise TypeError("measure_data is required")
-        if (
-            obis_map.FIELD_METER_ID not in measure_data
-            and obis_map.FIELD_METER_MANUFACTURER_ID not in measure_data
-        ):
-            raise ValueError(
-                (
-                    f"Expected element {obis_map.FIELD_METER_ID} "
-                    f"{obis_map.FIELD_METER_MANUFACTURER_ID} not in measure_data."
-                )
-            )
+        #if (
+        #    obis_map.FIELD_METER_ID not in measure_data
+        #    and obis_map.FIELD_METER_MANUFACTURER_ID not in measure_data
+        #):
+        #    raise ValueError(
+        #        (
+        #            f"Expected element {obis_map.FIELD_METER_ID} "
+        #            f"{obis_map.FIELD_METER_MANUFACTURER_ID} not in measure_data."
+        #        )
+        #    )
         if new_measure_signal_name is None:
             raise TypeError("new_measure_signal_name is required")

@@ -570,8 +570,8 @@ class MeterMeasureProcessor:
         self, measure_data: dict[str, str | int | float | dt.datetime]
     ) -> None:
         # meter_id or manufacturer_id is required to register entities (required by unique_id).
-        meter_id = measure_data.get(obis_map.FIELD_METER_ID)
-        manufacturer_id = measure_data.get(obis_map.FIELD_METER_MANUFACTURER_ID)
+        meter_id = 1  #measure_data.get(obis_map.FIELD_METER_ID)
+        manufacturer_id = 1  #measure_data.get(obis_map.FIELD_METER_MANUFACTURER_ID)
         if meter_id or manufacturer_id:
             missing_measures = measure_data.keys() - self._known_measures
toreamun commented 2 years ago

https://github.com/toreamun/amshan-homeassistant/releases/tag/2022.10.1