gaetancollaud / digitalstrom-mqtt

Bridge between digitalSTROM and MQTT
GNU Affero General Public License v3.0
23 stars 4 forks source link

Errors after Migration #46

Closed DerSchwarzeJugo closed 8 months ago

DerSchwarzeJugo commented 9 months ago

Hi I appreciate your work and am already a longtime user of this repo... I'm running an instance in docker in combination with homeassistant.

After migrating to the newest version and optaining an API Key, I am Getting the following error

ERR No controller found for metering error="No controller found with id 302ed89f43f0000000000e400000955b00" controllerId=302ed89f43f0000000000e400000955b00 meteringId=dsm-302ed89f43f0000000000e400000955b00-power

image

Any Ideas why that is and how I can resolve that?

Kind Regards

gaetancollaud commented 9 months ago

Hello,

Thanks for reporting the issue, normally the error should not stop the app, but I guess you see it every 10secs (interval between the metering update). I can hide this error easily but I would like to understand.

The only reason I would think this error could pop is that you have a device that report energy consumption but is not a controller. Can you run this command and look for a device with the id 302ed89f43f0000000000e400000955b00:

curl -k -X GET --location "https://HOSTNAME:8080/api/v1/apartment" -H "Authorization: Bearer API_KEY"

Don't forget to replace HOSTNAME and API_KEY with your digitalstrom host and API key.

You can post the result here if you want but I understand if you don't wanna share you whole setup publiquely. Please look for the id and tell me what kind of device it is.

Exemple for my installation:

        {
          "id": "302ed89f43f0000000000e400000fc9200",
          "type": "controller",
          "attributes": {
            "name": "cage",
            "technicalName": "dSM12"
          }
        },
DerSchwarzeJugo commented 9 months ago

Hi Gaetan, thanks for your quick reply... i have curled the endpoint, but i am not seeing this device in the outputted list. I think it is not a problem, to output the information here, as I am not seeing any relevant information

{
  "data": {
    "id": "f37229e1-17f9-5b8f-7fef-40c6dc7b0e97",
    "type": "apartment",
    "attributes": {
      "name": "dSS",
      "zones": [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "65534"
      ],
      "dsDevices": [
        "302ed89f43f0000000000a00000c832c00",
        "302ed89f43f0000000000a00000c832d00",
        "302ed89f43f0000000000a00000c832e00",
        "302ed89f43f0000000000a00000c832f00",
        "302ed89f43f0000000002780000b749200",
        "302ed89f43f0000000002780000b9ff600",
        "302ed89f43f0000000002780000ba07b00",
        "302ed89f43f0000000002780000ba08e00",
        "302ed89f43f0000000002780000ba10900",
        "302ed89f43f0000000002780000ba11300",
        "303505d7f8000000000004c0000b90ef00",
        "303505d7f8000000000004c0000b91f500",
        "303505d7f8000000000004c0000b920900",
        "303505d7f8000000000004c0000b922f00",
        "303505d7f8000000000004c0000b96e000",
        "303505d7f800000000000f00000b8f8000",
        "303505d7f800000000001680000d349000",
        "303505d7f800000000001680000d349200",
        "303505d7f800000000001680000d349300",
        "303505d7f800000000001680000dbddc00",
        "303505d7f800000000001680000dbdde00",
        "303505d7f800000000001680000dbf2c00",
        "303505d7f800000000001680000dbf2e00",
        "303505d7f800000000001680000dbfc800",
        "303505d7f800000000001680000dbfca00",
        "303505d7f800000000001680000dbfcb00",
        "303505d7f800000000001680000dbfd400",
        "303505d7f800000000001680000dbfd600"
      ],
      "clusters": [
        "16"
      ]
    }
  }
}

Also I am seeing 2 ERR outputs one after another.. image

and in HomeAssistant all my devices are unavailable When i run the API command to get devices /dsDevices, all the devices are available like so

{
      "id": "303505d7f8000000000004c0000b96e000",
      "type": "dsDevice",
      "attributes": {
        "name": "Kitchen Spotlights",
        "dsid": "303505d7f80004c0000b96e0",
        "displayId": "000b96e0",
        "present": true,
        "submodules": [
          "303505d7f8000000000004c0000b96e000"
        ],
        "zone": "3",
        "scenarios": [
          "device-303505d7f8000000000004c0000b96e000-std.turnOff",
          "device-303505d7f8000000000004c0000b96e000-std.turnOffSlowly",
          "device-303505d7f8000000000004c0000b96e000-std.turnOn"
        ]
      }
    },

When i curl the endpoint /apartment/installation/meterings/values i get an output like this

{
  "data": {
    "values": [
      {
        "id": "apartment-energy",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.257Z",
        "attributes": {
          "value": 13285386326
        }
      },
      {
        "id": "apartment-power",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.257Z",
        "attributes": {
          "value": 320
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e4000008d4a00-energy",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.242Z",
        "attributes": {
          "value": 5594355772
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e4000008d4a00-power",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.242Z",
        "attributes": {
          "value": 33
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e400000905500-energy",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.257Z",
        "attributes": {
          "value": 6321260704
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e400000905500-power",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.257Z",
        "attributes": {
          "value": 281
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e400000955b00-energy",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.247Z",
        "attributes": {
          "value": 1369769850
        }
      },
      {
        "id": "dsm-302ed89f43f0000000000e400000955b00-power",
        "type": "meteringValue",
        "lastChanged": "2023-12-18T20:59:42.247Z",
        "attributes": {
          "value": 6
        }
      }
    ]
  }
}
gaetancollaud commented 8 months ago

Interesting. Did you post the full output ? It's really strange because you have nothing in included like in my setup. There is an argument to define what to include but it was not working for me and everything was always included so I omited it in my implementation. Could you try this:

curl -k -X GET --location "https://HOSTNAME:8080/api/v1/apartment?include=installation,dsDevices,submodules,functionBlocks,zones,clusters,applications,dsServer,controllers,apiRevision,meterings" -H "Authorization: Bearer API_KEY"

Do you see the controllers now ?

Reference: https://developer.digitalstrom.org/api/#get-/

DerSchwarzeJugo commented 8 months ago

Maybe it is implemented differently in ohter dss server versions. I get now a full output (it is very long).. and i do see the controller now, but the error is still there in the docker logs.

What I can not get to work, is that the devices are available again in homeassistant... maybe you could point me how to do the "remapping" you have mentioned in the migration-guide? I actually have automatic discovery in HA enabled... But there i get the Error "MQTT device name is equal to entity name in your config" in the logs

gaetancollaud commented 8 months ago

You have nothing to do, it's my mistake. I will add the parameters in the my code and get back to you with a new version. Hopefully it will solve this. I think the devices are affected too since I use the same call to get the list of devices.

DerSchwarzeJugo commented 8 months ago

Alright, thank you for your time. I'm looking forward to your solution and many thanks for your quick help and replies.

gaetancollaud commented 8 months ago

Thanks for reporting and help me debug, it's not always easy when there are disparity in implementations...

Can you try the version 2.0.4 that I just released? Hopefully it will help.

DerSchwarzeJugo commented 8 months ago

It works now again like it should thank you. The only thing I have to do is to delete the old devices from my broker.. but that is ok. And I think I will loose the historical data of the energy sensors.

Thanks for resolving :)

gaetancollaud commented 8 months ago

Yeah unfortunatelly the new API doesn't have 100% the exact same feature as explained in the migration guide. So you will have to move things arround in your setup.

I will close this issue