bwp91 / homebridge-ewelink

Homebridge plugin to integrate eWeLink devices into HomeKit.
MIT License
384 stars 126 forks source link

Missing information - Internal API - POWR320D (ewUUID 190) #541

Closed ludufre closed 3 months ago

ludufre commented 3 months ago

What issue do you have? Please be as thorough and explicit as possible.

Internal API do not reply with Power, Current and Voltage of the accessory Sonoff POWR320D (eweUUID 190).

{
    "success": true,
    "response": {
        "status": {
            "wan": true,
            "lan": false,
            "ip": false
        },
        "services": [
            "switch",
            "power"
        ],
        "switch": {
            "state": "on"
        }
        ......MISSING_POWER_HERE......
    }
}

The current values are printed to logs:

[3/26/2024, 5:13:18 PM] [eWeLink] [POWR320D] current power [73.13W] current voltage [125.72V] current current [0.78A].
[3/26/2024, 5:13:22 PM] [eWeLink] [POWR320D] current power [76.65W] current voltage [125.72V] current current [0.77A].
[3/26/2024, 5:13:24 PM] [eWeLink] [POWR320D] current power [72.81W] current voltage [125.56V] current current [0.8A].

I noticed that those characteristics are removed to that eweUUID: https://github.com/bwp91/homebridge-ewelink/blob/9f0bef581abdf0db9c382d12abfcff3ac0531faf/lib/device/switch-single.js#L79-L87

And consequently not showing: https://github.com/bwp91/homebridge-ewelink/blob/9f0bef581abdf0db9c382d12abfcff3ac0531faf/lib/device/switch-single.js#L291-L299

It's a bug or i'm not seeing the big picture?

Details of your setup.

Please paste any relevant logs below.

[3/26/2024, 5:52:16 PM] Homebridge v1.7.0 (HAP v0.11.2) (Homebridge ECEB) is running on port 51609.
[3/26/2024, 5:52:17 PM] [Homebridge UI] [HapClient] Discovery :: Found HAP device with username 0E:F4:6D:63:EC:EB
[3/26/2024, 5:52:17 PM] [Homebridge UI] [HapClient] Discovery :: Testing 0E:F4:6D:63:EC:EB via http://172.19.0.2:51609/accessories
[3/26/2024, 5:52:17 PM] [Homebridge UI] [HapClient] Discovery :: Success 0E:F4:6D:63:EC:EB via http://172.19.0.2:51609/accessories
[3/26/2024, 5:52:17 PM] [Homebridge UI] [HapClient] Discovery :: [172.19.0.2:51609 (0E:F4:6D:63:EC:EB)] Instance Registered
[3/26/2024, 5:52:21 PM] [eWeLink] Fetching devices from eWeLink home/id [My Home] [5ed90d89c35d3d0008aec5b3].
[3/26/2024, 5:52:28 PM] [eWeLink] LAN monitoring started.
[3/26/2024, 5:52:28 PM] [eWeLink] [POWR320D] initialising with options {"inUsePowerThreshold":0,"logging":"standard","showAs":"default"}.
[3/26/2024, 5:52:28 PM] [homebridge-ewelink] This plugin generated a warning from the characteristic 'Voltage': Characteristic not in required or optional characteristic section for service Switch. Adding anyway.. See https://homebridge.io/w/JtMGR for more info.
[3/26/2024, 5:52:28 PM] [homebridge-ewelink] This plugin generated a warning from the characteristic 'Electric Current': Characteristic not in required or optional characteristic section for service Switch. Adding anyway.. See https://homebridge.io/w/JtMGR for more info.
[3/26/2024, 5:52:28 PM] [eWeLink] [POWR320D] initialised and LAN mode unavailable as not discovered/supported [190:POWR320D].
[3/26/2024, 5:52:28 PM] [eWeLink] ✓ Setup complete. This plugin has been made with ♥ by bwp91, please consider a ☆ on GitHub if you are finding it useful!
[3/26/2024, 5:52:28 PM] [eWeLink] Internal API listening on port [9591].
[3/26/2024, 5:52:28 PM] [eWeLink] [POWR320D] current power [74.35W] current voltage [126.45V] current current [0.82A].
[3/26/2024, 5:52:33 PM] [eWeLink] [POWR320D] current power [75.89W] current voltage [126.45V] current current [0.82A].
[3/26/2024, 5:52:34 PM] [Homebridge UI] [HapClient] Discovery :: Ended
[3/26/2024, 5:52:34 PM] [eWeLink] [POWR320D] current power [76.4W] current voltage [126.61V] current current [0.82A].
[3/26/2024, 5:52:38 PM] [eWeLink] [POWR320D] current power [72.56W] current voltage [126.54V] current current [0.82A].
[3/26/2024, 5:52:40 PM] [eWeLink] [POWR320D] current power [79.18W] current voltage [126.73V] current current [0.83A].
bwp91 commented 3 months ago

