zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
719 stars 664 forks source link

[Device Support Request] - TS011F by _TZ3000_ew3ldmgx #1045

Closed miit86 closed 2 years ago

miit86 commented 2 years ago

Hi All,

Bought a Smartplug from ALI TS011F by _TZ3000_ew3ldmgx

HA added 1 switch and 3 sensors:

switch.tz3000_ew3ldmgx_ts011f_bb1466fe_on_off "SWITCH" sensor.tz3000_ew3ldmgx_ts011f_bb1466fe_electrical_measurement "192 W" sensor.tz3000_ew3ldmgx_ts011f_bb1466fe_smartenergy_metering "UNKNOWN"

Describe the solution you'd like The "smartenergy_metering" is not working. It should show the KwH On other forums there talking it could be a TS0121 thats advertises wrong. Also Zigbee2MQTT supports this Plug with metering.

Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.

{
  "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=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": 260,
      "device_type": "0x010a",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0702",
        "0x0b04",
        "0xe000",
        "0xe001"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3000_ew3ldmgx",
  "model": "TS011F",
  "class": "zigpy.device.Device"
}

LOG

[0x0000:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [60, <Bool.false: 0>]
New device 0x0432 (84:fd:27:ff:fe:68:de:64) joined the network
[0x0432] Scheduling initialization
Tries remaining: 3
[0x0432] Requesting 'Node Descriptor'
Tries remaining: 2
[0x0432] Extending timeout for 0xce request
Device 0x0432 (84:fd:27:ff:fe:68:de:64) joined the network
[0x0432] Scheduling initialization
[0x0432] Canceling old initialize call
Tries remaining: 3
[0x0432] Requesting 'Node Descriptor'
Tries remaining: 2
[0x0432] Extending timeout for 0xd0 request
Device 0x0432 (84:fd:27:ff:fe:68:de:64) joined the network
[0x0432] Scheduling initialization
[0x0432] Canceling old initialize call
Received frame on uninitialized device <Device model=None manuf=None nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=False> from ep 0 to ep 0, cluster 19: b"\x822\x04d\xdeh\xfe\xff'\xfd\x84\x8e"
[0x0432:zdo] ZDO request ZDOCmd.Device_annce: [0x0432, 84:fd:27:ff:fe:68:de:64, 142]
Tries remaining: 3
[0x0432] Requesting 'Node Descriptor'
Tries remaining: 2
[0x0432] Extending timeout for 0xd2 request
Received frame on uninitialized device <Device model=None manuf=None nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=False> from ep 0 to ep 0, cluster 32770: b'\xd2\x002\x04\x01@\x8e\x02\x10RR\x00\x00,R\x00\x00'
[0x0432] Got 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=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)
[0x0432] Discovering endpoints
Tries remaining: 3
Received frame on uninitialized device <Device model=None manuf=None nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=False> from ep 0 to ep 0, cluster 32773: b'\xd4\x002\x04\x02\x01\xf2'
[0x0432] Discovered endpoints: [1, 242]
[0x0432] Initializing endpoints [<Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>, <Endpoint id=242 in=[] out=[] status=<Status.NEW: 0>>]
[0x0432:1] Discovering endpoint information
Tries remaining: 3
Received frame on uninitialized device <Device model=None manuf=None nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=False> from ep 0 to ep 0, cluster 32772: b'\xd6\x002\x04\x1e\x01\x04\x01\n\x01\x01\t\x00\x00\x03\x00\x04\x00\x05\x00\x06\x00\x02\x07\x04\x0b\x00\xe0\x01\xe0\x02\x19\x00\n\x00'
[0x0432:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=266, device_version=1, input_clusters=[0, 3, 4, 5, 6, 1794, 2820, 57344, 57345], output_clusters=[25, 10])
Unknown cluster 57344
Unknown cluster 57345
[0x0432:242] Discovering endpoint information
Tries remaining: 3
Received frame on uninitialized device <Device model=None manuf=None nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=False> from ep 0 to ep 0, cluster 32772: b'\xd8\x002\x04\n\xf2\xe0\xa1a\x00\x00\x00\x01!\x00'
[0x0432:242] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33])
[0x0432:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=218 command_id=Command.Read_Attributes_rsp>
[0x0432] Read model 'TS011F' and manufacturer '_TZ3000_ew3ldmgx' from <Endpoint id=1 in=[basic:0x0000, identify:0x0003, groups:0x0004, scenes:0x0005, on_off:0x0006, smartenergy_metering:0x0702, electrical_measurement:0x0B04, None:0xE000, None:0xE001] out=[ota:0x0019, time:0x000A] status=<Status.ZDO_INIT: 1>>
[0x0432] Discovered basic device information for <Device model='TS011F' manuf='_TZ3000_ew3ldmgx' nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=True>
Device is initialized <Device model='TS011F' manuf='_TZ3000_ew3ldmgx' nwk=0x0432 ieee=84:fd:27:ff:fe:68:de:64 is_initialized=True>
Checking quirks for _TZ3000_ew3ldmgx TS011F (84:fd:27:ff:fe:68:de:64)
Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'>
Fail because endpoint list mismatch: {232, 230} {1, 242}
Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'>
Fail because endpoint list mismatch: {232, 230} {1, 242}
Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
Fail because endpoint list mismatch: {1} {1, 242}
Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'>
Fail because endpoint list mismatch: {1} {1, 242}
Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
Fail because endpoint list mismatch: {1} {1, 242}
Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'>
Fail because endpoint list mismatch: {11, 13} {1, 242}
Considering <class 'bellows.zigbee.application.EZSPCoordinator'>
Fail because endpoint list mismatch: {1} {1, 242}
device - 0x0432:84:fd:27:ff:fe:68:de:64 entering async_device_initialized - is_new_join: True
device - 0x0432:84:fd:27:ff:fe:68:de:64 has joined the ZHA zigbee network
[0x0432](TS011F): started configuration
[0x0432:ZDO](TS011F): 'async_configure' stage succeeded
[0x0432:1:0x0000]: finished channel configuration
Error handling '_save_attribute' event with (84:fd:27:ff:fe:68:de:64, 1, 0, 4, '_TZ3000_ew3ldmgx') params: FOREIGN KEY constraint failed
Error handling '_save_attribute' event with (84:fd:27:ff:fe:68:de:64, 1, 0, 5, 'TS011F') params: FOREIGN KEY constraint failed
[0x0432:1:0x0006]: bound 'on_off' cluster: Status.SUCCESS
[0x0432:1:0x0702]: bound 'smartenergy_metering' cluster: Status.SUCCESS
[0x0432:1:0x0b04]: bound 'electrical_measurement' cluster: Status.SUCCESS
[0x0432:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=226 command_id=Command.Configure_Reporting_rsp>
[0x0432:1:0x0006]: reporting 'on_off' attr on 'on_off' cluster: 0/900/1: Result: '[[ConfigureReportingResponseRecord(status=0)]]'
[0x0432:1:0x0006]: finished channel configuration
[0x0432:1:0x0019]: finished channel configuration
[0x0432:1:0x0702] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=228 command_id=Command.Configure_Reporting_rsp>
[0x0432:1:0x0702]: reporting 'instantaneous_demand' attr on 'smartenergy_metering' cluster: 30/900/1: Result: '[[ConfigureReportingResponseRecord(status=134, direction=0, attrid=1024)]]'
[0x0432:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=230 command_id=Command.Configure_Reporting_rsp>
[0x0432:zdo] ZDO request ZDOCmd.NWK_addr_req: [60:a4:23:ff:fe:08:e2:f4, 0, 0]
[0x0432:1:0x0b04]: reporting 'active_power' attr on 'electrical_measurement' cluster: 30/900/1: Result: '[[ConfigureReportingResponseRecord(status=0)]]'
[0x0432:1:0x0b04]: finished channel configuration
[0x0432:1:0x0702] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=232 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0702]: finished channel configuration
[0x0432:1:0x0006]: 'async_configure' stage succeeded
[0x0432:1:0x0000]: 'async_configure' stage succeeded
[0x0432:1:0x0702]: 'async_configure' stage succeeded
[0x0432:1:0x0b04]: 'async_configure' stage succeeded
[0x0432:1:0x0019]: 'async_configure' stage succeeded
[0x0432](TS011F): completed configuration
[0x0432](TS011F): stored in registry: ZhaDeviceEntry(name='_TZ3000_ew3ldmgx TS011F', ieee='84:fd:27:ff:fe:68:de:64', last_seen=1632421430.6810045)
[0x0432:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=9 command_id=Command.Report_Attributes>
[0x0432:1:0x0b04] ZCL request 0x000a: [[Attribute(attrid=1291, value=<TypeValue type=int16s, value=0>)]]
[0x0432:1:0x0b04] Attribute report received: active_power=0
[0x0432:1:0x0003] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=235 command_id=Command.Default_Response>
[0x0432:1:0x0003]: executed 'trigger_effect' command with args: '(2, 0)' kwargs: '{}' result: [64, <Status.UNSUP_CLUSTER_COMMAND: 129>]
[0x0432](TS011F): started initialization
[0x0432:ZDO](TS011F): 'async_initialize' stage succeeded
[0x0432:1:0x0006]: initializing channel: from_cache: False
[0x0432:1:0x0000]: initializing channel: from_cache: False
[0x0432:1:0x0000]: finished channel configuration
[0x0432:1:0x0702]: initializing channel: from_cache: False
[0x0432:1:0x0b04]: initializing channel: from_cache: False
[0x0432:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=237 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0006]: finished channel configuration
[0x0432:1:0x0019]: initializing channel: from_cache: False
[0x0432:1:0x0019]: finished channel configuration
[0x0432:1:0x0702] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=239 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=241 command_id=Command.Read_Attributes_rsp>
[0x0432:zdo] ZDO request ZDOCmd.Node_Desc_req: [0x0000]
[0x0432:zdo] Unsupported ZDO request:ZDOCmd.Node_Desc_req
[0x0432:1:0x0702] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=243 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0702]: finished channel configuration
[0x0432:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=245 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0b04]: finished channel configuration
[0x0432:1:0x0006]: 'async_initialize' stage succeeded
[0x0432:1:0x0000]: 'async_initialize' stage succeeded
[0x0432:1:0x0702]: 'async_initialize' stage succeeded
[0x0432:1:0x0b04]: 'async_initialize' stage succeeded
[0x0432:1:0x0019]: 'async_initialize' stage succeeded
[0x0432](TS011F): power source: Mains
[0x0432](TS011F): completed initialization
[0x0432:1:0x0006]: attempting to update onoff state - from cache: False
[0x0432:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=247 command_id=Command.Read_Attributes_rsp>
[0x278f:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=9 command_id=Command.Report_Attributes>
[0x278f:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=0>)]]
[0x278f:1:0x0400] Attribute report received: measured_value=0
[0x2F84:1:0x0b04]: async_update
[0xD44E:1:0x0b04]: async_update
[0xB4C2:1:0x0b04]: async_update
[0x0432:1:0x0b04]: async_update
[0x2f84:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=249 command_id=Command.Read_Attributes_rsp>
[0xd44e:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=251 command_id=Command.Read_Attributes_rsp>
[0xb4c2:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=253 command_id=Command.Read_Attributes_rsp>
[0x0432:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=255 command_id=Command.Read_Attributes_rsp>
[0xd44e:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=109 command_id=Command.Report_Attributes>
[0xd44e:1:0x0b04] ZCL request 0x000a: [[Attribute(attrid=1291, value=<TypeValue type=int16s, value=203>)]]
[0xd44e:1:0x0b04] Attribute report received: active_power=203
[0xb4c2:1:0x0b04] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=106 command_id=Command.Report_Attributes>
[0xb4c2:1:0x0b04] ZCL request 0x000a: [[Attribute(attrid=1291, value=<TypeValue type=int16s, value=1689>)]]
[0xb4c2:1:0x0b04] Attribute report received: active_power=1689
MattWestb commented 2 years ago

By the way can you posing the quirk that is working so other user can testing it and getting there devices getting little taste of the power Metering (little high but still working ;-)) ).

MattWestb commented 2 years ago

Adminiuga have doing it for tuya AIR but is using tuya PD and not normal Zigbee clusters like your device but perhaps its one clue how to do it. https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/air/__init__.py I looking little more around for hacks.

MattWestb commented 2 years ago

Bitron/SMaBiT thermostats is "patching" the battery and adding it in one new cluster so i thing its one good example how to do the "new" patched cluster. https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/bitron/thermostat.py. Then its "only" putting in the multiplexer with "normal" way like "new" attribute = old * 100 i think (= not knowing)

MattWestb commented 2 years ago

One more IKEA thing !!

IKEA controllers is reporting battery then full as 100% and Zigbe shall doing it as 200% (very old Zigbee device was having 2 barristers more modern is only using 1) . In this is the 2* being done and also the cluster https://github.com/zigpy/zha-device-handlers/blob/83624ba2dea5bfb8af2c489211e26c877ca01c35/zhaquirks/__init__.py#L172 .

I think its easiest making the same and using the "new" cluster in the replacement but implanting it in tuya __init__.pyor in your quirk if no more devices is needing it.

Its looks very easy and short implanting only changing the name of the cluster and attribute and the multiplier :-)))

MattWestb commented 2 years ago

I have making one PR #1056 that is implanting the power on state in the tuya INIT and also removing it in the plug.py and adding the new on/off cluster in it and renaming plug.py to ts0121_plug.py. #1055 So your quirk can being named ts011f_plug.py and also using the power on state from the INIT.

I think i shall doing the same for TS0101 then i have getting 2 LIDL outdoor plugs but need writing one quirk for it :-(((

miit86 commented 2 years ago

Hi Matt,

Using the power on state from the INIT is cool. But plug.py only has lines for power on state. is it absolute then? I will name my quirk ts011f_plug.py

I'm not used to code, so it's difficult to understand how to build it.

If I add this below I will get a new output. also see replacements But I have no clue on how to change the numbers from metering and change it before HA gets the numbers.

class TS011FMetering(Metering):
    """Reported Value from current_summ_delivered dived by 100. """

    current_summ_delivered = 0x00
    current_summ_delivered = current_summ_delivered / 100 

Replacements:

                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOffRestorePowerCluster,
                    TS011FMetering,
                    ElectricalMeasurement.cluster_id,
                    0xE000,  # Unknown
                    0xE001,  # Unknown
MattWestb commented 2 years ago

I think using this from the quirk root INIT:

class DoublingPowerConfigurationCluster(CustomCluster, PowerConfiguration):
    """PowerConfiguration cluster implementation.
    This implementation doubles battery pct remaining for non standard devices
    that don't follow the reporting spec.
    """

    cluster_id = PowerConfiguration.cluster_id
    BATTERY_PERCENTAGE_REMAINING = 0x0021

    def _update_attribute(self, attrid, value):
        if attrid == self.BATTERY_PERCENTAGE_REMAINING:
            value = value * 2
        super()._update_attribute(attrid, value)

and changing the cluster name PowerConfiguration to wot you will changing. Then is the attribute you like changing BATTERY_PERCENTAGE_REMAINING = 0x0021 to your attibute.

And the recalculating is made with value = value * 2 so making your / 100 instead.

Edit: the class name need being changed 2. Edit 2: updating the attribute name in if attrid == self.BATTERY_PERCENTAGE_REMAINING:.

miit86 commented 2 years ago

Something like this:

class DividingMeteringCluster(CustomCluster, Metering):
    """Metering cluster implementation.
    This implementation divides the KwH for tuya devices
    that don't follow the reporting spec.
    """

    cluster_id = Metering.cluster_id
    current_summ_delivered = 0x0000

    def _update_attribute(self, attrid, value):
        if attrid == self.current_summ_delivered:
            value = value / 100
        super()._update_attribute(attrid, value)

how to implement this in my quirk?

MattWestb commented 2 years ago

I think its looks OK but im no code worrier :-((

If its only used for your device in then in your quirk and if its being used for more devices in the tuya INIT or if global in the quirk root INIT = in your device quirk.

I dont knowing if its need more imports but try putting it in.

Do it like the power on state state class is made (same line spaces before and after). And run black after before you is putting in your system then if its bad formatted it can being that HA is not starting

miit86 commented 2 years ago

Hi,

WauW, That worked :P ..! Very Nice :)

MattWestb commented 2 years ago

So you is having your server only using 0.19 kWh now ?

And the plug have power state off after power loss ;-))))

miit86 commented 2 years ago

Still have to test a hour. but the Graph went from 1080 to 10.80. All the graphs of my plugs. Yes: Power State is working.

Just one more 2 go: :)

I also have readings for: rms_current (id: 0x0508) 1195 should be 1.195 see below rms_voltage (id: 0x0505) 224 Correct active_power (id: 0x050b) 194 Correct

Z2M endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {acCurrentDivisor: 1000, acCurrentMultiplier: 1});

