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

Add support CK-BL602-W102SW18-01(226) #1425

Closed romero091 closed 3 weeks ago

romero091 commented 4 months ago

I have purchased several EARU items on aliexpress that turned out to be the model CK-BL602-W102SW18-01(226) from coolkit. In HA I cannot find an energy entity. Device version is 1.0 This sensor does not appear as inactive, attached screenshot: earu

Any ideas?

The device is not supported on the Ewelink website either, I don't know if this is normal

ewelink web

romero091 commented 4 months ago

@AlexxIT I have shared with your account sonofflan@gmail.com a device called "Pista Tenis Albero", to see why this new model does not show energy in HA, in case the integration requires any update. Thank you very much for everything you do for the community.

AlexxIT commented 4 months ago

There is no specification for your device. I won't be able to look at it anytime soon. There are so many other projects https://github.com/AlexxIT/SonoffLAN/blob/master/custom_components/sonoff/core/devices.py

romero091 commented 4 months ago

No hay especificaciones para su dispositivo. No podré verlo pronto. Hay muchos otros proyectos https://github.com/AlexxIT/SonoffLAN/blob/master/custom_components/sonoff/core/devices.py

Don't worry. I appreciate the response. I would like you to keep this in mind if you update the integration in the future. Thank you so much.

hosand commented 3 months ago

There is no specification for your device. I won't be able to look at it anytime soon. There are so many other projects https://github.com/AlexxIT/SonoffLAN/blob/master/custom_components/sonoff/core/devices.py

I have same issues too with this device this is what is find in the debug maybe helpfull:

  "sonoff": {
      "documentation": "https://github.com/AlexxIT/SonoffLAN",
      "version": "3.7.3",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "codeowners": [
      "AlexxIT"
    ],
    "config_flow": true,
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "iot_class": "local_push",
    "issue_tracker": "/api/sonoff/d889fe88-9f84-436f-8fc4-d17a024cef46",
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.7.3",
    "is_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 0.00010440300684422255
    },
    "87ee95a94ee94a75080bee615226190c": {
      "wait_import_platforms": -0.00011544399603735656,
      "config_entry_setup": 5.423382139997557
    }
  },
  "data": {
    "version": "e240aaf",
    "cloud_auth": true,
    "config": null,
    "options": {
      "mode": "auto",
      "debug": true,
      "homes": 0
    },
    "errors": [
      {
        "name": "custom_components.sonoff.core.ewelink.cloud",
        "message": [
          "Cloud ERROR: {'error': 400, 'deviceid': '1002244cbe', 'apikey': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad', 'sequence': '1718668158039', 'uid': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad'}",
          "Cloud ERROR: {'error': 400, 'deviceid': '1002244cbe', 'apikey': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad', 'sequence': '1718668242503', 'uid': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad'}",
          "Cloud ERROR: {'error': 400, 'deviceid': '1002244cbe', 'apikey': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad', 'sequence': '1718668311025', 'uid': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad'}",
          "Cloud ERROR: {'error': 400, 'deviceid': '1002244cbe', 'apikey': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad', 'sequence': '1718668315085', 'uid': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad'}",
          "Cloud ERROR: {'error': 400, 'deviceid': '1002244cbe', 'apikey': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad', 'sequence': '1718668667909', 'uid': 'e9ab245a-e06f-4e87-a8f2-0cdf05e2e1ad'}"
        ],
        "level": "WARNING",
        "source": [
          "custom_components/sonoff/core/ewelink/cloud.py",
          607
        ],
        "timestamp": 1718668668.3370745,
        "exception": "",
        "count": 16,
        "first_occurred": 1718666710.197597
      }
    ],
    "device": {
      "uiid": 226,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "rssi": -62,
        "fwVersion": "1.0.0",
        "switch": false,
        "pulse": "off",
        "pulseWidth": 500,
        "sledOnline": "on",
        "startup": "stay",
        "prepaid_support": true,
        "alarm_v_min": 188,
        "alarm_v_max": 265,
        "alarm_c_min": -1,
        "alarm_c_max": 9.99,
        "alarm_p_min": -1,
        "alarm_p_max": 2000,
        "availablePower": 0,
        "prepaidEnale": false,
        "prepaidLowBalanceAlert": false,
        "prepaidLowest": 0,
        "min_p_upper": 5000,
        "min_p_lower": 1,
        "max_p_upper": 15000,
        "max_p_lower": 1,
        "min_v_upper": 220,
        "min_v_lower": 76,
        "max_v_upper": 300,
        "max_v_lower": 220,
        "max_c_upper": 63,
        "max_c_lower": 0.1,
        "calibrateFlag": false,
        "ssid": "***",
        "bssid": "***",
        "staMac": "***",
        "totalPower": 21.84,
        "phase_0_c": 0,
        "phase_0_v": 238.87,
        "phase_0_p": 0,
        "uiActive": 60,
        "timers": "***",
        "hundredDaysKwh": "get",
        "oneKwh": "get",
        "endTime": "2024-06-17T11:54:44.650Z",
        "startTime": "2024-06-14T09:00:52.875Z",
        "alarmType": "pvc"
      },
      "model": "CK-BL602-W102SW18-01(226)",
      "online": true,
      "local": null,
      "localtype": null,
      "host": null,
      "deviceid": "1002244cbe"
    }
  }
}
hosand commented 3 months ago

