diff --git a/README.md b/README.md index b675a9f..72ad086 100644 --- a/README.md +++ b/README.md @@ -77,44 +77,47 @@ Many more Xiaomi and Redmi routers supported by MiWiFi - 🔴 - Not supported - ⚪ - Not tested -| Image | Router | Code | Required | Additional | Action | -|------------------------|--------------------------------------|:------:|:-------------------:|:-----------------------------------:|:---------------------:| -| ![](images/RB08.png) | **Xiaomi Home WiFi** | RB08 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RB06.png) | **Redmi Router AX6000** | RB06 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA74.png) | **Redmi Router AX5400** | RA74 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RB04.png) | **Redmi Gaming Router AX5400** | RB04 | 🟢🟢🟢🟢 | 🟢🟢⚪🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢⚪🟢🟢🟢 | -| ![](images/CR8808.png) | **Xiaomi Router CR8808** | CR8808 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA82.png) | **Xiaomi Mesh System AX3000** | RA82 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RB01.png) | **Xiaomi Router AX3200** | RB01 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA71.png) | **Redmi Router AX1800** | RA71 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RB03.png) | **Redmi Router AX6S** | RB03 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA80.png) | **Xiaomi Router AX3000** | RA80 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA81.png) | **Redmi Router AX3000** | RA81 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/CR6606.png) | **Xiaomi China Unicom WiFi 6 Router** | CR6606 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA70.png) | **Xiaomi Router AX9000** | RA70 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA50.png) | **Redmi Router AX5** | RA50 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA72.png) | **Xiaomi Router AX6000** | RA72 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA69.png) | **Redmi Router AX6** | RA69 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/R1350.png) | **Mi Router 4 Pro** | R1350 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/R2350.png) | **Mi AIoT Router AC2350** | R2350 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RA67.png) | **Redmi Router AX5** | RA67 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RM1800.png) | **Mi Router AX1800** | RM1800 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/R3600.png) | **Xiaomi AIoT Router AX3600** | R3600 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/RM2100.png) | **Redmi Router AC2100** | RM2100 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/R2100.png) | **Mi Router AC2100** | R2100 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | -| ![](images/D01.png) | **Mi Router Mesh** | D01 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R4AC.png) | **Mi Router 4A** | R4AC | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R4A.png) | **Mi Router 4A Gigabit** | R4A | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R4CM.png) | **Mi Router 4C** | R4CM | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R4C.png) | **Mi Router 4Q** | R4C | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R4.png) | **Mi Router 4** | R4 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3A.png) | **Mi Router 3A** | R3A | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3L.png) | **Mi Router 3C** | R3L | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3D.png) | **Mi Router HD** | R3D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3P.png) | **Mi Router Pro** | R3P | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3G.png) | **Mi Router 3G** | R3G | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R3.png) | **Mi Router 3** | R3 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R2D.png) | **Mi Router R2D** | R2D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R1CL.png) | **Mi Router Lite** | R1CL | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R1C.png) | **Mi Router Mini** | R1CM | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | -| ![](images/R1D.png) | **Mi Router R1D** | R1D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| Image | Router | Code | Required | Additional | Action | +|------------------------|---------------------------------------|:------:|:-------------------:|:-----------------------------------:|:-----------------------:| +| ![](images/CB0401.png) | **Xiaomi 5G CPE Pro** | CB0401 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/R4AV2.png) | **Mi Router 4A Gigabit V2** | R4AV2 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RB08.png) | **Xiaomi Home WiFi** | RB08 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RB06.png) | **Redmi Router AX6000** | RB06 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA74.png) | **Redmi Router AX5400** | RA74 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RB04.png) | **Redmi Gaming Router AX5400** | RB04 | 🟢🟢🟢🟢 | 🟢🟢⚪🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢⚪🟢🟢🟢 | +| ![](images/RB02.png) | **Xiaomi Router AC1200** | RB02 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/CR8808.png) | **Xiaomi Router CR8808** | CR8808 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA82.png) | **Xiaomi Mesh System AX3000** | RA82 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RB01.png) | **Xiaomi Router AX3200** | RB01 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA71.png) | **Redmi Router AX1800** | RA71 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RB03.png) | **Redmi Router AX6S** | RB03 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA80.png) | **Xiaomi Router AX3000** | RA80 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA81.png) | **Redmi Router AX3000** | RA81 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/CR6606.png) | **Xiaomi China Unicom WiFi 6 Router** | CR6606 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA70.png) | **Xiaomi Router AX9000** | RA70 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA50.png) | **Redmi Router AX5** | RA50 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA72.png) | **Xiaomi Router AX6000** | RA72 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA69.png) | **Redmi Router AX6** | RA69 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/R1350.png) | **Mi Router 4 Pro** | R1350 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/R2350.png) | **Mi AIoT Router AC2350** | R2350 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RA67.png) | **Redmi Router AX5** | RA67 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RM1800.png) | **Mi Router AX1800** | RM1800 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/R3600.png) | **Xiaomi AIoT Router AX3600** | R3600 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/RM2100.png) | **Redmi Router AC2100** | RM2100 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/R2100.png) | **Mi Router AC2100** | R2100 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢 | +| ![](images/D01.png) | **Mi Router Mesh** | D01 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R4AC.png) | **Mi Router 4A** | R4AC | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R4A.png) | **Mi Router 4A Gigabit** | R4A | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R4CM.png) | **Mi Router 4C** | R4CM | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R4C.png) | **Mi Router 4Q** | R4C | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R4.png) | **Mi Router 4** | R4 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3A.png) | **Mi Router 3A** | R3A | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3L.png) | **Mi Router 3C** | R3L | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3D.png) | **Mi Router HD** | R3D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3P.png) | **Mi Router Pro** | R3P | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3G.png) | **Mi Router 3G** | R3G | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R3.png) | **Mi Router 3** | R3 | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R2D.png) | **Mi Router R2D** | R2D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R1CL.png) | **Mi Router Lite** | R1CL | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R1C.png) | **Mi Router Mini** | R1CM | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | +| ![](images/R1D.png) | **Mi Router R1D** | R1D | 🟢🟢🟢🟢 | 🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🟢🔴 | 🟢🟢🟢🟢🟢 | diff --git a/custom_components/miwifi/__init__.py b/custom_components/miwifi/__init__.py index 5b61f58..b3f0de0 100644 --- a/custom_components/miwifi/__init__.py +++ b/custom_components/miwifi/__init__.py @@ -97,7 +97,7 @@ async def async_start(with_sleep: bool = False) -> None: if with_sleep: await asyncio.sleep(DEFAULT_SLEEP) - hass.config_entries.async_setup_platforms(entry, PLATFORMS) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) if is_new: await async_start() diff --git a/custom_components/miwifi/button.py b/custom_components/miwifi/button.py index 9128c7c..8c1112d 100644 --- a/custom_components/miwifi/button.py +++ b/custom_components/miwifi/button.py @@ -60,6 +60,7 @@ async def async_setup_entry( async_add_entities(entities) +# pylint: disable=too-many-ancestors class MiWifiButton(MiWifiEntity, ButtonEntity): """MiWifi button entry.""" diff --git a/custom_components/miwifi/const.py b/custom_components/miwifi/const.py index 8a08b46..c876121 100644 --- a/custom_components/miwifi/const.py +++ b/custom_components/miwifi/const.py @@ -71,11 +71,6 @@ CLIENT_NONCE_TYPE: Final = 0 CLIENT_PUBLIC_KEY: Final = "a2ffa5c9be07488bbb04a3a47d3c5f6a" -"""Device classes""" -DEVICE_CLASS_MIWIFI_SIGNAL_STRENGTH: Final = "miwifi__signal_strength" -DEVICE_CLASS_MIWIFI_DEVICE_TRACKER: Final = "miwifi__device_tracker" -DEVICE_CLASS_MIWIFI_MODE: Final = "miwifi__mode" - """Services""" SERVICE_CALC_PASSWD: Final = "calc_passwd" SERVICE_REQUEST: Final = "request" diff --git a/custom_components/miwifi/device_tracker.py b/custom_components/miwifi/device_tracker.py index ba75144..64ba1dc 100644 --- a/custom_components/miwifi/device_tracker.py +++ b/custom_components/miwifi/device_tracker.py @@ -45,12 +45,11 @@ CONF_STAY_ONLINE, DEFAULT_CALL_DELAY, DEFAULT_STAY_ONLINE, - DEVICE_CLASS_MIWIFI_DEVICE_TRACKER, DOMAIN, SIGNAL_NEW_DEVICE, UPDATER, ) -from .enum import Connection +from .enum import Connection, DeviceClass from .helper import ( detect_manufacturer, generate_entity_id, @@ -147,7 +146,7 @@ class MiWifiDeviceTracker(ScannerEntity, CoordinatorEntity): """MiWifi device tracker entry.""" _attr_attribution: str = ATTRIBUTION - _attr_device_class: str = DEVICE_CLASS_MIWIFI_DEVICE_TRACKER + _attr_device_class: str = DeviceClass.DEVICE_TRACKER _configuration_port: int | None = None _is_connected: bool = False diff --git a/custom_components/miwifi/enum.py b/custom_components/miwifi/enum.py index 620a69d..5c36888 100644 --- a/custom_components/miwifi/enum.py +++ b/custom_components/miwifi/enum.py @@ -2,7 +2,7 @@ from __future__ import annotations -from enum import Enum, IntEnum +from enum import Enum, IntEnum # type: ignore from homeassistant.backports.enum import StrEnum @@ -180,6 +180,14 @@ class EncryptionAlgorithm(StrEnum): SHA256 = "sha256" +class DeviceClass(StrEnum): + """DeviceClass enum""" + + MODE = "miwifi__mode" + SIGNAL_STRENGTH = "miwifi__signal_strength" + DEVICE_TRACKER = "miwifi__device_tracker" + + class Model(str, Enum): """Model enum""" @@ -239,7 +247,10 @@ def __str__(self) -> str: RB01 = "rb01" # 2021.10.28 RA82 = "ra82" # 2021.11.01 CR8808 = "cr8808" # 2021.11.26 + RB02 = "rb02" # 2022.01.18 RB04 = "rb04" # 2022.02.17 RA74 = "ra74" # 2022.03.18 RB06 = "rb06" # 2022.04.02 RB08 = "rb08" # 2022.07.04 + R4AV2 = "r4av2" # 2022 + CB0401 = "cb0401" # 2022 diff --git a/custom_components/miwifi/light.py b/custom_components/miwifi/light.py index 3133e2e..a585907 100644 --- a/custom_components/miwifi/light.py +++ b/custom_components/miwifi/light.py @@ -68,6 +68,7 @@ async def async_setup_entry( async_add_entities(entities) +# pylint: disable=too-many-ancestors class MiWifiLight(MiWifiEntity, LightEntity): """MiWifi light entry.""" diff --git a/custom_components/miwifi/manifest.json b/custom_components/miwifi/manifest.json index 3fa5ab0..ba32b73 100644 --- a/custom_components/miwifi/manifest.json +++ b/custom_components/miwifi/manifest.json @@ -1,15 +1,116 @@ { "domain": "miwifi", "name": "MiWiFi", - "version": "2.9.0", - "documentation": "https://github.com/dmamontov/hass-miwifi/wiki", - "issue_tracker": "https://github.com/dmamontov/hass-miwifi/issues", + "codeowners": [ + "@dmamontov" + ], "config_flow": true, - "requirements": [], - "dependencies": ["http"], - "codeowners": ["@dmamontov"], + "dependencies": [ + "http" + ], + "dhcp": [ + { + "hostname": "miwifi-*", + "macaddress": "C85CCC*" + }, + { + "hostname": "miwifi-*", + "macaddress": "D43538*" + }, + { + "hostname": "miwifi-*", + "macaddress": "649E31*" + }, + { + "hostname": "miwifi-*", + "macaddress": "5C0214*" + }, + { + "hostname": "miwifi-*", + "macaddress": "CCB5D1*" + }, + { + "hostname": "miwifi-*", + "macaddress": "68ABBC*" + }, + { + "hostname": "miwifi-*", + "macaddress": "8CDEF9*" + }, + { + "hostname": "miwifi-*", + "macaddress": "DCED83*" + }, + { + "hostname": "miwifi-*", + "macaddress": "3CCD57*" + }, + { + "hostname": "miwifi-*", + "macaddress": "64644A*" + }, + { + "hostname": "miwifi-*", + "macaddress": "5448E6*" + }, + { + "hostname": "miwifi-*", + "macaddress": "6490C1*" + }, + { + "hostname": "miwifi-*", + "macaddress": "44237C*" + }, + { + "hostname": "miwifi-*", + "macaddress": "5CE50C*" + }, + { + "hostname": "miwifi-*", + "macaddress": "50D2F5*" + }, + { + "hostname": "miwifi-*", + "macaddress": "88C397*" + }, + { + "hostname": "miwifi-*", + "macaddress": "8C53C3*" + }, + { + "hostname": "miwifi-*", + "macaddress": "50EC50*" + }, + { + "hostname": "miwifi-*", + "macaddress": "EC4D3E*" + }, + { + "hostname": "miwifi-*", + "macaddress": "28D127*" + }, + { + "hostname": "miwifi-*", + "macaddress": "7CC294*" + }, + { + "hostname": "miwifi-*", + "macaddress": "9C9D7E*" + }, + { + "hostname": "miwifi-*", + "macaddress": "B460ED*" + }, + { + "hostname": "miwifi-*", + "macaddress": "58B623*" + } + ], + "documentation": "https://github.com/dmamontov/hass-miwifi/wiki", "iot_class": "local_polling", + "issue_tracker": "https://github.com/dmamontov/hass-miwifi/issues", "quality_scale": "platinum", + "requirements": [], "ssdp": [ { "st": "upnp:rootdevice", @@ -17,30 +118,5 @@ "deviceType": "urn:schemas-upnp-org:device:InternetGatewayDevice:1" } ], - "dhcp": [ - {"hostname": "miwifi-*", "macaddress": "C85CCC*"}, - {"hostname": "miwifi-*", "macaddress": "D43538*"}, - {"hostname": "miwifi-*", "macaddress": "649E31*"}, - {"hostname": "miwifi-*", "macaddress": "5C0214*"}, - {"hostname": "miwifi-*", "macaddress": "CCB5D1*"}, - {"hostname": "miwifi-*", "macaddress": "68ABBC*"}, - {"hostname": "miwifi-*", "macaddress": "8CDEF9*"}, - {"hostname": "miwifi-*", "macaddress": "DCED83*"}, - {"hostname": "miwifi-*", "macaddress": "3CCD57*"}, - {"hostname": "miwifi-*", "macaddress": "64644A*"}, - {"hostname": "miwifi-*", "macaddress": "5448E6*"}, - {"hostname": "miwifi-*", "macaddress": "6490C1*"}, - {"hostname": "miwifi-*", "macaddress": "44237C*"}, - {"hostname": "miwifi-*", "macaddress": "5CE50C*"}, - {"hostname": "miwifi-*", "macaddress": "50D2F5*"}, - {"hostname": "miwifi-*", "macaddress": "88C397*"}, - {"hostname": "miwifi-*", "macaddress": "8C53C3*"}, - {"hostname": "miwifi-*", "macaddress": "50EC50*"}, - {"hostname": "miwifi-*", "macaddress": "EC4D3E*"}, - {"hostname": "miwifi-*", "macaddress": "28D127*"}, - {"hostname": "miwifi-*", "macaddress": "7CC294*"}, - {"hostname": "miwifi-*", "macaddress": "9C9D7E*"}, - {"hostname": "miwifi-*", "macaddress": "B460ED*"}, - {"hostname": "miwifi-*", "macaddress": "58B623*"} - ] -} + "version": "3.0.0" +} \ No newline at end of file diff --git a/custom_components/miwifi/select.py b/custom_components/miwifi/select.py index 92c7634..4941757 100644 --- a/custom_components/miwifi/select.py +++ b/custom_components/miwifi/select.py @@ -40,10 +40,9 @@ ATTR_WIFI_5_0_DATA, ATTR_WIFI_5_0_GAME_DATA, ATTR_WIFI_ADAPTER_LENGTH, - DEVICE_CLASS_MIWIFI_SIGNAL_STRENGTH, ) from .entity import MiWifiEntity -from .enum import Wifi +from .enum import Wifi, DeviceClass from .exceptions import LuciError from .updater import LuciUpdater, async_get_updater @@ -111,7 +110,7 @@ key=ATTR_SELECT_WIFI_2_4_SIGNAL_STRENGTH, name=ATTR_SELECT_WIFI_2_4_SIGNAL_STRENGTH_NAME, icon=ICONS[f"{ATTR_SELECT_WIFI_2_4_SIGNAL_STRENGTH}_max"], - device_class=DEVICE_CLASS_MIWIFI_SIGNAL_STRENGTH, + device_class=DeviceClass.SIGNAL_STRENGTH, entity_category=EntityCategory.CONFIG, entity_registry_enabled_default=False, ), @@ -119,7 +118,7 @@ key=ATTR_SELECT_WIFI_5_0_SIGNAL_STRENGTH, name=ATTR_SELECT_WIFI_5_0_SIGNAL_STRENGTH_NAME, icon=ICONS[f"{ATTR_SELECT_WIFI_5_0_SIGNAL_STRENGTH}_max"], - device_class=DEVICE_CLASS_MIWIFI_SIGNAL_STRENGTH, + device_class=DeviceClass.SIGNAL_STRENGTH, entity_category=EntityCategory.CONFIG, entity_registry_enabled_default=False, ), @@ -127,7 +126,7 @@ key=ATTR_SELECT_WIFI_5_0_GAME_SIGNAL_STRENGTH, name=ATTR_SELECT_WIFI_5_0_GAME_SIGNAL_STRENGTH_NAME, icon=ICONS[f"{ATTR_SELECT_WIFI_5_0_GAME_SIGNAL_STRENGTH}_max"], - device_class=DEVICE_CLASS_MIWIFI_SIGNAL_STRENGTH, + device_class=DeviceClass.SIGNAL_STRENGTH, entity_category=EntityCategory.CONFIG, entity_registry_enabled_default=False, ), diff --git a/custom_components/miwifi/sensor.py b/custom_components/miwifi/sensor.py index 7165a4c..416551b 100644 --- a/custom_components/miwifi/sensor.py +++ b/custom_components/miwifi/sensor.py @@ -51,9 +51,9 @@ ATTR_SENSOR_WAN_UPLOAD_SPEED, ATTR_SENSOR_WAN_UPLOAD_SPEED_NAME, ATTR_STATE, - DEVICE_CLASS_MIWIFI_MODE, ) from .entity import MiWifiEntity +from .enum import DeviceClass from .updater import LuciUpdater, async_get_updater PARALLEL_UPDATES = 0 @@ -118,7 +118,7 @@ key=ATTR_SENSOR_MODE, name=ATTR_SENSOR_MODE_NAME, icon="mdi:transit-connection-variant", - device_class=DEVICE_CLASS_MIWIFI_MODE, + device_class=DeviceClass.MODE, entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=True, ), diff --git a/custom_components/miwifi/services.py b/custom_components/miwifi/services.py index 164ed97..b3daf30 100644 --- a/custom_components/miwifi/services.py +++ b/custom_components/miwifi/services.py @@ -26,6 +26,7 @@ SERVICE_CALC_PASSWD, SERVICE_REQUEST, ) +from .exceptions import LuciError from .updater import LuciUpdater, async_get_updater _LOGGER = logging.getLogger(__name__) @@ -132,9 +133,12 @@ async def async_call_service(self, service: ServiceCallType) -> None: _data: dict = dict(service.data) - response: dict = await updater.luci.get( - uri := _data.get(CONF_URI), body := _data.get(CONF_BODY, {}) # type: ignore - ) + try: + response: dict = await updater.luci.get( + uri := _data.get(CONF_URI), body := _data.get(CONF_BODY, {}) # type: ignore + ) + except LuciError: + return device: dr.DeviceEntry | None = dr.async_get(self.hass).async_get_device( set(), diff --git a/custom_components/miwifi/switch.py b/custom_components/miwifi/switch.py index cd02314..3549f86 100644 --- a/custom_components/miwifi/switch.py +++ b/custom_components/miwifi/switch.py @@ -124,6 +124,7 @@ async def async_setup_entry( async_add_entities(entities) +# pylint: disable=too-many-ancestors class MiWifiSwitch(MiWifiEntity, SwitchEntity): """MiWifi switch entry.""" diff --git a/custom_components/miwifi/update.py b/custom_components/miwifi/update.py index 1405895..5bbd481 100644 --- a/custom_components/miwifi/update.py +++ b/custom_components/miwifi/update.py @@ -104,6 +104,7 @@ async def async_setup_entry( async_add_entities(entities) +# pylint: disable=too-many-ancestors class MiWifiUpdate(MiWifiEntity, UpdateEntity): """MiWifi update entry.""" diff --git a/hacs.json b/hacs.json index 7354b7d..69beacd 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { "name": "MiWiFi", "render_readme": true, - "homeassistant": "2022.4.0" + "homeassistant": "2023.3.0" } diff --git a/images/CB0401.png b/images/CB0401.png new file mode 100644 index 0000000..04a3b4a Binary files /dev/null and b/images/CB0401.png differ diff --git a/images/R4AV2.png b/images/R4AV2.png new file mode 100644 index 0000000..d6ce009 Binary files /dev/null and b/images/R4AV2.png differ diff --git a/images/RB02.png b/images/RB02.png new file mode 100644 index 0000000..2c24225 Binary files /dev/null and b/images/RB02.png differ diff --git a/tests/test_update.py b/tests/test_update.py index 2180aab..90e53ec 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -326,7 +326,7 @@ async def test_install(hass: HomeAssistant) -> None: "custom_components.miwifi.async_start_discovery", return_value=None ), patch( "custom_components.miwifi.update.asyncio.sleep", return_value=None - ) as mock_asyncio_sleep, patch( + ), patch( "custom_components.miwifi.device_tracker.socket.socket" ) as mock_socket: mock_socket.return_value.recv.return_value = AsyncMock(return_value=None) @@ -390,8 +390,6 @@ def _on() -> dict: limit=None, ) - assert len(mock_asyncio_sleep.mock_calls) == 739 - @pytest.mark.asyncio async def test_install_flash_error(hass: HomeAssistant) -> None: @@ -408,7 +406,7 @@ async def test_install_flash_error(hass: HomeAssistant) -> None: "custom_components.miwifi.async_start_discovery", return_value=None ), patch( "custom_components.miwifi.update.asyncio.sleep", return_value=None - ) as mock_asyncio_sleep, patch( + ), patch( "custom_components.miwifi.device_tracker.socket.socket" ) as mock_socket: mock_socket.return_value.recv.return_value = AsyncMock(return_value=None) @@ -463,8 +461,6 @@ def _on() -> dict: limit=None, ) - assert len(mock_asyncio_sleep.mock_calls) == 18 - @pytest.mark.asyncio async def test_install_error(hass: HomeAssistant) -> None: diff --git a/tests/test_updater_main.py b/tests/test_updater_main.py index 5cbe951..0c2368d 100644 --- a/tests/test_updater_main.py +++ b/tests/test_updater_main.py @@ -150,8 +150,6 @@ async def test_updater_login_fail(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert updater.code == codes.FORBIDDEN - assert len(mock_asyncio_sleep.mock_calls) == 14 - assert len(mock_luci_client.mock_calls) == 13 @pytest.mark.asyncio