But only the sensor for Active Power is Created in HA. Is this a problem in HA or ZHA or the quirk?

MattWestb commented 2 years ago

If you can do reading from cluster commands / reading attribute, then the Zigbee part is OK. It can that (Z)HA is not making sensor for all cluster you is having (like the old problem that is fixes in the beta now).

For the wrong current do one more attribute patching class and fixing it like you was doing with the / 100 and it shall working.

Also look in the HA log with debug enabled and you can see then the device is reporting and how its doing it.

miit86 commented 2 years ago

Yes,

It's Oke now. from 10.8 KwH to 11.0 KwH in an hour.

How can is share this quirk?

MattWestb commented 2 years ago

The radio is only sending receiving wot devices is sending and the radio lib plus Zigpy is only piping it to ZHA that only understanding "pure Zigbee" so its work OK with devices that is making all OK. If the device is doing somthing bad then the quirk can correcting it and ZHA is getting "pure Zigbee" and all is working OK.

HA is only getting the last summered consumption and is adding it to the graph with little logic for if have missing some reports and if the device have resettled the counters so it shall starting from zero.

You can doing one PR for adding the code and if you is getting problem i can trying helping you with fixing the tests that normally making one PITA. If you is having the quirk file made you can starting with "adding file" in the tuya folder and making one new file (with the name of your quirk file) and adding the code in it and then making one pull request after saving it to the dev branch.