Hi @ludufre

Nice find, and thanks for the detailed issue.

Please try the beta version of the plugin, I hope to have fixed this there!

ludufre commented 3 months ago

Unfortunately not.

Even destroying the container and removing and reconfiguring de accessory on eWeLink App.

If helps, here is the response calling directly the eWeLink API:

{
    "error": 0,
    "msg": "",
    "data": {
        "thingList": [
            {
                "itemType": 1,
                "itemData": {
                    "name": "POWR320D",
                    "deviceid": "1001....",
                    "apikey": "4fe2228....",
                    "extra": {
                        "uiid": 190,
                        "description": "20A,有显示屏",
                        "itCredential": "vf5OFWv4V....",
                        "brandId": "5c4c1aee3a7d24c7100be054",
                        "apmac": "d0:27:03....",
                        "mac": "d0:27:03:...",
                        "ui": "POWR3-显示屏版本",
                        "modelInfo": "61b83734d12cfa5e630c8770",
                        "model": "SN-ESP32D0-POWR3-01",
                        "manufacturer": "深圳松诺技术有限公司",
                        "chipid": "E05A1B.....",
                        "staMac": "E0:5A:1B:...."
                    },
                    "brandName": "SONOFF",
                    "brandLogo": "https://us-ota.coolkit.cc/logo/q62PevoglDNmwUJ9oPE7kRrpt1nL1CoA.png",
                    "showBrand": true,
                    "productModel": "POWR320D",
                    "tags": {
                        "m_0329_ludu": "on"
                    },
                    "devConfig": {},
                    "settings": {
                        "opsNotify": 1,
                        "opsHistory": 1,
                        "alarmNotify": 1,
                        "wxAlarmNotify": 0,
                        "wxOpsNotify": 0,
                        "wxDoorbellNotify": 0,
                        "appDoorbellNotify": 1,
                        "offlineNotify": 1,
                        "powerConsumptionNotify": 0,
                        "overThresholdNotify": 0
                    },
                    "devGroups": [],
                    "family": {
                        "familyid": "5ed90d89c3....",
                        "index": 0,
                        "members": [
                            "c34dbee0-e47f-43a...."
                        ],
                        "guests": []
                    },
                    "shareTo": [],
                    "devicekey": "dd10177a-d3f9-4022-....",
                    "online": true,
                    "params": {
                        "bindInfos": {
                            "gaction": [
                                "4fe2228c-4e47-4a98-90...._ewelinkGoogleHome"
                            ]
                        },
                        "version": 8,
                        "demNextFetchTime": 1711508400000,
                        "ssid": "RESISTENCIA_2G",
                        "bssid": "a0:b5:3c....",
                        "fwVersion": "1.1.1",
                        "current": 84,
                        "voltage": 12661,
                        "power": 8095,
                        "uiActive": 120,
                        "timeZone": -3,
                        "dayKwh": 163,
                        "monthKwh": 316,
                        "switches": [
                            {
                                "switch": "on",
                                "outlet": 0
                            }
                        ],
                        "operSide": 1,
                        "getHoursKwh": {
                            "start": 0,
                            "end": 6
                        },
                        "threshold": {
                            "actPow": {
                                "min": 10,
                                "max": 254000
                            },
                            "voltage": {
                                "min": 8500,
                                "max": 14600
                            },
                            "current": {
                                "min": 10,
                                "max": 2100
                            }
                        },
                        "overload_00": {
                            "minAP": {
                                "en": 0,
                                "val": 10
                            },
                            "maxAP": {
                                "en": 1,
                                "val": 254000
                            },
                            "minV": {
                                "en": 0,
                                "val": 8500
                            },
                            "maxV": {
                                "en": 0,
                                "val": 14600
                            },
                            "maxC": {
                                "en": 1,
                                "val": 2100
                            },
                            "minC": {
                                "en": 0,
                                "val": 10
                            }
                        },
                        "configure": [
                            {
                                "startup": "on",
                                "outlet": 0
                            }
                        ],
                        "pulses": [
                            {
                                "pulse": "off",
                                "switch": "off",
                                "outlet": 0,
                                "width": 500
                            }
                        ],
                        "rssi": -48,
                        "sledOnline": "off",
                        "only_device": {
                            "ota": "success",
                            "ota_fail_reason": 0
                        },
                        "staMac": "E0:5A:1B...."
                    },
                    "denyFeatures": [
                        "formateKwhDataByFourChars",
                        "userManual"
                    ],
                    "isSupportGroup": false,
                    "isSupportedOnMP": false,
                    "isSupportChannelSplit": false,
                    "deviceFeature": {}
                },
                "index": 0
            }
        ],
        "total": 1
    }
}

