aturri / ha-zcsazzurro

A modern integration for ZCS Azzurro devices in Home Assistant
MIT License
23 stars 6 forks source link

RESOLVED - Most recent data shown in HA are outdated - RESOLVED #65

Closed grzwolf closed 3 months ago

grzwolf commented 3 months ago

The problem

Data shown in HA are time wise, as if they were recent (just a few minutes old), but they are outdated by > approx 4h.

Example: A powerGenerating data point of 12586 W as shown in the UI card has a time stamp 18:50.

Device diagnostics shows the same "powerGenerating: 12586" but with time stamp of ""lastUpdate": "2024-08-03T14:13:47Z"".

zcsazzurro-diagnostics.json

Version of zcsazzurro integration having the issue?

zcsazzurro - 0.1.0

Version of Home Assistant Core having the issue?

core - 2024.7.4

Anything in the logs that might be useful for us?

Diagnostics.json
~~~~~~~~~~~~~~~~

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.7.4",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.4",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "6.6.31-haos-raspi",
    "supervisor": "2024.06.2",
    "host_os": "Home Assistant OS 12.4",
    "docker_version": "26.1.4",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "zcsazzurro": {
      "documentation": "https://github.com/aturri/ha-zcsazzurro",
      "version": "0.1.0",
      "requirements": [
        "flatdict==4.0.1"
      ]
    },
  },
  "integration_manifest": {
    "domain": "zcsazzurro",
    "name": "ZCS Azzurro",
    "codeowners": [
      "aturri"
    ],
    "config_flow": true,
    "dependencies": [
      "rest"
    ],
    "documentation": "https://github.com/aturri/ha-zcsazzurro",
    "homekit": {},
    "integration_type": "device",
    "iot_class": "cloud_polling",
    "issue_tracker": "https://github.com/aturri/ha-zcsazzurro/issues",
    "loggers": [
      "pyzcsazzurro"
    ],
    "requirements": [
      "flatdict==4.0.1"
    ],
    "ssdp": [],
    "version": "0.1.0",
    "zeroconf": [],
    "is_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 0.00012614600018423516
    },
    "e31af0695780c7afd5fcae8b451d7e3b": {
      "wait_import_platforms": -0.04040410499965219,
      "config_entry_setup": 0.7593670579999525
    }
  },
  "data": {
    "info": {
      "manufacturer": "ZCS Azzurro",
      "serial": "**REDACTED**"
    },
    "data": {
      "energyChargingTotal": 2262.9,
      "powerGenerating": 12586,
      "energyConsumingTotal": 4742.8,
      "batterySoC": 99,
      "energyImporting": 0.19,
      "powerExporting": 9020,
      "batteryCycletime": 76,
      "energyExporting": 43.35,
      "energyImportingTotal": 43.8,
      "energyExportingTotal": 7335.9,
      "energyCharging": 24.49,
      "energyAutoconsumingTotal": 3434.3,
      "energyDischarging": 14.72,
      "batteryCycletime2": 57,
      "energyConsuming": 46.0,
      "powerConsuming": 3158,
      "powerAutoconsuming": 3158,
      "thingFind": "2024-01-15T13:26:24Z",
      "energyDischargingTotal": 1931.2,
      "powerDischarging": 0,
      "lastUpdate": "2024-08-03T14:13:47Z",
      "energyGeneratingTotal": 13033.1,
      "energyAutoconsuming": 31.09,
      "batterySoC2": 100,
      "powerCharging": 407,
      "energyGenerating": 98.93,
      "powerImporting": 0,
      "currentDC": 8.83,
      "voltageDC": 449.6,
      "powerDC": 3969.97,
      "temperature": 42.0,
      "_use_cached_result": false
    }
  }
}

Additional information

Azzurro app on smartphone shows a correct timestamp.

So it looks to me, as if the "zcsazzurro" integration were asking for historic data, not recent ones.

Daratorn commented 3 months ago

I have the same exact problem, never happened before.

Azzurro app is correct but home assistant show older data

grzwolf commented 3 months ago

Update: The maintainer may close this issue, I contacted the Azzurro support.

Running the Python script below (many thanks to https://github.com/ZCS-User) provides the same time gap of approx 4h.

That means, aturri's ha-zcsazzurro integration in HA works fine, the root cause seems to be the screwed up server response from https://third.zcsazzurroportal.com:19003/.

Question is still, why does the Azzurro app (assuming it uses the same API) show correct data?


import requests
try:
    rsp = requests.Session()
    rsp = requests.post(
        'https://third.zcsazzurroportal.com:19003/',
        headers={
            "Authorization": "Zcs <auth_key>",
            "Client": '<client>',
            "Content-Type": 'application/json'
        },
        json={
            "realtimeData": {
                "command": "realtimeData",
                "params": {
                    "thingKey": " <serial_number>",
                    "requiredValues": "*"
                }
            }
        },
        timeout=1)

    if rsp.status_code == 200:
        # print(str(rsp.text))
        print(str(rsp.text), str(rsp.status_code))
    else:
        print(str(0), str(rsp.status_code))
except:
    print('Script Fail')

grzwolf commented 3 months ago

Update: Per 2024/08/10 the issue is gone w/o any change at the client side. It seems like the server config at Azzurro got fixed.

The maintainer may close this issue,