Or I can do it but if i do changes i need help from you for testing that all changes is working OK or the devs is not accepting the PR if its not tested in real.

MattWestb commented 2 years ago

The PR looks good but the devs must approving the tests and hope its working OK. Your quirk is using only the TS011F so its no need writing all devices that shall working but its OK. Its good putting one link to the devise request issue and is doing it with "fixing" before its automatic closing the request.

miit86 commented 2 years ago

like this:

https://github.com/zigpy/zha-device-handlers/pull/1057

MattWestb commented 2 years ago

Yes but in the PR so the devs can see wot is made and how its working :-))

MattWestb commented 2 years ago

The checks was all OK only that David need approving one more time for rerunning it after the last extra "Zero" that was added ;-)

If you have getting one PR merged the system is making the checks without the devs need making anything and its easier.

Great work done !!

miit86 commented 2 years ago

Hi, I saw the Mistake, corrected it. I learned a lot these past days. Thanks for you Help. :)

When will it be available for everyone.?

MattWestb commented 2 years ago

If David is approving it and making one new ZHS_quirk for the HA beta it can going in HA 2021.10 but i think its too late for that.

Hi have proving the TS0121 name changes and using MODEL so that is in the dev branch now.

miit86 commented 2 years ago

@Hedda

https://github.com/home-assistant/core/pull/56909 It's a merge for Current en Voltage from Zigbee devices.

