Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ptrrkssn opened this issue Nov 4, 2022 · 72 comments
Open
Labels
custom quirk available A custom quirk is available to solve the issue, but it's not merged in the repo yet

Comments

@ptrrkssn
Copy link

ptrrkssn commented Nov 4, 2022

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.

@javicalle
Copy link
Collaborator

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.

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 4, 2022

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.

@javicalle
Copy link
Collaborator

javicalle commented Nov 5, 2022

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?

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 5, 2022

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

@javicalle
Copy link
Collaborator

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.

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 5, 2022

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.

@javicalle
Copy link
Collaborator

Is the same behavior in all three devices?

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 5, 2022

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

@javicalle
Copy link
Collaborator

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:

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
Copy link
Collaborator

Maybe related to: #1705

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 7, 2022

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)

@javicalle
Copy link
Collaborator

javicalle commented Nov 7, 2022

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:

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:

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:

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}

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 8, 2022

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
Copy link
Author

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)
        

@dmulcahey
Copy link
Collaborator

dmulcahey commented Nov 15, 2022

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.

@ptrrkssn
Copy link
Author

ptrrkssn commented Nov 15, 2022

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.

@dmulcahey
Copy link
Collaborator

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

@dmulcahey
Copy link
Collaborator

@ptrrkssn
Copy link
Author

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...

@javicalle
Copy link
Collaborator

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?

@dmulcahey
Copy link
Collaborator

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.

@ptrrkssn
Copy link
Author

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 :-)

@dmulcahey
Copy link
Collaborator

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

@javicalle
Copy link
Collaborator

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.

@krlssn
Copy link

krlssn commented Nov 16, 2022

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

@dmulcahey
Copy link
Collaborator

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?

@krlssn
Copy link

krlssn commented Nov 16, 2022

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.

@javicalle
Copy link
Collaborator

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

@krlssn
Copy link

krlssn commented Nov 16, 2022

image
Like this?

@dmulcahey
Copy link
Collaborator

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

@javicalle
Copy link
Collaborator

The multiplier/divisor attributes are read only and couldn't be changed from UI.
Usually the values you change, you can restore... if you now the previous value.
I appreciate the efforts, but we have the necessary info from the diagnostics.

@javicalle
Copy link
Collaborator

Looking at the data I have come to the same conclusion as David (but much slower):

So is the device doing it’s own conversion to watts on the instantaneous demand attribute?

Putting 2 plugs in serial (the affected one and another well working one) would confirm the suspicions.

So probably the solution goes through the quirk that Peter proposes.
However, I am concerned that since it is a bug in the device, in an updated version the problem may be resolved and that it may present conflicts.

For these attributes, the formatting don't play any role in the code (also, didn't would change the value, just the format), so not relevant.

@krlssn
Copy link

krlssn commented Nov 17, 2022

So you mean that if Schneider fix a FW update of the device it would be fixed? Does this only affect HA (ZHA) connected devices or devices connected through Wisers own app too?
I don't have other Zigbee devices with metering, but I have Fibro wall plugs if it should help (to confirm this issue)?

@javicalle
Copy link
Collaborator

What I mean is, if that is a firmware bug as it seems, probably SE will patch it. Then it could be that we can find devices with new firmware version (because SE sells the devices with the new version or because users update its devices through SE gateway).
If we patch the same in ZHA (with a quirk) I am not sure if we can check the device firmware version to apply or not the quirk.

I don't know if Wiser app exposes the values correctly or not, but every manufacturer can do a particular interpretation from the Zigbee specifications, so maybe they in its app are showing the values in other way (and fine with the metering values) despite the device don't follow the standar.

I don't have other Zigbee devices with metering, but I have Fibro wall plugs if it should help (to confirm this issue)?

My point is to compare between 2 devices with 'instantaneous demmand' metering to see its cluster attribute values.

@krlssn
Copy link

krlssn commented Nov 17, 2022

Ok, then I guess FB wallplug don't talk "the same language" and it won't help here. No idea if Schneider will fix fw, if it is no problem in their own app I guess their priority is lower and a fix from you would be awesome. Understand the problem if/when different FW appear.

@javicalle
Copy link
Collaborator

And here it is...

Elko EKO09738 and EKO09716 reports power in mW, scale to W