So actually getting some data But for example the switch is true or false not on or off

joaquimpin commented 3 months ago

hi, i have some of this units, but the integration not show voltage, power, amperes and energy. are possible to add this values?

this are my logs of device,

"device": {
      "uiid": 226,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "rssi": -77,
        "fwVersion": "1.0.0",
        "switch": true,
        "pulse": "off",
        "pulseWidth": 1000,
        "sledOnline": "on",
        "startup": "off",
        "prepaid_support": true,
        "alarm_v_min": -1,
        "alarm_v_max": -1,
        "alarm_c_min": -1,
        "alarm_c_max": -1,
        "alarm_p_min": -1,
        "alarm_p_max": -1,
        "availablePower": 0,
        "prepaidEnale": false,
        "prepaidLowBalanceAlert": false,
        "prepaidLowest": 0,
        "min_p_upper": 5000,
        "min_p_lower": 1,
        "max_p_upper": 15000,
        "max_p_lower": 1,
        "min_v_upper": 220,
        "min_v_lower": 76,
        "max_v_upper": 300,
        "max_v_lower": 220,
        "max_c_upper": 63,
        "max_c_lower": 0.1,
        "calibrateFlag": false,
        "ssid": "***",
        "bssid": "***",
        "staMac": "***",
        "totalPower": 0.7,  <<<---- energy
        "phase_0_c": 1.13, <<<---- Ampers
        "phase_0_v": 241.08, <---- Voltage
        "phase_0_p": 51.83,   <---- power
        "uiActive": 60
      },
      "model": "CK-BL602-W102SW18-01(226)",
      "online": true,
      "local": null,
      "localtype": null,
      "host": null,

Thanks!!!

joaquimpin commented 3 months ago

Can I upload a pull request, with the fix?

hosand commented 3 months ago

Can I upload a pull request, with the fix?

Did you fix it?

joaquimpin commented 3 months ago

add this to devices.py

226: [
    LED,
    RSSI,
    spec(XSensor100, param="phase_0_c", uid="Current", multiply=1, ),
    spec(XSensor100, param="phase_0_p", uid="Power", multiply=1),
    spec(XSensor100, param="phase_0_v", uid="Voltage", multiply=1, round=0),
],  # CK-BL602-W102SW18-01(226)

The device only reports once a day, I have asked the seller and he says that is how it works. If you enter the ewelink app and show the device, it updates in real time, if not, only once a day, in my case at 11 at night.

hosand commented 2 months ago

add this to devices.py

226: [
    LED,
    RSSI,
    spec(XSensor100, param="phase_0_c", uid="Current", multiply=1, ),
    spec(XSensor100, param="phase_0_p", uid="Power", multiply=1),
    spec(XSensor100, param="phase_0_v", uid="Voltage", multiply=1, round=0),
],  # CK-BL602-W102SW18-01(226)