I use HA Beta. And HA doesn't make sensors for Current en Voltage from my tuya device I can see the values in Clusters.

I don't see anything for Tuya devices. but maybe their created from general code. I try to understand the process and code. maybe something with discovery.

Hedda commented 2 years ago

@Hedda

home-assistant/core#56909 It's a merge for Current en Voltage from Zigbee devices.

I use HA Beta. And HA doesn't make sensors for Current en Voltage from my tuya device I can see the values in Clusters.

As wrote in https://github.com/zigpy/zha-device-handlers/issues/910

If I understand the last comment from Adminiuga in PR for ZHA in Home Assistant core home-assistant/core#56909 the ZHA integration component in Home Assistant could now be extended with other attributes on the electrical measurement cluster but have not yet so those you either have to code and submit that as a PR to Home Assistant core yourself or post a feature request on the Home Assistant community forum. Only once those are attributes are support by the ZHA component in Home Assistant core can you make quirks for them if available from the device and needed.

"Support for other attributes could be extended later, as I couldn't find too many devices other than Sinopé RM3250ZB Electrical Load Controller – 50A – Zigbee https://www.amazon.com/dp/B07CGJ6XH2/ reporting anything interesting on the electrical measurement cluster."

miit86 commented 2 years ago

Merged into DEV #1057 @MattWestb thanks for the help..!

