AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.67k stars 414 forks source link

POWR316 not updating the enegy entity #982

Closed Jellybabz closed 1 year ago

Jellybabz commented 2 years ago

Hi

I have the new POWR316 and i have enabled the enegy entity. I see the enegy consumption ind the ewelink app but not in HA.

I've waited for 10 houses to se if any data would show up.

AlexxIT commented 2 years ago

Show device diagnostics

Jellybabz commented 2 years ago
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "config_flow": true,
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "issue_tracker": "https://github.com/AlexxIT/SonoffLAN/issues",
    "codeowners": [
      "@AlexxIT"
    ],
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.2.0",
    "iot_class": "local_push",
    "is_built_in": false
  },
  "data": {
    "version": "38856d1",
    "cloud_auth": true,
    "config": {
      "username": "***",
      "password": "***"
    },
    "options": {
      "mode": "auto",
      "debug": false
    },
    "errors": [
      {
        "name": "custom_components.sonoff.core.ewelink.cloud",
        "message": [
          "Cloud WS Connection error: Cannot connect to host eu-dispa.coolkit.cc:443 ssl:default [Try again]"
        ],
        "level": "WARNING",
        "source": [
          "custom_components/sonoff/core/ewelink/cloud.py",
          268
        ],
        "timestamp": 1664007289.1190434,
        "exception": "",
        "count": 3,
        "first_occurred": 1664007204.0536988
      },
      {
        "name": "custom_components.sonoff.core.ewelink.cloud",
        "message": [
          "Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '10017b54b9', 'apikey': '3f35eeeb-06ed-44c5-9171-137464352c64', 'sequence': '1664006384000'}",
          "Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '10017b54b9', 'apikey': '3f35eeeb-06ed-44c5-9171-137464352c64', 'sequence': '1664009984000'}"
        ],
        "level": "WARNING",
        "source": [
          "custom_components/sonoff/core/ewelink/cloud.py",
          286
        ],
        "timestamp": 1664009989.8513184,
        "exception": "",
        "count": 2,
        "first_occurred": 1664006389.7042894
      }
    ],
    "device": {
      "uiid": 190,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "ssid": "***",
        "bssid": "***",
        "fwVersion": "1.0.6",
        "switches": [
          {
            "switch": "on",
            "outlet": 0
          }
        ],
        "configure": [
          {
            "startup": "stay",
            "outlet": 0
          }
        ],
        "pulses": [
          {
            "pulse": "off",
            "switch": "off",
            "outlet": 0,
            "width": 500
          }
        ],
        "rssi": -56,
        "threshold": {
          "actPow": {
            "min": 10,
            "max": 400000
          },
          "voltage": {
            "min": 18500,
            "max": 26400
          },
          "current": {
            "min": 10,
            "max": 1600
          }
        },
        "current": 84,
        "voltage": 22753,
        "power": 12957,
        "uiActive": 60,
        "timeZone": 2,
        "dayKwh": 52,
        "monthKwh": 105,
        "only_device": {
          "ota": "success",
          "ota_fail_reason": 0
        },
        "getHoursKwh": {
          "start": 0,
          "end": 6
        }
      },
      "model": "POWR316",
      "online": true,
      "localtype": "plug",
      "deviceid": "10017b54b9"
    }
  }
}
ocigam69 commented 2 years ago