The device only reports once a day, I have asked the seller and he says that is how it works. If you enter the ewelink app and show the device, it updates in real time, if not, only once a day, in my case at 11 at night.

luvxinh commented 2 months ago

Hi

I think I have the same problem, and someone else's managed to get a solution. So allow me to cut in here.

My device is CK-BL602-SWP1-01(182). I have the same problem being the device updates once an hour if left alone, but would update in real time if the device on ewelink app is opened.

So I found this repo saying he has found the solution: to continuously "probe" the device so it would return the data continuously.

I'm totally noob in these aspects, so I'm just going to paste the link to that repo here with the hope that it can be of help.

https://github.com/PJanisio/ewelinkApiPhp/discussions/18#discussioncomment-10123334

There you go. Cheers

AlexxIT commented 2 months ago

This is known problem for all ewelink pow devices. 182 already fixed. 226 not yet. If you have problems with 182 device - you have problems with cloud connection. Lots of answers in the documentation.

https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#sonoff-pow https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#configuration https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#mode

luvxinh commented 2 months ago

Hi.

Thank you for the quick response.

I've gone through the link you shared and also confirmed that my integration is running on auto mode. Still, it's not updated timely :(

Sorry I didn't share my device diagnostic. Please refer below.

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.7.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.4",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Asia/Bangkok",
    "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": {
    "sonoff": {
      "documentation": "https://github.com/AlexxIT/SonoffLAN",
      "version": "3.7.3",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "watchman": {
      "documentation": "https://github.com/dummylabs/thewatchman",
      "version": "0.6.3",
      "requirements": [
        "prettytable==3.10.0"
      ]
    },
    "spook": {
      "documentation": "https://spook.boo",
      "version": "3.0.1",
      "requirements": []
    },
    "adaptive_lighting": {
      "documentation": "https://github.com/basnijholt/adaptive-lighting#readme",
      "version": "1.22.0",
      "requirements": [
        "ulid-transform"
      ]
    },
    "ble_monitor": {
      "documentation": "https://github.com/custom-components/ble_monitor",
      "version": "12.13.0",
      "requirements": [
        "pycryptodomex>=3.19.1",
        "janus>=1.0.0",
        "aioblescan>=0.2.14",
        "btsocket>=0.2.0",
        "pyric>=0.1.6.3"
      ]
    },
    "spook_inverse": {
      "documentation": "https://spook.boo",
      "version": "3.0.1",
      "requirements": []
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "codeowners": [
      "AlexxIT"
    ],
    "config_flow": true,
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "iot_class": "local_push",
    "issue_tracker": "/api/sonoff/e1196ffc-5d76-48f8-9025-52f6f6380304",
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.7.3",
    "is_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 0.00026288721710443497
    },
    "8ed1489fdbcf6ae6a80db041dbb6a128": {
      "wait_import_platforms": -0.00028786761686205864,
      "wait_base_component": -0.7725813230499625,
      "config_entry_setup": 6.343426560051739
    }
  },
  "data": {
    "version": "e240aaf",
    "cloud_auth": true,
    "config": null,
    "options": {
      "mode": "auto",
      "debug": true
    },
    "errors": [],
    "device": {
      "uiid": 182,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "demNextFetchTime": 1721667600000,
        "rssi": -43,
        "fwVersion": "1.1.1",
        "switches": [
          {
            "switch": "on",
            "outlet": 0
          },
          {
            "switch": "off",
            "outlet": 1
          },
          {
            "switch": "off",
            "outlet": 2
          },
          {
            "switch": "off",
            "outlet": 3
          }
        ],
        "pulses": [
          {
            "pulse": "off",
            "switch": "off",
            "width": 1000,
            "outlet": 0
          },
          {
            "pulse": "off",
            "switch": "off",
            "width": 1000,
            "outlet": 1
          },
          {
            "pulse": "off",
            "switch": "off",
            "width": 1000,
            "outlet": 2
          },
          {
            "pulse": "off",
            "switch": "off",
            "width": 1000,
            "outlet": 3
          }
        ],
        "sledOnline": "off",
        "configure": [
          {
            "startup": "off",
            "outlet": 0
          },
          {
            "startup": "off",
            "outlet": 1
          },
          {
            "startup": "off",
            "outlet": 2
          },
          {
            "startup": "off",
            "outlet": 3
          }
        ],
        "timeZone": 7,
        "current": "0.07",
        "voltage": "226.66",
        "power": "38.41",
        "alarmVValue": [
          -1,
          -1
        ],
        "alarmCValue": [
          -1,
          -1
        ],
        "alarmPValue": [
          -1,
          -1
        ],
        "alarmType": "pcv",
        "ssid": "***",
        "bssid": "***",
        "staMac": "***",
        "threshold": {
          "current": {
            "min": 0.1,
            "max": 15
          },
          "voltage": {
            "min": 0.1,
            "max": 240
          },
          "minActPow": {
            "min": 0.1,
            "max": 3500
          },
          "maxActPow": {
            "min": 10,
            "max": 3500
          }
        },
        "uiActive": 60
      },
      "model": "CK-BL602-SWP1-01(182)",
      "online": true,
      "local": null,
      "localtype": null,
      "host": null,
      "deviceid": "1002224492"
    }
  }
}
AlexxIT commented 2 months ago