Hedda commented 2 years ago

@mitaka Just to clarify, did the quirk for TS011F in PR #1057 resolve the missing sensors or attributes?

mitaka commented 2 years ago

Hello,

Currently using zha-quirks version 0.0.62 and homeassistant version 2021.10.5. The smartenergy_metering sensor is still showing unavailable but there is a new entity smartenergy_metering_summation_delivered which is showing something like the total used energy.

miit86 commented 2 years ago

@mitaka

The support for TS011F is still in DEV.

miit86 commented 2 years ago

@mitaka Just to clarify, did the quirk for TS011F in PR #1057 resolve the missing sensors or attributes?

@Hedda Not missing sensors. But value corrections and support for power state.

PlusPlus-ua commented 2 years ago

Hi,

I've just updated to Home Assistant Core version core-2021.11.0b0 and zha-device-handlers version 0.0.63. Mine version of the device is _TZ3000_cphmq0q7.

I can see rms_voltage and rms_current in Home Assistant interface. But reported values are wrong. Voltage is constantly 0.2V when real voltage is around 220V. Current with 6-8W load shows 62A.

By the way, is someone managed to change value of an attribute power_on_state (id: 0x8002) of TuyaZBOnOffRestorePowerCluster via Home Assistant interface?

Hedda commented 2 years ago

@PlusPlus-ua there is no new zha-quirks release as of yet yet that contain https://github.com/zigpy/zha-device-handlers/pull/1107 (also see see https://github.com/zigpy/zha-device-handlers/issues/1108 for TS011F RMS current)

Arno500 commented 2 years ago

@PlusPlus-ua there is no new zha-quirks release as of yet yet that contain #1107 (also see see #1108 for TS011F RMS current)

It seems that this specific model that I have (_TZ3000_cphmq0q7) still doesn't report correct voltage (as described by @PlusPlus-ua , it's 100 times lower than what it should be and current is 1000 times higher than what it is).

I guess we'll need to split the quirks between the various models :/

Referring to this one: #1107 where the author did remove the previous voltage correction to add the current one, with a screenshot attesting the values are now right for them.