Full log

[3/26/2024, 10:28:09 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules -D --strict-plugin-resolution
[3/26/2024, 10:28:09 PM] [HB Supervisor] Started Homebridge v1.7.0 with PID: 4530
[3/26/2024, 10:28:09 PM] Loaded config.json with 0 accessories and 3 platforms.
[3/26/2024, 10:28:09 PM] Loaded 1 cached accessories from cachedAccessories.
[3/26/2024, 10:28:09 PM] ---
[3/26/2024, 10:28:09 PM] Loaded plugin: homebridge-ewelink@12.1.1-beta.6
[3/26/2024, 10:28:09 PM] Registering platform 'homebridge-ewelink.eWeLink'
[3/26/2024, 10:28:09 PM] ---
[3/26/2024, 10:28:09 PM] Loading 3 platforms...
[3/26/2024, 10:28:09 PM] [eWeLink] Initializing eWeLink platform...
[3/26/2024, 10:28:09 PM] [eWeLink] Initialising plugin v12.1.1-beta.6 | System linux | Node v18.19.0 | HB v1.7.0 | HAPNodeJS v0.11.2...
[3/26/2024, 10:28:09 PM] [eWeLink] Plugin initialised. Setting up accessories....
[3/26/2024, 10:28:09 PM] [eWeLink] ******************************************************************************************
[3/26/2024, 10:28:09 PM] [eWeLink] You are using a beta version of the plugin - you will experience more logging than normal.
[3/26/2024, 10:28:09 PM] [eWeLink] ******************************************************************************************
[3/26/2024, 10:28:09 PM] Publishing bridge accessory (name: Homebridge ECEB, publishInfo: {
  username: '0E:F4:6D:63:EC:EB',
  port: 51609,
  pincode: '***-**-***',
  category: 2,
  bind: undefined,
  mdns: undefined,
  addIdentifyingMaterial: true,
  advertiser: 'bonjour-hap'
}).
Setup Payload:
X-HM://002458UV4RTCM
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ 408-37-952 │     
    └────────────┘     

[3/26/2024, 10:28:09 PM] Homebridge v1.7.0 (HAP v0.11.2) (Homebridge ECEB) is running on port 51609.
[3/26/2024, 10:28:10 PM] [Homebridge UI] [HapClient] Discovery :: Found HAP device with username 0E:F4:6D:63:EC:EB
[3/26/2024, 10:28:10 PM] [Homebridge UI] [HapClient] Discovery :: Success 0E:F4.... via http://172.19.0.2:51609/accessories
[3/26/2024, 10:28:10 PM] [Homebridge UI] [HapClient] Discovery :: [172.19.0.2:51609 (0E:F4:6D:63:EC:EB)] Instance Registered
[3/26/2024, 10:28:13 PM] [eWeLink] Fetching devices from eWeLink home/id [My Home] [5ed90d89c....].
[3/26/2024, 10:28:18 PM] [eWeLink] LAN monitoring started.
[3/26/2024, 10:28:18 PM] [eWeLink] [POWR320D] initialising with options {"inUsePowerThreshold":0,"logging":"standard","showAs":"default"}.
[3/26/2024, 10:28:18 PM] [eWeLink] [POWR320D] initialised and LAN mode unavailable as not discovered/supported [190:POWR320D].
[3/26/2024, 10:28:18 PM] [eWeLink] ✓ Setup complete. This plugin has been made with ♥ by bwp91, please consider a ☆ on GitHub if you are finding it useful!
[3/26/2024, 10:28:18 PM] [eWeLink] Internal API listening on port [9591].
[3/26/2024, 10:28:18 PM] [eWeLink] [POWR320D] receiving update {"current":120,"voltage":12628,"power":11435,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:28:18 PM] [eWeLink] [POWR320D] current power [114.35W] current voltage [126.28V] current current [1.2A].
[3/26/2024, 10:28:22 PM] [eWeLink] [POWR320D] receiving update {"current":124,"voltage":12658,"power":12033,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:28:22 PM] [eWeLink] [POWR320D] current power [120.33W] current voltage [126.58V] current current [1.24A].
[3/26/2024, 10:28:23 PM] [eWeLink] [POWR320D] sending update {"uiActive":120}.
[3/26/2024, 10:29:02 PM] [eWeLink] [POWR320D] receiving update {"current":116,"voltage":12661,"power":11519,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:02 PM] [eWeLink] [POWR320D] current power [115.19W] current voltage [126.61V] current current [1.16A].
[3/26/2024, 10:29:04 PM] [eWeLink] [POWR320D] receiving update {"current":122,"voltage":12677,"power":11793,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:04 PM] [eWeLink] [POWR320D] current power [117.93W] current voltage [126.77V] current current [1.22A].
[3/26/2024, 10:29:05 PM] [Homebridge UI] [HapClient] Discovery :: Ended
[3/26/2024, 10:29:08 PM] [eWeLink] [POWR320D] receiving update {"current":118,"voltage":12645,"power":11583,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:08 PM] [eWeLink] [POWR320D] current power [115.83W] current voltage [126.45V] current current [1.18A].
[3/26/2024, 10:29:10 PM] [eWeLink] [POWR320D] receiving update {"current":124,"voltage":12660,"power":12125,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:10 PM] [eWeLink] [POWR320D] current power [121.25W] current voltage [126.6V] current current [1.24A].
[3/26/2024, 10:29:12 PM] [eWeLink] [POWR320D] receiving update {"current":118,"voltage":12646,"power":11476,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:12 PM] [eWeLink] [POWR320D] current power [114.76W] current voltage [126.46V] current current [1.18A].
[3/26/2024, 10:29:14 PM] [eWeLink] [POWR320D] receiving update {"current":124,"voltage":12655,"power":12024,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:14 PM] [eWeLink] [POWR320D] current power [120.24W] current voltage [126.55V] current current [1.24A].
[3/26/2024, 10:29:16 PM] [eWeLink] [POWR320D] receiving update {"current":118,"voltage":12628,"power":11431,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:16 PM] [eWeLink] [POWR320D] current power [114.31W] current voltage [126.28V] current current [1.18A].
[3/26/2024, 10:29:18 PM] [eWeLink] [POWR320D] receiving update {"current":124,"voltage":12643,"power":11701,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:18 PM] [eWeLink] [POWR320D] current power [117.01W] current voltage [126.43V] current current [1.24A].
[3/26/2024, 10:29:20 PM] [eWeLink] [POWR320D] receiving update {"current":121,"voltage":12628,"power":11518,"online":true,"updateSource":"WS"}.
[3/26/2024, 10:29:20 PM] [eWeLink] [POWR320D] current power [115.18W] current voltage [126.28V] current current [1.21A].
...
ludufre commented 3 months ago

@bwp91 actually, when I enable LAN mode works:

This beta version fix the issue 🎉

{
    "success": true,
    "response": {
        "status": {
            "wan": true,
            "lan": true,
            "ip": "192.168.123.160"
        },
        "services": [
            "switch",
            "power"
        ],
        "switch": {
            "state": "on"
        },
        "power": {
            "voltage": 128,
            "power": 118,
            "current": 1.3
        }
    }
}