Same ussue:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.9.6",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.5",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Madrid",
    "os_name": "Linux",
    "os_version": "5.15.67",
    "supervisor": "2022.09.1",
    "host_os": "Home Assistant OS 9.0",
    "docker_version": "20.10.17",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "climate_ip": {
      "version": "3.5.2",
      "requirements": [
        "requests>=2.21.0",
        "xmljson>=0.2.0"
      ]
    },
    "hacs": {
      "version": "1.27.2",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    },
    "formulaone_api": {
      "version": "0.1.5",
      "requirements": [
        "requests >=2.20"
      ]
    },
    "edge_tts": {
      "version": "0.0.1",
      "requirements": [
        "edge-tts==5.0.1"
      ]
    },
    "sonoff": {
      "version": "3.2.0",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "alexa_media": {
      "version": "4.1.2",
      "requirements": [
        "alexapy==1.26.3",
        "packaging>=20.3",
        "wrapt>=1.12.1"
      ]
    },
    "alarmo": {
      "version": "v1.9.5",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "config_flow": true,
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "issue_tracker": "https://github.com/AlexxIT/SonoffLAN/issues",
    "codeowners": [
      "@AlexxIT"
    ],
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.2.0",
    "iot_class": "local_push",
    "is_built_in": false
  },
  "data": {
    "version": "38856d1",
    "cloud_auth": true,
    "config": null,
    "options": {
      "mode": "auto",
      "debug": false,
      "homes": 1
    },
    "errors": [
      {
        "name": "custom_components.sonoff.core.ewelink.local",
        "message": [
          "100173850d => Local4 | {'switches': [{'outlet': 0, 'switch': 'on'}]} <= {'sequence': '1664015653000', 'seq': 5, 'error': 400, 'encrypt': True}",
          "100173850d => Local4 | {'switches': [{'outlet': 0, 'switch': 'off'}]} <= {'sequence': '1664015656000', 'seq': 8, 'error': 400, 'encrypt': True}",
          "100173850d => Local4 | {'switches': [{'outlet': 0, 'switch': 'on'}]} <= {'sequence': '1664015657000', 'seq': 10, 'error': 400, 'encrypt': True}",
          "100173850d => Local4 | {'switches': [{'outlet': 0, 'switch': 'off'}]} <= {'sequence': '1664015663000', 'seq': 14, 'error': 400, 'encrypt': True}",
          "100173850d => Local4 | {'switches': [{'outlet': 0, 'switch': 'on'}]} <= {'sequence': '1664015992000', 'seq': 19, 'error': 400, 'encrypt': True}"
        ],
        "level": "WARNING",
        "source": [
          "custom_components/sonoff/core/ewelink/local.py",
          255
        ],
        "timestamp": 1664015992.4754107,
        "exception": "",
        "count": 10,
        "first_occurred": 1664014624.4797814
      },
      {
        "name": "custom_components.sonoff.core.ewelink.cloud",
        "message": [
          "Cloud ERROR: {'error': 400, 'deviceid': 'ab300001fe', 'apikey': 'acb441d7-1b57-48d8-8fd5-xxxxx', 'sequence': '1664014875000'}",
          "Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '100173850d', 'apikey': 'acb441d7-1b57-48d8-8fd5-xxxxx', 'sequence': '1664018204000'}",
          "Cloud ERROR: {'error': 400, 'deviceid': 'ab300001fe', 'apikey': 'acb441d7-1b57-48d8-8fd5-xxxxx', 'sequence': '1664018475000'}",
          "Cloud ERROR: {'error': 504, 'reason': 'Request Timeout', 'deviceid': '100173850d', 'apikey': 'acb441d7-1b57-48d8-8fd5-xxxxx', 'sequence': '1664021804000'}",
          "Cloud ERROR: {'error': 400, 'deviceid': 'ab300001fe', 'apikey': 'acb441d7-1b57-48d8-8fd5-xxxxx', 'sequence': '1664022075001'}"
        ],
        "level": "WARNING",
        "source": [
          "custom_components/sonoff/core/ewelink/cloud.py",
          286
        ],
        "timestamp": 1664022076.1155539,
        "exception": "",
        "count": 8,
        "first_occurred": 1664014609.6192422
      }
    ],
    "device": {
      "uiid": 190,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "ssid": "***",
        "bssid": "***",
        "fwVersion": "1.0.6",
        "switches": [
          {
            "outlet": 0,
            "switch": "off"
          }
        ],
        "configure": [
          {
            "startup": "stay",
            "outlet": 0
          }
        ],
        "pulses": [
          {
            "pulse": "off",
            "switch": "off",
            "outlet": 0,
            "width": 500
          }
        ],
        "rssi": -56,
        "threshold": {
          "actPow": {
            "min": 10,
            "max": 500000
          },
          "voltage": {
            "min": 18500,
            "max": 26400
          },
          "current": {
            "min": 10,
            "max": 2000
          }
        },
        "current": 0,
        "voltage": 0,
        "power": 0,
        "dayKwh": 0,
        "monthKwh": 2,
        "uiActive": 60,
        "timeZone": 2,
        "getHoursKwh": {
          "start": 3720,
          "end": 4463
        },
        "sledOnline": "on",
        "only_device": {
          "ota": "success",
          "ota_fail_reason": 0
        },
        "operSide": 1
      },
      "model": "POWR320D",
      "online": true,
      "localtype": "plug",
      "deviceid": "100173850d"
    }
  }
}
crazyasyou commented 2 years ago

Is there any update on this, I have the same issue.

R1220 commented 1 year ago

Same here. I can see in the log the correct value for "dayKwh": 0, and "monthKwh": 2. I can see them in the ewelink addon but can't use the data in my dashboard. I manually enabled the sensor "Energy" in the device but it always shows "Unknown" Browsing the files, I noticed that in custom_components/sonoff/sensor.py in the DEVICE CLASSES there is no "energy class. Same for Units class. But down in class XEnergySensor I can see the device class and the Unit. Not sure if this info is of any use!

HolubTom commented 1 year ago

I have the same problem, is there any update or progress? Thanks

dezza commented 1 year ago

Similar issue with TH10.

It seems like when SonoffLAN is in "auto" mode it asks the cloud for update. It seems when local it still waits for cloud to update the device sensors? Or maybe its hardwired to only update on time intervals that might not trigger or deliver old data by the time its finally delivered?

lazmo88 commented 1 year ago

Same issue here, no energy metering stats/history available on the entity. It stays "unknown" even the stats are available in ewelink app and integration. That said, even on the official ewelink integration for HA these stats are not available directly for energy dashboard 🤷‍♂️

rubendediegomartinez commented 1 year ago

Same issue. :-(

dezza commented 1 year ago

I ended up switching to local-mode and that works now consistently. Its everytime auto/cloud is enabled that it always pulls old data from the cloud and never polls local.

Even if this is discouraged by maintainer, this is the only solution.

DaSpors commented 1 year ago

local-mode does not change anything at my side, energy stays 'unknown'

AlexxIT commented 1 year ago

Energy loading from cloud. It will always be unknown in local mode. Maybe 504 errors are related to API changes on the cloud side.

alexthevenot commented 1 year ago

Hello everybody, I was wondering if there was any update on this topic ? Any solution found ? Thank you !

DaSpors commented 1 year ago

As a workaround I created a Riemann-sum-integral helper https://www.home-assistant.io/integrations/integration/ Not nice, but working until this is fixed.

AlexxIT commented 1 year ago

Should be fixed in the latest master version

AlexxIT commented 1 year ago

https://github.com/AlexxIT/SonoffLAN/releases/tag/v3.5.1