https://github.com/Koenkk/zigbee-herdsman-converters/blob/081c81ef0131c5cd7dae342d3784e501e1c0cb68/converters/fromZigbee.js#L712-L725

That quirk is applied to the SE devices:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/081c81ef0131c5cd7dae342d3784e501e1c0cb68/devices/schneider_electric.js#L762-L779

We don't thank Z2M enough for the work they do there.

@ptrrkssn if you don't mind you can create the PR yourself, if possible also adding the signature for the SOCKET/OUTLET/1.

@krlssn
Copy link

krlssn commented Nov 17, 2022

Sounds perfect😄 What do I need to do/what should I add to my system to get the correct scaled values?

@javicalle
Copy link
Collaborator

You can wait to the next HA release to see if the quirk has been added to the version.
If you don't want/can't wait until next month, you can put the proposed quirk as a local quirk in your instalation (and remember to remove it when updating HA).

The quirk would be the one from #1889 (comment)

There is a guide about enabling custom quirks:

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.

@krlssn
Copy link

krlssn commented Nov 17, 2022

Thank you! If I wait until it comes in future HA release, do I have to unpair/pair devices to get correct values or do it "autoupdate"?

@javicalle
Copy link
Collaborator

I can't tell you for sure, but as a standar procedure I will suggest you to perform the unpair/pair to be sure.

@krlssn
Copy link

krlssn commented Nov 27, 2022

