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

[BUG] An other TS011F with the wrong amps offset

Open kodiakastu opened this issue 2 years ago • 4 comments

Bug description

Hi! I have a circuit breaker that reports it's an other TS011F.

Reading a lot, I've seen many reports of those devices that are being off by a factor of a 1000. I know that power should be good and voltage seems okay. I do not thrust the total tho. I feel, it should at least be divided by 10.

Steps to reproduce

Simply add the device like any other.

Expected behavior

Current seems to be reported in mA from the device.

Summation delivered should be divided by 10

Screenshots/Video

Screenshots/Video

image

Device signature

Device 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.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4098, 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": {
    "1": {
      "profile_id": "0x0104",
      "device_type": "0x010a",
      "input_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0402",
        "0x0702",
        "0x0b04",
        "0xe000",
        "0xe001"
      ],
      "output_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3000_6l1pjfqe",
  "model": "TS011F",
  "class": "zigpy.device.Device"
}

Diagnostic information

Diagnostic information
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.11.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "America/Toronto",
    "os_name": "Linux",
    "os_version": "6.1.59",
    "supervisor": "2023.11.6",
    "host_os": "Home Assistant OS 11.1",
    "docker_version": "24.0.6",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "nodered": {
      "version": "1.1.2",
      "requirements": []
    },
    "hacs": {
      "version": "1.28.0",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "after_dependencies": [
      "onboarding",
      "usb"
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "config_flow": true,
    "dependencies": [
      "file_upload"
    ],
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp",
      "universal_silabs_flasher"
    ],
    "requirements": [
      "bellows==0.36.8",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.106",
      "zigpy-deconz==0.21.1",
      "zigpy==0.59.0",
      "zigpy-xbee==0.19.0",
      "zigpy-zigate==0.11.0",
      "zigpy-znp==0.11.6",
      "universal-silabs-flasher==0.0.14",
      "pyserial-asyncio-fast==0.11"
    ],
    "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"
        ]
      }
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      },
      {
        "type": "_zigstar_gw._tcp.local.",
        "name": "*zigstar*"
      },
      {
        "type": "_uzg-01._tcp.local.",
        "name": "uzg-01*"
      },
      {
        "type": "_slzb-06._tcp.local.",
        "name": "slzb-06*"
      }
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 60538,
    "manufacturer": "_TZ3000_6l1pjfqe",
    "model": "TS011F",
    "name": "_TZ3000_6l1pjfqe TS011F",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "quirk_id": null,
    "manufacturer_code": 4098,
    "power_source": "Mains",
    "lqi": 255,
    "rssi": -67,
    "last_seen": "2023-11-29T21:47:13",
    "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.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4098, 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": {
        "1": {
          "profile_id": "0x0104",
          "device_type": "0x010a",
          "input_clusters": [
            "0x0000",
            "0x0003",
            "0x0004",
            "0x0005",
            "0x0006",
            "0x0402",
            "0x0702",
            "0x0b04",
            "0xe000",
            "0xe001"
          ],
          "output_clusters": [
            "0x000a",
            "0x0019"
          ]
        },
        "242": {
          "profile_id": "0xa1e0",
          "device_type": "0x0061",
          "input_clusters": [],
          "output_clusters": [
            "0x0021"
          ]
        }
      },
      "manufacturer": "_TZ3000_6l1pjfqe",
      "model": "TS011F"
    },
    "active_coordinator": false,
    "entities": [
      {
        "entity_id": "button.tob9z_63m_identify",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tob9z_63m_current",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tob9z_63m_voltage",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tz3000_6l1pjfqe_ts011f_rssi",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tz3000_6l1pjfqe_ts011f_lqi",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tob9z_63m_power",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "sensor.tob9z_63m_summation_delivered",
        "name": "_TZ3000_6l1pjfqe TS011F"
      },
      {
        "entity_id": "switch.tob9z_63m_switch",
        "name": "_TZ3000_6l1pjfqe TS011F"
      }
    ],
    "neighbors": [],
    "routes": [],
    "endpoint_names": [
      {
        "name": "ON_OFF_PLUG_IN_UNIT"
      },
      {
        "name": "PROXY_BASIC"
      }
    ],
    "user_given_name": "TOB9Z-63M",
    "device_reg_id": "39159eb5dc258756b71f770c00e67fc5",
    "area_id": "spare",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "ON_OFF_PLUG_IN_UNIT",
          "id": 266
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "_TZ3000_6l1pjfqe"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "TS011F"
              }
            },
            "unsupported_attributes": {
              "0x4000": {
                "attribute_name": "sw_build_id"
              },
              "0x000e": {
                "attribute_name": "product_label"
              },
              "0x0010": {
                "attribute_name": "location_desc"
              }
            }
          },
          "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": {
              "0x4002": {
                "attribute_name": "off_wait_time",
                "value": 0
              },
              "0x0000": {
                "attribute_name": "on_off",
                "value": 1
              },
              "0x4001": {
                "attribute_name": "on_time",
                "value": 0
              }
            },
            "unsupported_attributes": {
              "0x4003": {
                "attribute_name": "start_up_on_off"
              }
            }
          },
          "0x0702": {
            "endpoint_attribute": "smartenergy_metering",
            "attributes": {
              "0x0000": {
                "attribute_name": "current_summ_delivered",
                "value": 23
              },
              "0x0306": {
                "attribute_name": "metering_device_type",
                "value": 0
              },
              "0x0200": {
                "attribute_name": "status",
                "value": 0
              },
              "0x0303": {
                "attribute_name": "summation_formatting",
                "value": 0
              },
              "0x0300": {
                "attribute_name": "unit_of_measure",
                "value": 0
              }
            },
            "unsupported_attributes": {
              "0x0400": {
                "attribute_name": "instantaneous_demand"
              },
              "0x0100": {
                "attribute_name": "current_tier1_summ_delivered"
              },
              "0x0102": {
                "attribute_name": "current_tier2_summ_delivered"
              },
              "0x0302": {
                "attribute_name": "divisor"
              },
              "0x0104": {
                "attribute_name": "current_tier3_summ_delivered"
              },
              "0x0304": {
                "attribute_name": "demand_formatting"
              },
              "0x0106": {
                "attribute_name": "current_tier4_summ_delivered"
              },
              "0x0301": {
                "attribute_name": "multiplier"
              },
              "0x0108": {
                "attribute_name": "current_tier5_summ_delivered"
              },
              "0x010a": {
                "attribute_name": "current_tier6_summ_delivered"
              }
            }
          },
          "0x0b04": {
            "endpoint_attribute": "electrical_measurement",
            "attributes": {
              "0x050b": {
                "attribute_name": "active_power",
                "value": 450
              },
              "0x0508": {
                "attribute_name": "rms_current",
                "value": 3831
              },
              "0x0505": {
                "attribute_name": "rms_voltage",
                "value": 117
              }
            },
            "unsupported_attributes": {
              "0x0300": {
                "attribute_name": "ac_frequency"
              },
              "0x0601": {
                "attribute_name": "ac_voltage_divisor"
              },
              "0x0302": {
                "attribute_name": "ac_frequency_max"
              },
              "0x0603": {
                "attribute_name": "ac_current_divisor"
              },
              "0x050a": {
                "attribute_name": "rms_current_max"
              },
              "0x0602": {
                "attribute_name": "ac_current_multiplier"
              },
              "0x0605": {
                "attribute_name": "ac_power_divisor"
              },
              "0x0507": {
                "attribute_name": "rms_voltage_max"
              },
              "0x0604": {
                "attribute_name": "ac_power_multiplier"
              },
              "0x0600": {
                "attribute_name": "ac_voltage_multiplier"
              },
              "0x0000": {
                "attribute_name": "measurement_type"
              },
              "0x050d": {
                "attribute_name": "active_power_max"
              },
              "0x0510": {
                "attribute_name": "power_factor"
              },
              "0x050f": {
                "attribute_name": "apparent_power"
              },
              "0x0802": {
                "attribute_name": "ac_current_overload"
              },
              "0x0801": {
                "attribute_name": "ac_voltage_overload"
              },
              "0x0403": {
                "attribute_name": "power_divisor"
              },
              "0x0400": {
                "attribute_name": "ac_frequency_multiplier"
              },
              "0x0401": {
                "attribute_name": "ac_frequency_divisor"
              },
              "0x0402": {
                "attribute_name": "power_multiplier"
              },
              "0x0304": {
                "attribute_name": "total_active_power"
              },
              "0x0800": {
                "attribute_name": "ac_alarms_mask"
              }
            }
          },
          "0x0402": {
            "endpoint_attribute": "temperature",
            "attributes": {
              "0xfffd": {
                "attribute_name": "cluster_revision",
                "value": 1
              },
              "0x0000": {
                "attribute_name": "measured_value",
                "value": 0
              }
            },
            "unsupported_attributes": {
              "0x0001": {
                "attribute_name": "min_measured_value"
              },
              "0x0002": {
                "attribute_name": "max_measured_value"
              },
              "0x0003": {
                "attribute_name": "tolerance"
              },
              "0xfffe": {
                "attribute_name": "reporting_status"
              }
            }
          },
          "0xe000": {
            "endpoint_attribute": null,
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xe001": {
            "endpoint_attribute": null,
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x000a": {
            "endpoint_attribute": "time",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      },
      "242": {
        "device_type": {
          "name": "PROXY_BASIC",
          "id": 97
        },
        "profile_id": 41440,
        "in_clusters": {},
        "out_clusters": {
          "0x0021": {
            "endpoint_attribute": "green_power",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}

Logs

Logs
[Paste the logs here]

Additional information

This is a circuit breaker bought on Aliexpress from Tomzn TOB9Z-63M

kodiakastu avatar Nov 30 '23 03:11 kodiakastu

Additional infos 2: I do not really understand at an 100% how it work, but reading from the debug file, the device doesn't seem to provide the offsets. Trying to set them in the GUI will always revert to none when trying to write then read the values at 0x0602 and 0x0603.

kodiakastu avatar Nov 30 '23 03:11 kodiakastu

Yeah, a quirk needs to be added. It should be relatively simple, as there are a bunch of quirks for these plugs already. I hope I can take a look at this soon.

I'll send you a custom quirk to test then.

TheJulianJES avatar Nov 30 '23 03:11 TheJulianJES

I believe that can be added to the Plug_CB_Metering quirk: https://github.com/zigpy/zha-device-handlers/blob/aeca76da0ea81ecba5b17e0f7314620cd686faae/zhaquirks/tuya/ts011f_plug.py#L1245-L1253

javicalle avatar Nov 30 '23 20:11 javicalle

I encountered the same issue with Tomzn TOB9Z-63M and solved it by adding custom quirk, but as fas as I could tell specifying

MODELS_INFO: [("_TZ3000_qeuvnohg", "TS011F")],

is not a good idea. If I understand correctly if zigpy encounteres several classes with same MODEL specified in a signature than it iteratates over them and select one that is most suitable for Descriptors provided by device. So in my case speciyfing MODEL_INFO actually hurts, since Plug_CB_Metering specifies my device signature exactly, but filters class because MODEL_INFO (_TZ3000_qeuvnohg) is different. Try deleting MODEL_INFO altogether

ogvalt avatar May 17 '24 09:05 ogvalt