I don't see any problem here. You can examine the debug logs on your server. And this issue is not about your device or your problem.

luvxinh commented 2 months ago

I don't see any problem here. You can examine the debug logs on your server. And this issue is not about your device or your problem.

Hi.

I'm sorry for the troubles and please understand that I had no intention to hijack this thread. Apologize if that's how it came across.

I'm happy to share that after a power outage, the device started updating everything timely.

Just want to quickly show my appreciation to you and your time for making life easier for all of us.

Cheers

mirokkkk commented 3 weeks ago

Hi. it will good to see in HA these three entities:

"totalPower": 0.130, "phase_0_c": 0,00 "phase_0_v": 234.470, "phase_0_p": 0,00

hosand commented 3 weeks ago

Hi. it will good to see in HA these three entities:

"totalPower": 0.130, "phase_0_c": 0,00 "phase_0_v": 234.470, "phase_0_p": 0,00 Hi

the only thinks I managed to modified your /homeassistant/custom_components/sonoff/core/devices.py

and added this in

226: [
LED,
RSSI,
spec(XEnergyTotal, param="totalPower", uid="energy", multiply=1, ),
spec(XSensor100, param="phase_0_c", uid="current", multiply=1, ),
spec(XSensor100, param="phase_0_p", uid="power", multiply=1),
spec(XSensor100, param="phase_0_v", uid="voltage", multiply=1, round=2),
], 
# CK-BL602-W102SW18-01(226)

So i can read some data but no update just if you log in to mobile app

AlexxIT commented 3 weeks ago

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

1Bogdan1 commented 3 weeks ago

I confirm - version 3.8.0 my CK-BL602-W102SW18-01 is visible, I can control it and it shows the measurement. Exactly as in the Ewelink application. Thank you very much. sensor

hosand commented 3 weeks ago

I confirm - version 3.8.0 my CK-BL602-W102SW18-01 is visible, I can control it and it shows the measurement. Exactly as in the Ewelink application. Thank you very much. sensor

Can I ask you this version 3.8.0 Did they updated the framework for you or that's how did you buy it?

1Bogdan1 commented 2 weeks ago

I confirm - version 3.8.0 my CK-BL602-W102SW18-01 is visible, I can control it and it shows the measurement. Exactly as in the Ewelink application. Thank you very much. sensor

Can I ask you this version 3.8.0 Did they updated the framework for you or that's how did you buy it?

I updated in HACS.

rafrafk commented 2 weeks ago

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

Thanks Alex was so good, last version.

I find the bug on EARU Circuit Breaker If "WAN DOWN REDIRECT BROWSER NOTICE" is enabled on router then device is not reconnect. If it not enabled then device is reconnect. Maybe you fix it next firmware.

Screenshot_20240912-104428_Chrome