sbidy / pywizlight

A python connector for WiZ devices
MIT License
463 stars 79 forks source link

Power monitoring for ESP24's #165

Closed xanderificnl closed 1 year ago

xanderificnl commented 1 year ago

Hi,

The Wiz app displays power measurements but with homeassistant (using pywizlight) the results are "unknown", perhaps someone can shine some light on this issue?

Below is the debug output from homeassistant, I've chosen not to redact anything since I'm not sure what kind of information may be useful/required; I'm hopeful it'll help.

e27 bulb

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.6.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "6.1.34",
    "supervisor": "2023.06.2",
    "host_os": "Home Assistant OS 10.3",
    "docker_version": "23.0.6",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "tapo": {
      "version": "1.6.1",
      "requirements": [
        "plugp100==2.5.1"
      ]
    },
    "mikrotik_router": {
      "version": "0.0.0",
      "requirements": [
        "librouteros>=3.2.0",
        "mac-vendor-lookup>=0.1.12"
      ]
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "powercalc": {
      "version": "v1.6.7",
      "requirements": [
        "numpy>=1.21.1"
      ]
    },
    "watchman": {
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "nodered": {
      "version": "1.2.0",
      "requirements": []
    },
    "meross_lan": {
      "version": "4.2.0",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "wiz",
    "name": "WiZ",
    "codeowners": [
      "@sbidy"
    ],
    "config_flow": true,
    "dependencies": [
      "network"
    ],
    "dhcp": [
      {
        "registered_devices": true
      },
      {
        "macaddress": "A8BB50*"
      },
      {
        "macaddress": "D8A011*"
      },
      {
        "macaddress": "444F8E*"
      },
      {
        "macaddress": "6C2990*"
      },
      {
        "hostname": "wiz_*"
      }
    ],
    "documentation": "https://www.home-assistant.io/integrations/wiz",
    "iot_class": "local_push",
    "quality_scale": "platinum",
    "requirements": [
      "pywizlight==0.5.14"
    ],
    "is_built_in": true
  },
  "data": {
    "entry": {
      "title": "Bedroom",
      "data": {
        "host": "192.168.88.188"
      }
    },
    "data": {
      "state": {
        "mac": "d8a0111ed0d4",
        "rssi": -57,
        "src": "",
        "state": true,
        "sceneId": 0,
        "r": 18,
        "g": 10,
        "b": 4,
        "c": 0,
        "w": 41,
        "dimming": 10
      },
      "white_range": null,
      "extended_white_range": [
        2200.0,
        2700.0,
        6500.0,
        6500.0
      ],
      "bulb_type": {
        "features": {
          "color": true,
          "color_tmp": true,
          "effect": true,
          "brightness": true,
          "dual_head": false
        },
        "name": "ESP24_SHRGBC_01",
        "kelvin_range": {
          "max": 6500,
          "min": 2200
        },
        "bulb_type": "RGB",
        "fw_version": "1.29.1",
        "white_channels": 1,
        "white_to_color_ratio": 60
      },
      "last_push": 34070.282145875,
      "push_running": true,
      "version": "0.5.14",
      "history": {
        "receive": {
          "getSystemConfig": {
            "method": "getSystemConfig",
            "env": "pro",
            "result": {
              "mac": "d8a0111ed0d4",
              "homeId": "**REDACTED**",
              "roomId": "**REDACTED**",
              "rgn": "eu",
              "moduleName": "ESP24_SHRGBC_01",
              "fwVersion": "1.29.1",
              "groupId": 0,
              "ping": 0
            }
          },
          "getModelConfig": {
            "method": "getModelConfig",
            "env": "pro",
            "result": {
              "ps": 2,
              "pwmFreq": 1000,
              "pwmRes": 11,
              "pwmRange": [
                0,
                100
              ],
              "wcr": 60,
              "nowc": 1,
              "cctRange": [
                2200,
                2700,
                6500,
                6500
              ],
              "renderFactor": [
                200,
                255,
                150,
                255,
                0,
                0,
                40,
                0,
                0,
                0
              ],
              "drvIface": 0
            }
          },
          "getPilot": {
            "method": "getPilot",
            "env": "pro",
            "result": {
              "mac": "d8a0111ed0d4",
              "rssi": -57,
              "src": "",
              "state": true,
              "sceneId": 0,
              "r": 18,
              "g": 10,
              "b": 4,
              "c": 0,
              "w": 41,
              "dimming": 10
            }
          },
          "getPower": {
            "method": "getPower",
            "env": "pro",
            "result": {
              "power": 0
            }
          },
          "registration": {
            "method": "registration",
            "env": "pro",
            "result": {
              "mac": "d8a0111ed0d4",
              "success": true
            }
          }
        },
        "send": {
          "getSystemConfig": {
            "method": "getSystemConfig",
            "params": {}
          },
          "getModelConfig": {
            "method": "getModelConfig",
            "params": {}
          },
          "getPilot": {
            "method": "getPilot",
            "params": {}
          },
          "getPower": {
            "method": "getPower"
          },
          "registration": {
            "params": {
              "phoneIp": "192.168.88.207",
              "register": true,
              "phoneMac": "147ba75eaad5"
            },
            "method": "registration"
          }
        },
        "push": {
          "syncPilot": {
            "method": "syncPilot",
            "env": "pro",
            "params": {
              "mac": "d8a0111ed0d4",
              "rssi": -58,
              "src": "hb",
              "mqttCd": 0,
              "ts": 1687213445,
              "state": true,
              "sceneId": 0,
              "r": 18,
              "g": 10,
              "b": 4,
              "c": 0,
              "w": 41,
              "dimming": 10
            }
          }
        },
        "last_error": null
      },
      "push_manager": {
        "running": true,
        "fail_reason": null
      }
    }
  }
}

gu10 bulbs

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.6.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "6.1.34",
    "supervisor": "2023.06.2",
    "host_os": "Home Assistant OS 10.3",
    "docker_version": "23.0.6",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "tapo": {
      "version": "1.6.1",
      "requirements": [
        "plugp100==2.5.1"
      ]
    },
    "mikrotik_router": {
      "version": "0.0.0",
      "requirements": [
        "librouteros>=3.2.0",
        "mac-vendor-lookup>=0.1.12"
      ]
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "powercalc": {
      "version": "v1.6.7",
      "requirements": [
        "numpy>=1.21.1"
      ]
    },
    "watchman": {
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "nodered": {
      "version": "1.2.0",
      "requirements": []
    },
    "meross_lan": {
      "version": "4.2.0",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "wiz",
    "name": "WiZ",
    "codeowners": [
      "@sbidy"
    ],
    "config_flow": true,
    "dependencies": [
      "network"
    ],
    "dhcp": [
      {
        "registered_devices": true
      },
      {
        "macaddress": "A8BB50*"
      },
      {
        "macaddress": "D8A011*"
      },
      {
        "macaddress": "444F8E*"
      },
      {
        "macaddress": "6C2990*"
      },
      {
        "hostname": "wiz_*"
      }
    ],
    "documentation": "https://www.home-assistant.io/integrations/wiz",
    "iot_class": "local_push",
    "quality_scale": "platinum",
    "requirements": [
      "pywizlight==0.5.14"
    ],
    "is_built_in": true
  },
  "data": {
    "entry": {
      "title": "East facing light",
      "data": {
        "host": "192.168.88.175"
      }
    },
    "data": {
      "state": {
        "mac": "d8a0110629f0",
        "rssi": -47,
        "src": "udp",
        "state": false,
        "sceneId": 0,
        "temp": 6500,
        "dimming": 100
      },
      "white_range": null,
      "extended_white_range": [
        2200.0,
        2700.0,
        6500.0,
        6500.0
      ],
      "bulb_type": {
        "features": {
          "color": true,
          "color_tmp": true,
          "effect": true,
          "brightness": true,
          "dual_head": false
        },
        "name": "ESP24_SHRGBC_01",
        "kelvin_range": {
          "max": 6500,
          "min": 2200
        },
        "bulb_type": "RGB",
        "fw_version": "1.29.1",
        "white_channels": 1,
        "white_to_color_ratio": 40
      },
      "last_push": 34866.868569889,
      "push_running": true,
      "version": "0.5.14",
      "history": {
        "receive": {
          "getSystemConfig": {
            "method": "getSystemConfig",
            "env": "pro",
            "result": {
              "mac": "d8a0110629f0",
              "homeId": "**REDACTED**",
              "roomId": "**REDACTED**",
              "rgn": "eu",
              "moduleName": "ESP24_SHRGBC_01",
              "fwVersion": "1.29.1",
              "groupId": 0,
              "ping": 0
            }
          },
          "getModelConfig": {
            "method": "getModelConfig",
            "env": "pro",
            "result": {
              "ps": 2,
              "pwmFreq": 1000,
              "pwmRes": 11,
              "pwmRange": [
                0,
                100
              ],
              "wcr": 40,
              "nowc": 1,
              "cctRange": [
                2200,
                2700,
                6500,
                6500
              ],
              "renderFactor": [
                200,
                255,
                160,
                255,
                0,
                0,
                40,
                0,
                0,
                0
              ],
              "drvIface": 0
            }
          },
          "getPilot": {
            "method": "getPilot",
            "env": "pro",
            "result": {
              "mac": "d8a0110629f0",
              "rssi": -47,
              "src": "",
              "state": false,
              "sceneId": 0,
              "temp": 6500,
              "dimming": 100
            }
          },
          "getPower": {
            "method": "getPower",
            "env": "pro",
            "result": {
              "power": 0
            }
          },
          "registration": {
            "method": "registration",
            "env": "pro",
            "result": {
              "mac": "d8a0110629f0",
              "success": true
            }
          },
          "setPilot": {
            "method": "setPilot",
            "env": "pro",
            "result": {
              "success": true
            }
          }
        },
        "send": {
          "getSystemConfig": {
            "method": "getSystemConfig",
            "params": {}
          },
          "getModelConfig": {
            "method": "getModelConfig",
            "params": {}
          },
          "getPilot": {
            "method": "getPilot",
            "params": {}
          },
          "getPower": {
            "method": "getPower"
          },
          "registration": {
            "params": {
              "phoneIp": "192.168.88.207",
              "register": true,
              "phoneMac": "147ba75eaad5"
            },
            "method": "registration"
          },
          "setPilot": {
            "method": "setPilot",
            "params": {
              "state": false
            }
          }
        },
        "push": {
          "syncPilot": {
            "method": "syncPilot",
            "env": "pro",
            "params": {
              "mac": "d8a0110629f0",
              "rssi": -48,
              "src": "hb",
              "mqttCd": 0,
              "ts": 1687219888,
              "state": false,
              "sceneId": 0,
              "temp": 6500,
              "dimming": 100
            }
          }
        },
        "last_error": null
      },
      "push_manager": {
        "running": true,
        "fail_reason": null
      }
    }
  }
}

Thanks for any help you can offer!

krstlmnn commented 1 year ago

I'm not very familiar with Home Assistant, but the getPower messages used by pywizlight are not available on all devices, in which case the official app uses alternative methods for computing the power consumption.

See:

xanderificnl commented 1 year ago

Sorry for the late reply. Thanks for the explanation and the links!