zha-device-handlers icon indicating copy to clipboard operation
zha-device-handlers copied to clipboard

[BUG] Schneider Exxact Wiser outlet reporting W & Wh a factor 1000 off

Open ptrrkssn opened this issue 3 years ago • 72 comments

Describe the bug Schneider Exxact Wiser outlet seems to report W and Wh a factor 1000 off (or HA/ZHA seems to think so at least). Ie a 900W load is reported as 900kW

To Reproduce Steps to reproduce the behavior: Plug in an 600-900W electrical element into the outlet, check the power usage in Home Assistant for the device...

Expected behavior W & Wh numbers displayed a factor 1000 less.. In the screenshot below it should be 881W not 881840W...

Screenshots IMG_5838

Device signature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4190, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
  "endpoints": {
    "6": {
      "profile_id": 260,
      "device_type": "0x0009",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0702",
        "0x0708",
        "0x0b04",
        "0x0b05",
        "0xfc04"
      ],
      "out_clusters": [
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "Schneider Electric",
  "model": "SOCKET/OUTLET/2",
  "class": "zigpy.device.Device"
}

Diagnostic information
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.11.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Stockholm",
    "os_name": "Linux",
    "os_version": "5.15.74",
    "supervisor": "2022.10.2",
    "host_os": "Home Assistant OS 9.3",
    "docker_version": "20.10.18",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "nordpool": {
      "version": "0.0.7",
      "requirements": [
        "nordpool>=0.2"
      ]
    },
    "programmable_thermostat": {
      "version": "8.1",
      "requirements": []
    },
    "scheduler": {
      "version": "v0.0.0",
      "requirements": []
    },
    "hacs": {
      "version": "1.28.2",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.34.2",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.84",
      "zigpy-deconz==0.19.0",
      "zigpy==0.51.5",
      "zigpy-xbee==0.16.2",
      "zigpy-zigate==0.10.3",
      "zigpy-znp==0.9.1"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "1A86",
        "pid": "55D4",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus v2"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      },
      {
        "type": "_zigstar_gw._tcp.local.",
        "name": "*zigstar*"
      }
    ],
    "dependencies": [
      "file_upload"
    ],
    "after_dependencies": [
      "onboarding",
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 32853,
    "manufacturer": "Schneider Electric",
    "model": "SOCKET/OUTLET/2",
    "name": "Schneider Electric SOCKET/OUTLET/2",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4190,
    "power_source": "Mains",
    "lqi": 255,
    "rssi": -56,
    "last_seen": "2022-11-04T19:57:25",
    "available": true,
    "device_type": "Router",
    "signature": {
      "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4190, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
      "endpoints": {
        "6": {
          "profile_id": 260,
          "device_type": "0x0009",
          "in_clusters": [
            "0x0000",
            "0x0003",
            "0x0004",
            "0x0005",
            "0x0006",
            "0x0702",
            "0x0708",
            "0x0b04",
            "0x0b05",
            "0xfc04"
          ],
          "out_clusters": [
            "0x0019"
          ]
        },
        "242": {
          "profile_id": 41440,
          "device_type": "0x0061",
          "in_clusters": [],
          "out_clusters": [
            "0x0021"
          ]
        }
      }
    },
    "active_coordinator": false,
    "entities": [
      {
        "entity_id": "button.schneider_electric_socket_outlet_2_identify",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "select.schneider_electric_socket_outlet_2_start_up_behavior",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "sensor.schneider_electric_socket_outlet_2_rms_current",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "sensor.schneider_electric_socket_outlet_2_rms_voltage",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "sensor.schneider_electric_socket_outlet_2_power_factor",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "sensor.schneider_electric_socket_outlet_2_instantaneous_demand",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "sensor.schneider_electric_socket_outlet_2_summation_delivered",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      },
      {
        "entity_id": "switch.schneider_outlet_element",
        "name": "Schneider Electric SOCKET/OUTLET/2"
      }
    ],
    "neighbors": [
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x00A7",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "131"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x1E97",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "112"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x237B",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "47"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x3A79",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "207"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x468D",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "72"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x49C0",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "119"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x56AC",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "109"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x5B9F",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "144"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x64D5",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "174"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x6AFF",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "140"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x6D1F",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "83"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x6D33",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "135"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x7C29",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "160"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x99A5",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "144"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x99C7",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "144"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x9CFB",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "176"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0x9DC3",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "128"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xA38F",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "128"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xA38F",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "128"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Parent",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xAAF9",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "142"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xCEB9",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "195"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xD7D9",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "184"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xDBE1",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "169"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xE698",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "167"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xF6C5",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "113"
      },
      {
        "device_type": "Router",
        "rx_on_when_idle": "On",
        "relationship": "Sibling",
        "extended_pan_id": "**REDACTED**",
        "ieee": "**REDACTED**",
        "nwk": "0xF922",
        "permit_joining": "Unknown",
        "depth": "15",
        "lqi": "128"
      }
    ],
    "endpoint_names": [
      {
        "name": "MAIN_POWER_OUTLET"
      },
      {
        "name": "unknown 97 device_type of 0xa1e0 profile id"
      }
    ],
    "user_given_name": "K\u00f6ket Elementuttaget",
    "device_reg_id": "40ea6971c90041fd695ac249e530cc4b",
    "area_id": "kitchen",
    "cluster_details": {
      "6": {
        "device_type": {
          "name": "MAIN_POWER_OUTLET",
          "id": 9
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "Schneider Electric"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "SOCKET/OUTLET/2"
              }
            },
            "unsupported_attributes": {}
          },
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0006": {
            "endpoint_attribute": "on_off",
            "attributes": {
              "0x0000": {
                "attribute_name": "on_off",
                "value": 1
              },
              "0x4003": {
                "attribute_name": "start_up_on_off",
                "value": 255
              }
            },
            "unsupported_attributes": {}
          },
          "0x0702": {
            "endpoint_attribute": "smartenergy_metering",
            "attributes": {
              "0x0000": {
                "attribute_name": "current_summ_delivered",
                "value": 6931
              },
              "0x0200": {
                "attribute_name": "status",
                "value": 0
              },
              "0x0204": {
                "attribute_name": "extended_status",
                "value": 0
              },
              "0x0207": {
                "attribute_name": "iambient_consumption_indicator",
                "value": 2
              },
              "0x0300": {
                "attribute_name": "unit_of_measure",
                "value": 0
              },
              "0x0301": {
                "attribute_name": "multiplier",
                "value": 1
              },
              "0x0302": {
                "attribute_name": "divisor",
                "value": 1000
              },
              "0x0303": {
                "attribute_name": "summation_formatting",
                "value": 75
              },
              "0x0306": {
                "attribute_name": "metering_device_type",
                "value": 0
              },
              "0x0400": {
                "attribute_name": "instantaneous_demand",
                "value": 872121
              }
            },
            "unsupported_attributes": {
              "0x0304": {
                "attribute_name": "demand_formatting"
              }
            }
          },
          "0x0708": {
            "endpoint_attribute": "smartenergy_device_management",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0b04": {
            "endpoint_attribute": "electrical_measurement",
            "attributes": {
              "0x0000": {
                "attribute_name": "measurement_type",
                "value": 8
              },
              "0x0505": {
                "attribute_name": "rms_voltage",
                "value": 236
              },
              "0x0508": {
                "attribute_name": "rms_current",
                "value": 3695
              },
              "0x0602": {
                "attribute_name": "ac_current_multiplier",
                "value": 1
              },
              "0x0603": {
                "attribute_name": "ac_current_divisor",
                "value": 1000
              }
            },
            "unsupported_attributes": {
              "0x0300": {
                "attribute_name": "ac_frequency"
              },
              "0x0601": {
                "attribute_name": "ac_voltage_divisor"
              },
              "0x0302": {
                "attribute_name": "ac_frequency_max"
              },
              "0x0600": {
                "attribute_name": "ac_voltage_multiplier"
              },
              "0x0604": {
                "attribute_name": "ac_power_multiplier"
              },
              "0x0605": {
                "attribute_name": "ac_power_divisor"
              },
              "0x0401": {
                "attribute_name": "ac_frequency_divisor"
              },
              "0x0507": {
                "attribute_name": "rms_voltage_max"
              },
              "0x0400": {
                "attribute_name": "ac_frequency_multiplier"
              },
              "0x0403": {
                "attribute_name": "power_divisor"
              },
              "0x050a": {
                "attribute_name": "rms_current_max"
              },
              "0x050b": {
                "attribute_name": "active_power"
              },
              "0x050d": {
                "attribute_name": "active_power_max"
              },
              "0x050f": {
                "attribute_name": "apparent_power"
              },
              "0x0402": {
                "attribute_name": "power_multiplier"
              }
            }
          },
          "0x0b05": {
            "endpoint_attribute": "diagnostic",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xfc04": {
            "endpoint_attribute": "manufacturer_specific",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      },
      "242": {
        "device_type": {
          "name": "unknown",
          "id": 97
        },
        "profile_id": 41440,
        "in_clusters": {},
        "out_clusters": {
          "0x0021": {
            "endpoint_attribute": "green_power",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}
Additional logs
Paste any additional debug logs here.
Don't remove the extra line breaks outside the ``` marks.

Additional context Add any other context about the problem here.

ptrrkssn avatar Nov 04 '22 19:11 ptrrkssn

Can you try to read from the cluster MeteringCluster (Endpoint id: 1, Id: 0x0702, Type: in) the attributes divisor (id: 0x0302) and multiplier (id: 0x0301)?

You can do it from the device view -> Admin Zigbee device --> Clusters Select the cluster and attribute and push the "get attribute" button.

Once you get the values try to increasse the divisor value x1000.

javicalle avatar Nov 04 '22 20:11 javicalle

Tried it now - divisor was set to 1000. multiplier to 1. Tried to change it but it seems to just revert back to the same values.

ptrrkssn avatar Nov 04 '22 23:11 ptrrkssn

My bad, the attributes are read only 🤦🏻‍♂️ : image

It seems extrange to me because divisor already has the 1000 divisor value. Which Zigbee gateway are you using?

javicalle avatar Nov 05 '22 11:11 javicalle

I'm using a ConBee II with the latest available firmware (0x26780700). (Connected via an extension cable to an Intel NUC running the updated HassOS/HA :-)

HA 2022.11.1 SUP 2022.10.2 OS 9.3 Frontend 20221102.1

ptrrkssn avatar Nov 05 '22 17:11 ptrrkssn

Have you tried to remove and pair the device again? It seems that the value is already here so no clear to me if the quirk would work.

javicalle avatar Nov 05 '22 18:11 javicalle

The device (devices actually, I have 3 of them, one I've had some time, and two new ones I just got) was recently paired, but I guess I can try to re-pair it.

ptrrkssn avatar Nov 05 '22 18:11 ptrrkssn

Is the same behavior in all three devices?

javicalle avatar Nov 05 '22 19:11 javicalle

Yes, same on all three. Firmware 0x020612ff, sw_build_id 002.006.018 R

ptrrkssn avatar Nov 05 '22 19:11 ptrrkssn

I still believe that the problem must be elsewhere but if you want to try, there is a quirk for your device:

schneider_plug.py
"""Schneider Electric plugs quirks."""
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    GreenPowerProxy,
    Groups,
    Identify,
    OnOff,
    Ota,
    Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic, ElectricalMeasurement
from zigpy.zcl.clusters.smartenergy import DeviceManagement, Metering

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)


class MeteringCluster(CustomCluster, Metering):
    """Fix the Metering divisor."""

    MULTIPLIER = 0x0301
    DIVISOR = 0x0302
    _CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000000}


class SocketOutlet2(CustomDevice):
    """Schneider Electric Socket outlet 2."""

    signature = {
        MODELS_INFO: [("Schneider Electric", "SOCKET/OUTLET/2")],
        ENDPOINTS: {
            6: {
                # "profile_id": 260,
                # "device_type": "0x0009",
                # "in_clusters": ["0x0000","0x0003","0x0004","0x0005","0x0006","0x0702","0x0708","0x0b04","0x0b05","0xfc04"],
                # "out_clusters": ["0x0019"]
                PROFILE_ID: 0x0104,
                DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOff.cluster_id,
                    Metering.cluster_id,
                    DeviceManagement.cluster_id,
                    ElectricalMeasurement.cluster_id,
                    Diagnostic.cluster_id,
                    0xFC04,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
            242: {
                # "profile_id": 41440,
                # "device_type": "0x0061",
                # "in_clusters": [],
                # "out_clusters": ["0x0021"]
                PROFILE_ID: 41440,
                DEVICE_TYPE: 97,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }

    replacement = {
        ENDPOINTS: {
            6: {
                PROFILE_ID: 0x0104,
                DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOff.cluster_id,
                    MeteringCluster,
                    DeviceManagement.cluster_id,
                    ElectricalMeasurement.cluster_id,
                    Diagnostic.cluster_id,
                    0xFC04,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
            242: {
                PROFILE_ID: 41440,
                DEVICE_TYPE: 97,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }

You will need to enable the local quirk in your instalation. There is a guide about enabling custom quirks:

  • https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274

Create in your local quirk folder a new schneider_plug.py file and put the suggested quirk in file.

Restart HA, remove and pair you device again. Check that the device is loading the quirk and that the device signature has changed.

javicalle avatar Nov 06 '22 20:11 javicalle

Maybe related to: #1705

javicalle avatar Nov 06 '22 20:11 javicalle

With that local quirk installed and the devices re-paired the Instantaneous Demand (W) figure is right (881W), however I wonder if not the Summation Delivered now becomes a factor 1000 too low instead - which was correct before.

I wonder if we're chasing the wrong thing and perhaps it's the ZCL_ATTR_METERING_SUMMATION_FORMATTING and ZCL_ATTR_METERING_DEMAND_FORMATTING attributes that isn't used correctly somewhere? I'm no Zigbee expert so this might be totally wrong but...

Summation formatting has the value "bitmap8.64|8|2|1" and Demand Formatting has "none" when I try to read them.

If I read the zcl metering cluster documentation correctly that should mean 01001011 = 0 = do not suppress leading zeros 1 = ? 001 = 1 digit to the right of decimal point 011 = 3 digits to the left of the decimal point

The instantaneous_demand attribute value is 873311 and current_summ_delivered is 1200 right now.

A reasonable interpretation of those numbers at 873.311 W and 1.2 kWH (seems reasonable since I re-pair:ed it)

ptrrkssn avatar Nov 07 '22 00:11 ptrrkssn

With that local quirk installed and the devices re-paired the Instantaneous Demand (W) figure is right (881W), however I wonder if not the Summation Delivered now becomes a factor 1000 too low instead - which was correct before.

That makes sense because instantaneous_demand and current_summ_delivered are afected by the same multiplier and divisor:

  • https://github.com/zigpy/zigpy/blob/8a2c7548065367d7e94ddf5857652ca1cd087e70/zigpy/zcl/clusters/smartenergy.py#L190-L191

If I read the zcl metering cluster documentation correctly that should mean 01001011 = 0 = do not suppress leading zeros 1 = ? 001 = 1 digit to the right of decimal point 011 = 3 digits to the left of the decimal point

According to (i.e.) ZHA:

  • https://github.com/home-assistant/core/blob/bc146a09dba6df6eaec429039f6e1efcfbd1123f/homeassistant/components/zha/core/channels/smartenergy.py#L194-L200

That would be like (but don't sure because not make sense to me with the result 🤷🏻‍♂️): 0 = do not suppress leading zeros 1001 = 9 digits to the left of decimal point (bits 3-6) 011 = 3 digits to the right of the decimal point (bits 0-2)

There are a few examples here:

  • https://zigbeealliance.org/wp-content/uploads/2019/11/docs-07-5356-19-0zse-zigbee-smart-energy-profile-specification.pdf#page=236&zoom=100,90,402

So, do you think we could have fixed it by just setting the demand_formatting?

Maybe with a little of trial and error we can get the right 'format'.

You can try with:

class MeteringCluster(CustomCluster, Metering):
    """Fix the Metering divisor."""

    MULTIPLIER = 0x0301
    DIVISOR = 0x0302
    DEMMAND_FORMATTING = 0x0304

    # _CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000000}
    _CONSTANT_ATTRIBUTES = {DEMMAND_FORMATTING: 75}

javicalle avatar Nov 07 '22 20:11 javicalle

Hmm.. Nope, doesn't work. It seems to ignore the demand_formatting stuff. I've been reading the core/homeassistant/components/zha/sensor.py code a bit to try to understand what's happening. A couple of observations:

class SmartEnergySummation, starting at line 472, unit_of_measure_map: 0x00 = ENERGY_KILO_WATT_HOUR ...

   def formatter(self, value: int) -> int | float:
        """Numeric pass-through formatter."""
        if self._channel.unit_of_measurement != 0:
            return self._channel.summa_formatter(value)

        cooked = float(self._channel.multiplier * value) / self._channel.divisor
        return round(cooked, 3)

class SmartEnergyMetering, starting at line 424, unit_of_measure_map: 0x00 = POWER_WATT ...

    def formatter(self, value: int) -> int | float:
        """Pass through channel formatter."""
        return self._channel.demand_formatter(value)

Notice here: no cooked-stuff with the multiplier/divisor! And unit_of_measurement is 0x00 so for Summation it will execute the cooked stuff and ignore the channel.summa_formatter, but for the Instantaneous Demand stuff it will call the demand_formatter.

Looking at the formatter code in smartenergy.py, line 213, it seems to assume that unit_of_measurement always means kW:

    def _formatter_function(
        self, selector: FormatSelector, value: int
    ) -> int | float | str:
        """Return formatted value for display."""
        value_float = value * self.multiplier / self.divisor
        if self.unit_of_measurement == 0:
            # Zigbee spec power unit is kW, but we show the value in W
            value_watt = value_float * 1000
            if value_watt < 100:
                return round(value_watt, 1)
            return round(value_watt)
        if selector == self.FormatSelector.SUMMATION:
            assert self._summa_format
            return self._summa_format.format(value_float).lstrip()
        assert self._format_spec
        return self._format_spec.format(value_float).lstrip()

This feels a bit wrong and I think that multiplication of value_float -> value_watt by 1000 should be removed, or the value sent to it divided by 1000 in sensor.py, or add similar code that checks unit_of_measurement that summation does - this one is probably easiest. I'm no Python programmer so I'm a bit unsure how to implement a quirk that overrides this though...

ptrrkssn avatar Nov 08 '22 18:11 ptrrkssn

I modified the quirk with this and then re-pair:ed the outlet and now I get sane values for both Instantaneous Demand and Summation Delivered...

However I still think that the code in core/homeassistant/components/zha/sensor.py at line 424 is suspect and possibly should be fixed similar to the code at line 472.

class MeteringCluster(CustomCluster, Metering):
    """Fix the Instataneous Demand value."""

    INSTANTANEOUS_DEMAND = 0x0400

    def _update_attribute(self, attrid, value):
        if attrid == self.INSTANTANEOUS_DEMAND:
            value = value / 1000.0
        super()._update_attribute(attrid, value)
        

ptrrkssn avatar Nov 15 '22 21:11 ptrrkssn

What are you looking at in ZHA? https://github.com/home-assistant/core/blob/7614aba401ffd4041d9dac09344d37b7525c4685/homeassistant/components/zha/sensor.py#L424

The code from your block comment is from a quirk and not ZHA itself.

dmulcahey avatar Nov 15 '22 21:11 dmulcahey

Yes, my code is from the quirk we discussed previously in this thread. I just removed the code we were testing there.

But what I suspect is the real problem (also written about above) is in core/homeassistant/components/zha/sensor.py where:

class SmartEnergySummation, starting at line 472, unit_of_measure_map: 0x00 = ENERGY_KILO_WATT_HOUR

   def formatter(self, value: int) -> int | float:
        """Numeric pass-through formatter."""
        if self._channel.unit_of_measurement != 0:
            return self._channel.summa_formatter(value)

        cooked = float(self._channel.multiplier * value) / self._channel.divisor
        return round(cooked, 3)

but:

class SmartEnergyMetering, starting at line 424, unit_of_measure_map: 0x00 = POWER_WATT

    def formatter(self, value: int) -> int | float:
        """Pass through channel formatter."""
        return self._channel.demand_formatter(value)

Notice here: no cooked-stuff with the multiplier/divisor! And unit_of_measurement is 0x00 so for Summation it will execute the cooked stuff and ignore the channel.summa_formatter, but for the Instantaneous Demand stuff it will call the demand_formatter. So perhaps add the same " if self._channel.unit_of_measurement != 0:" test to the this code?

I'd test this on my HA installation but I don't know how to do that since I'm running HassIO on my system.

ptrrkssn avatar Nov 15 '22 21:11 ptrrkssn

No the quirk should be setting the correct values for multiplier and divisor.

dmulcahey avatar Nov 15 '22 21:11 dmulcahey

The logic is all in the channel: https://github.com/home-assistant/core/blob/ae7272575a30e73fc9d6cecb0217cd15a4ba0d59/homeassistant/components/zha/core/channels/smartenergy.py#L230

dmulcahey avatar Nov 15 '22 21:11 dmulcahey

No the quirk should be setting the correct values for multiplier and divisor.

Sure, but how? If we set divisor to 1000 (which it already is by default from the device btw) then Summation is correct, but Instantaneous becomes 1000 times to high. If we set divisor to 1000000 then Instantaneous is correct, but Summation gets 1000 times too low...

ptrrkssn avatar Nov 15 '22 21:11 ptrrkssn

I believe that there is something at least 'extrange' to me.

In Zigbee specification I can read:

D.3.2.2.4Formatting
The following set of attributes provides the ratios and formatting hints required to transform the
received summations, consumptions, temperatures, or demands/ rates into displayable values.
If the Multiplier and Divisor attribute values are non-zero, they are used in conjunction with the
SummationFormatting, ConsumptionFormatting, DemandFormatting, and
TemperatureFormatting attributes.

As I understand, if there are a multiplier/divisor it aplies to all measurements.

But, in ZHA there is something diferent in how is applied in SmartEnergyMetering and SmartEnergySummation. Shouldn't it be applied in the same way in both cases?

javicalle avatar Nov 15 '22 21:11 javicalle

Full transparency I responded the first time to just the last comment without reading the thread. Let me look through the entire thing later tonight to see what the deal is.

dmulcahey avatar Nov 15 '22 22:11 dmulcahey

I wish I had some other zigbee devices with power metering that provides these attributes, but my only other (zigbee) device is an Aqara Plug, and it doesn't support them (at least not at the firmware level that one is at :-). Would have been interesting to compare things :-)

ptrrkssn avatar Nov 15 '22 22:11 ptrrkssn

I may have some that support both. I’ll try to investigate tonight/tomorrow depending on availability

dmulcahey avatar Nov 15 '22 22:11 dmulcahey

I'd test this on my HA installation but I don't know how to do that since I'm running HassIO on my system.

You can copy all the zha folder as a custom_components in HA and edit the desired class.

javicalle avatar Nov 15 '22 23:11 javicalle

Hello. I have installed 2 WDE002172 (Wiser 1 way outlet), same as @ptrrkssn but with one outlet. Exactly the same problem. Following this and hope you find a solution, if I can help with anything please tell me. Home assistant on NUC, Conbee II stick (ZHA), FW on my sockets is 0x020612ff Picture below is with washing machine, even I think summation (kWh) is correct and Instantaneous (W) is wrong.
image

krlssn avatar Nov 16 '22 11:11 krlssn

OK I have devices that support both of these that do return values correctly (Sengled bulbs - not quirked) What is the device actually reporting for both of these attributes?

image

image

I am fairly certain I have some plugs in a bin somewhere that work right too. I can look for them later...

the device is saying its uom is kWh... are you publishing both values in kWh?

dmulcahey avatar Nov 16 '22 15:11 dmulcahey

I'm sorry, don't understand what info you want. The problem we have is that the sensor named Instant... is reporting energy x1000, in my example above the correct value should be 2053,132W or even better 2053W.

krlssn avatar Nov 16 '22 17:11 krlssn

@krlssn please, attach the device diagnostic with a screenshoot for the current values.

javicalle avatar Nov 16 '22 17:11 javicalle

image Like this?

krlssn avatar Nov 16 '22 17:11 krlssn

Instantaneous is current power draw for the device… meaning what it is consuming at that instant

dmulcahey avatar Nov 16 '22 17:11 dmulcahey