Hi
Stupid question again... How can I find if this has been fixed? Have got some updates to my system, but I dont know in which of the updates bugs like this is fixed, and how I find it (how it's named) in release notes...? Is it Home assistant, supervisor or operating system that includes these uptades?
image

@javicalle
Copy link
Collaborator

There's no an easy way to know it.
You can check if the HA version includes any zha handler update. Then you can look at the version changelog if includes the fix. But...

The first thing will be to have a PR/fix/quirk to look for. And there's no PR yet for this issue. So, until someone creates a PR and that would be merged the fix don't be available to all the users.

@krlssn
Copy link

krlssn commented Dec 2, 2022

Update:
I managed to insert the local quirk @ptrrkssn (🙏👍) made for SOCKET/OUTLET/2 (I bought a 2way socket too) with success! I have also made a new quirk file for SOCKET/OUTLET/1 (just replaced "2" with "1" in the code. Everything seems to work. I didn't need to unpair/reinclude the devices, HA restart was enough. Maybe I re-include just to get correct graphs in the history because now it is 0-2500000 so hard to read when ~0-2500 looks better, maybe there is a simpler way...
How is the "correct" way to to this, can multiple devices be included in the same quirk file or is 1 file/device better? If it can be done in the same file, is it copy paste all code after each other, or can I just add SOCKET/OUTLET/2 and SOCKET/OUTLET/1 after each other on the places they are used in the code?
@javicalle Does your text in #1889 (comment) mean that this "PR" covers the Wiser sockets too, or do they need a new "PR"?

image

image

@javicalle
Copy link
Collaborator

I would suggest to create a new schneider_electric or schneiderelectric (like in https://github.com/zigpy/zha-device-handlers/pull/1705/files)

I would put all together in the same file and the same quirk, probably in a plug.py.
Like both devices have the same signature it will be better to put in the same quirk:

    signature = {
        MODELS_INFO: [
            ("Schneider Electric", "SOCKET/OUTLET/1"),
            ("Schneider Electric", "SOCKET/OUTLET/2"),
        ],
        ENDPOINTS: {
            .../...

@krlssn
Copy link

krlssn commented Dec 5, 2022

New *py file if someone needs it. Working for me with both WDE002182 (2way) and WDE002172 (1way). Gives me correct values in "instantaneous_demand".

Checked the site https://github.com/zigpy/zha-device-handlers/compare but not sure what to do, needs comparing to open PR and this stuff is new to me so I dont know what to "compare" to open a new pull request.

socketoutlet.py.txt

@TheJulianJES TheJulianJES added the custom quirk available A custom quirk is available to solve the issue, but it's not merged in the repo yet label Jan 4, 2023
@github-actions
Copy link

github-actions bot commented Jul 3, 2023

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Issue is inactivate and might get closed soon label Jul 3, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2023
@kosmiq
Copy link
Contributor

kosmiq commented Nov 30, 2023

I just added my 2-way outlet and ran into this very issue. I am using the latest version of Home Assistant (running on a HA Green). Using SkyConnect and ZHA.

So is there a way to get this merged into an actual release or how does that work?

@krlssn
Copy link

krlssn commented Nov 30, 2023 via email

@kosmiq
Copy link
Contributor

kosmiq commented Dec 1, 2023

As I understand the fix (quirk) needs to be added as a pull request first, then it can be added into future release of ZHA integration in HA. I didnt manage how to do this. I still need to "inactivate" and reactivate the quirk every time I update HA (and some other steps). Had been very nice to get this fixed. I think it's ZHA people who need to merge this when the PR is created.  I read somewhere that zigbee2mqtt integration has fixed this, but i'm not very happy to rebuild my entire Zigbee network. Feel free to try opening a pull request, this stuff is new to me, I don't think it should be that hard to do 😏

Well I've been looking for a reason to get into Python... So I guess this is it. Will look into creating a PR.

kosmiq added a commit to kosmiq/zha-device-handlers that referenced this issue Dec 13, 2023
Based on the code supplied by krlssn in comment zigpy#1889 (comment)
@TheJulianJES TheJulianJES reopened this Jan 19, 2024
@TheJulianJES TheJulianJES removed the stale Issue is inactivate and might get closed soon label Jan 19, 2024
@TheJulianJES
Copy link
Collaborator

This PR should mostly be ready now:

From what I've read in this thread, it seems like we can't use the formatter attributes for this, as that also affects the total summation delivered.
The solution was to simply divide the instantaneous demand for this plug and I'm fine with that.
I've made some small changes to the PR above, so it would be nice if someone who has the plugs can test it.
The code below is basically almost exactly the code from the PR, but it can be installed as a custom quirk in a single file.

Please confirm if the following code works when it's installed as a custom quirk.
(You need to copy it and save it as a schneider_outlet.py file for example, move it to your configured custom zha quirks directory, and then restart HA.)

"""Schneider Electric (Wiser) Outlet Quirks."""
from zigpy.profiles import zgp, 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):
    """Custom Metering cluster to fix instantaneous demand value multiplied by 1000."""

    def _update_attribute(self, attrid, value):
        if attrid == self.AttributeDefs.instantaneous_demand.id:
            value = value / 1000
        super()._update_attribute(attrid, value)


class SocketOutlet(CustomDevice):
    """Schneider Electric Socket outlet WDE002182, WDE002172."""

    signature = {
        MODELS_INFO: [
            ("Schneider Electric", "SOCKET/OUTLET/1"),
            ("Schneider Electric", "SOCKET/OUTLET/2"),
        ],
        ENDPOINTS: {
            # <SimpleDescriptor endpoint=1 profile=260 device_type=9
            # device_version=0
            # input_clusters=[0, 3, 4, 5, 6, 1794, 1800, 2820, 2821, 64516] output_clusters=[25]>
            6: {
                PROFILE_ID: zha.PROFILE_ID,
                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: zgp.PROFILE_ID,
                DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [
                    GreenPowerProxy.cluster_id,
                ],
            },
        },
    }

    replacement = {
        ENDPOINTS: {
            6: {
                PROFILE_ID: zha.PROFILE_ID,
                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: zgp.PROFILE_ID,
                DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [
                    GreenPowerProxy.cluster_id,
                ],
            },
        },
    }

@krlssn
Copy link

krlssn commented Jan 21, 2024

@TheJulianJES Loaded with your code, seems to work for me. Shows correct values. I guess you haven't changed anything with summation delivered, that one takes some time (hours) to see if it's correct. Hope this can lead to get the solution into ZHA so I won't have to use the local quirk, would be nice to be able to update HA without de- and reactivate the quirk every time! I have another filename but inside my file is the code in your message above (#1889 (comment)).
image

@TheJulianJES
Copy link
Collaborator

Thanks for testing!

@krlssn
Copy link

krlssn commented Mar 18, 2024

Update/permanent fix: Updated to HA Core 2024.3.1 today and now everything seems to work without enabling my local/custom quirk again after this update. Instantaneous demand now gives me correct values "out of the box". Thank you @TheJulianJES and everybody else in this thread that helped to fix this issue!
.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom quirk available A custom quirk is available to solve the issue, but it's not merged in the repo yet
Projects
None yet
Development

No branches or pull requests

6 participants