dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 498 forks source link

[Request Device Support] Samsung SmartPlug 2019 Model ID: 7A-PL-Z-J3 #2121

Closed smartypantsuk closed 4 years ago

smartypantsuk commented 4 years ago

I have just purchased a 2019 Smartthings Smart Plug which supports power monitoring. Deconz treats it as an on/off plug and works fine in that respect, but I'd love to get power monitoring working. These plugs are a reasonable price without breaking the bank so would be brilliant if the energy side worked.

I have a feeling that these plugs could be manufacturered by Innr, but I aren't certain. The manufacturer code is 0x1168, which according to this page is an Innr reference, Innr2 to be precise Perhaps Innr use the '2' designation for products they manufacturer but release under a difference brand?..

They are almost identical to the Innr plug with size, shape and power switch location, but there are some tiny differences regarding depth and bevel at the front lip. The build quality is identical to the Innr device.

I have attached the important stuff, If i've missed anything please advise.

Model ID: 7A-PL-Z-J3

Thank you

node node-info basic-cluster simple-metering-cluster electrical-measurment-cluster

and some debug info, in which I turned the smart plug on and off:

debug.txt

and perhaps there is some information from this smartthings github page which mentions the same model/make of ZB-ONOFFPlug-D0005 and LDS

SmartThingsPublic

djashjones commented 4 years ago

This is getting to be a right ball ache. 😆

SwoopX commented 4 years ago

I'd say it will work with zigbee2mqtt, but you probably need to create a corresponding device for it. In my opinion, zigbee2mqtt uses a better approach to deal with zigbee traffic and devices. Hope that would be followed in deconz API version 2 whenever it will come.

smartypantsuk commented 4 years ago

Okay well I have a sniffer on it's way so I'll see if I can get that working and capture some traffic. I suspect that may take some time to get working.

SwoopX commented 4 years ago

Folks, I know this is getting boring but another idea worth a try since I just had it with a different device. Start sensor search in Phoscon and then in deconz GUI, read the simple descriptors and see if anything is added. I proposed the earlier, but unfortunately without the active sensor search. Sorry for that.

Okay well I have a sniffer on it's way so I'll see if I can get that working and capture some traffic. I suspect that may take some time to get working.

Have you guys ordered the CC debugger along? Otherwise, you cannot flash the firmware.

smartypantsuk commented 4 years ago

Have you guys ordered the CC debugger

I ordered a cheapo sniffer but didn't realise I may need to flash it with a debugger. Nonetheless, I've made some progress with it.

I'm using a combination of Killerbee and Wireshark on Ubuntu. I've managed to get the packets decrypted so next step is tell me what you need. I'm going to do this tomorrow and shutdown all my zigbee stuff leaving just the Gateway and plug running to minimise traffic.. I know I can use filters but I prefer to limit data this way.

So what do you need?

SwoopX commented 4 years ago

Gee, people are getting creative. I like that :wink:

Set the wireshark filter to "zbee_nwk" for a start. I'd say, do a sniff of about 5 mins, including the join. Oh, and don't forget to check the option I posted earlier. Good luck!

smartypantsuk commented 4 years ago

SwoopX I've captured some junk. I started by turning off everything on the network (I think)! Then I removed the smart plug from Phoscon. Then started a capture and started a join light process. After the smart plug was added, I ran a manual force read of simple descriptors but forgot to click the add sensors button. I then re-ran the force read of simple descriptors but this time I clicked the add sensors button first.

HOWEVER! I'M AN IDIOT or just tired.

After doing all this I realised that I wasn't running deCONZ on Ubuntu with your plugin... BIG DOH! I was running it on my Windows system, well it is 00:43am. So I'll do it again tomorrow.

In the mean time, I guess the results would still be useful to see, so how shall I post them? Shall I upload a wireshark capture file, or some exported file?

I did notice the following while browing the packet capture. When the simple descriptor request was made, the Application Device value read as 'unknown', not sure if that is relevant. image

djashjones commented 4 years ago

I cant get the debugger to recognise the sniffer. Something is faulty!!!

smartypantsuk commented 4 years ago

Does the sniffer have a green light on it? Wait, which one did you buy?

djashjones commented 4 years ago

Free light? The pcb says CC25xx usb dongle rev 1.0

All drivers ok, debugger has latest firmware I think and the sniffer shows one green led

smartypantsuk commented 4 years ago

Free light? The pcb says CC25xx usb dongle rev 1.0

All drivers ok, debugger has latest firmware I think and the sniffer shows one green led

Oops I meant green. Mine has a solid green light and is the CC2531 variant, so sounds like yours is the CC2530/31 too. Maybe it doesn't need a firmware flashing, possibly already has something usable on it? Have you tried sniffing with it?

djashjones commented 4 years ago

no, not yet. Just purchased another sniffing tool just in case thou.

smartypantsuk commented 4 years ago

Ooh aren't you a keen sniffer 🤭 and yes, I'm childish.

djashjones commented 4 years ago

Your gonna have to start calling me charlie with all this sniffing I'm trying to do.

Don't think its going to work as its listed in device manager under "Cebal controlled devices" and not under com ports as expected!

smartypantsuk commented 4 years ago

Gee, people are getting creative. I like that 😉

Set the wireshark filter to "zbee_nwk" for a start. I'd say, do a sniff of about 5 mins, including the join. Oh, and don't forget to check the option I posted earlier. Good luck!

So I captured some traffic today SwoopX, it went something like this;

Removed smartplug from Phoscon and factory reset smartplug. Started packet capture. Started the 'add light' process in via Phoscon for 3 minutes. Put smartplug into join mode (factory reset again). Watched the live capture and pretended as though I knew what I was looking at 🤭 Waited for the 3 minutes to end, actually I left it nearly 4 minutes. Then started the 'add sensor' process via Phoscon, again for 3 minutes. I then forced a 'simple descriptor' re-read in deCONZ. After that, and iirc in the following order, I forced another 'simple descriptor' re-read followed by: ----- 'Power Descriptor' re-read ----- 'Node Descriptor' re-read ----- 'IEEE Address' re-read ----- 'NWK Adresss' re-read

I then, I don't know why, un-plugged the smartplug, moved it elsewhere in the room and put a different load on it then turned it back on..... and I think that was it.

There seemed to be quite a lot of crap being produced for quite a while, not sure which direction it was going in or what it was doing but it seemed to happen without me initiating anything and just ran and ran. See below -> image

So how do you want the capture data sending?

smartypantsuk commented 4 years ago

Your gonna have to start calling me charlie with all this sniffing I'm trying to do.

Don't think its going to work as its listed in device manager under "Cebal controlled devices" and not under com ports as expected!

image like mine?

I've moved to capturing Windows using Texas Instruments Wireshark Converter, which basically is a small program that intiatiates a connection (pipe) to Wireshark. You want instructions?

djashjones commented 4 years ago

yes and yes, lol

smartypantsuk commented 4 years ago

Ok charlie... give me 5

smartypantsuk commented 4 years ago

Install the converter TiWsPc.zip

Download and install wireshark, make sure pcap is checked on the install options screens, but you can omit all the extra stuff it asks you about like USBpcap etc. https://www.wireshark.org/#download

You need to create a desktop shortcut that runs Wireshark with some extra parameters. Make a Wireshark desktop shortcut, click on it's properties and make sure your target box looks like this (assuming Wireshark is installed in the same location on your machine).

"C:\Program Files\Wireshark\Wireshark.exe" -i\.\pipe\tiwspc_data -k

Now, once you've done all that, make sure your sniffer is plugged in and open up TI Wireshark Packet Converter (TiWsPc.exe), then click on Device Configuration button. You'll see the following: image Assuming the converter detects your sniffer, put a check/tick in the 'use' box on the left side and you need to select the channel number your network is using, then you can start the converter running by selecting 'Start' and you can close that screen with 'Done'.

At this stage, the two tabs on the main converter window should be like this: image Now, leave that converter running and click on the Wireshark shortcut we created earlier. It may take a few moments to open wireshark up, but once done, assuming everythings working, you should see some traffic appearing in the window and the converter will have changed to this: image

Finally put 'zbee_nwk' without quotes into the filter box at the top and apply it, this will just show you the Zigbee data we're interested in.

djashjones commented 4 years ago

ha ha. Just plugged it into my HASS system and its not detected. I'll play with wireshark at some point. 😄

smartypantsuk commented 4 years ago

ha ha. Just plugged it into my HASS system and its not detected. I'll play with wireshark at some point. 😄

After all my hard work, slaving for hours on this very detailed tutorial, you son of a charlie smoking goat... 😉

Yeah no worries, It's there if you need it. 👍

djashjones commented 4 years ago

I will use it, honest gov. Need to play with wireshark as it's a useful bit of kit!

Got a headache from all this, so I'm off down the pub.

Energy monitoring has turned into an obsession with me now. I pretty much have most the plugs available in the UK. Here's another one, lve found.

https://www.peclights.com/product/aurora-aone-au-a1zbpia-13a-smart-plug-in-adaptor

smartypantsuk commented 4 years ago

I will use it, honest gov. Need to play with wireshark as it's a useful bit of kit!

Got a headache from all this, so I'm off down the pub.

Energy monitoring has turned into an obsession with me now. I pretty much have most the plugs available in the UK. Here's another one, lve found.

Yeah it's hurting my brain a bit now... I'd prefer a Z-Wave plug as most of my automation is on that protocol, plus it's on a far better frequency. But I aren't impressed with any of the Z-Wave smart plugs so here we are. I don't want the modules that install at the back of sockets, although in some ways it would be advantageous.

https://www.peclights.com/product/aurora-aone-au-a1zbpia-13a-smart-plug-in-adaptor

Thanks an interesting find. I'm not familiar with the brand but the 0.1% accuracy is a bold statement for this price... I'd be surprised if it's anywhere near that. Still, getting support is the key, and of course something that won't burn your house down.

SwoopX commented 4 years ago

When the simple descriptor request was made, the Application Device value read as 'unknown', not sure if that is relevant.

@smartypantsuk That's just the deviceID for smart plugs. I never understood why wireshark's cluster library seems to be incomplete.

I'm using a combination of Killerbee and Wireshark on Ubuntu.

The guy with the hacker toolz ;)

In terms of what's interesting. Do you see some binding or attribute reporting requests/responses? What attributes are so frequently queried? Is it "on/off" or also some metering?

smartypantsuk commented 4 years ago

I'm using a combination of Killerbee and Wireshark on Ubuntu.

The guy with the hacker toolz ;)

😂

What attributes are so frequently queried? Is it "on/off" or also some metering?

It seems to be on/off:

0xc09c 0x0000 ZigBee HA 113 ZCL: Read Attributes Response, Seq: 148 On/off Control: On (0x01)

then..

0x0000 0xc09c ZigBee HA 110 ZCL: Read Attributes, Seq: 149 Attribute: OnOff (0x0000)

I'll post the whole thing next, if you want the wireshark file to inspect I'll post it up on request.

capture-collapsed-no_packets.txt

The attributes that get passed on read requests are the same things that deCONZ logs, I don't see anything that is being missed by deCONZ, but I don't know exactly what to look for.

smartypantsuk commented 4 years ago

121 Node Descriptor Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Node Descriptor Response (Cluster ID: 0x8002)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 30
ZigBee Device Profile, Node Descriptor Response, Rev: 22, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 87
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Node Descriptor
        .... .... .... .001 = Type: 1 (Router)
        .... .... .... 0... = Complex Descriptor: False
        .... .... ...0 .... = User Descriptor: False
        .... 0... .... .... = 868MHz BPSK Band: False
        ..0. .... .... .... = 902MHz BPSK Band: False
        .1.. .... .... .... = 2.4GHz OQPSK Band: True
        0... .... .... .... = EU Sub-GHz FSK Band: False
        Capability Information: 0x8e
            .... ...0 = Alternate Coordinator: False
            .... ..1. = Full-Function Device: True
            .... .1.. = AC Power: True
            .... 1... = Rx On When Idle: True
            .0.. .... = Security Capability: False
            1... .... = Allocate Short Address: True
        Manufacturer Code: 0x1168
        Max Buffer Size: 82
        Max Incoming Transfer Size: 82
        Server Flags: 0x2c00
            .... .... .... ...0 = Primary Trust Center: False
            .... .... .... ..0. = Backup Trust Center: False
            .... .... .... .0.. = Primary Binding Table Cache: False
            .... .... .... 0... = Backup Binding Table Cache: False
            .... .... ...0 .... = Primary Discovery Cache: False
            .... .... ..0. .... = Backup Discovery Cache: False
            .... .... .0.. .... = Network Manager: False
            0010 110. .... .... = Stack Compliance Revision: 22
        Max Outgoing Transfer Size: 82
        Descriptor Capability Field: 0x00
            .... ...0 = Extended Active Endpoint List Available: False
            .... ..0. = Extended Simple Descriptor List Available: False

Active Endpoint Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Active Endpoint Response (Cluster ID: 0x8005)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 31
ZigBee Device Profile, Active Endpoint Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 88
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Endpoint Count: 2
    Active Endpoint List
        Endpoint: 1
        Endpoint: 242

Simple Descriptor Response to Active Endpoint:1

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Simple Descriptor Response (Cluster ID: 0x8004)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 32
ZigBee Device Profile, Simple Descriptor Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 89
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Simple Descriptor Length: 30
    Simple Descriptor
        Endpoint: 1
        Profile: Home Automation (0x0104)
        Application Device: Unknown (0x0051)
        Application Version: 0x0001
        Input Cluster Count: 8
        Input Cluster List
            Input Cluster: Basic (0x0000)
            Input Cluster: Identify (0x0003)
            Input Cluster: Groups (0x0004)
            Input Cluster: Scenes (0x0005)
            Input Cluster: On/Off (0x0006)
            Input Cluster: Simple Metering (0x0702)
            Input Cluster: Electrical Measurement (0x0b04)
            Input Cluster: Manufacturer Specific (0xfc82)
        Output Cluster Count: 3
        Output Cluster List
            Output Cluster: Identify (0x0003)
            Output Cluster: Time (0x000a)
            Output Cluster: OTA Upgrade (0x0019)

Simple Descriptor Response to Active Endpoint:242

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Simple Descriptor Response (Cluster ID: 0x8004)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 33
ZigBee Device Profile, Simple Descriptor Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 90
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Simple Descriptor Length: 10
    Simple Descriptor
        Endpoint: 242
        Profile: Green Power (0xa1e0)
        Application Device: 0x0061
        Application Version: 0x0000
        Input Cluster Count: 0
        Output Cluster Count: 1
        Output Cluster List
            Output Cluster: Green Power (0x0021)

Read Attribute Response

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Basic (0x0000)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 34
ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 93
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 93
    Command: Read Attributes Response (0x01)
    Status Record, String: ZB-ONOFFPlug-D0005
        Attribute: Model Identifier (0x0005)
        Status: Success (0x00)
        Data Type: Character String (0x42)
        String: ZB-ONOFFPlug-D0005

187 Node Descriptor Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Node Descriptor Response (Cluster ID: 0x8002)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 209
ZigBee Device Profile, Node Descriptor Response, Nwk Addr: 0x0000, Status: Success
    Sequence Number: 1
    Status: Success (0)
    Nwk Addr of Interest: 0x0000
    Node Descriptor
        .... .... .... .000 = Type: 0 (Coordinator)
        .... .... .... 0... = Complex Descriptor: False
        .... .... ...1 .... = User Descriptor: True
        .... 0... .... .... = 868MHz BPSK Band: False
        ..0. .... .... .... = 902MHz BPSK Band: False
        .1.. .... .... .... = 2.4GHz OQPSK Band: True
        0... .... .... .... = EU Sub-GHz FSK Band: False
        Capability Information: 0x0f
            .... ...1 = Alternate Coordinator: True
            .... ..1. = Full-Function Device: True
            .... .1.. = AC Power: True
            .... 1... = Rx On When Idle: True
            .0.. .... = Security Capability: False
            0... .... = Allocate Short Address: False
        Manufacturer Code: 0x1135
        Max Buffer Size: 89
        Max Incoming Transfer Size: 61
        Server Flags: 0x0040
            .... .... .... ...0 = Primary Trust Center: False
            .... .... .... ..0. = Backup Trust Center: False
            .... .... .... .0.. = Primary Binding Table Cache: False
            .... .... .... 0... = Backup Binding Table Cache: False
            .... .... ...0 .... = Primary Discovery Cache: False
            .... .... ..0. .... = Backup Discovery Cache: False
            .... .... .1.. .... = Network Manager: True
            0000 000. .... .... = Stack Compliance Revision: 0
        Max Outgoing Transfer Size: 61
        Descriptor Capability Field: 0x00
            .... ...0 = Extended Active Endpoint List Available: False
            .... ..0. = Extended Simple Descriptor List Available: False

1252 Simple Descriptor Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Simple Descriptor Response (Cluster ID: 0x8004)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 166
ZigBee Device Profile, Simple Descriptor Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 119
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Simple Descriptor Length: 30
    Simple Descriptor
        Endpoint: 1
        Profile: Home Automation (0x0104)
        Application Device: Unknown (0x0051)
        Application Version: 0x0001
        Input Cluster Count: 8
        Input Cluster List
            Input Cluster: Basic (0x0000)
            Input Cluster: Identify (0x0003)
            Input Cluster: Groups (0x0004)
            Input Cluster: Scenes (0x0005)
            Input Cluster: On/Off (0x0006)
            Input Cluster: Simple Metering (0x0702)
            Input Cluster: Electrical Measurement (0x0b04)
            Input Cluster: Manufacturer Specific (0xfc82)
        Output Cluster Count: 3
        Output Cluster List
            Output Cluster: Identify (0x0003)
            Output Cluster: Time (0x000a)
            Output Cluster: OTA Upgrade (0x0019)

1254 Simple Descriptor Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Simple Descriptor Response (Cluster ID: 0x8004)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 167
ZigBee Device Profile, Simple Descriptor Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 120
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Simple Descriptor Length: 10
    Simple Descriptor
        Endpoint: 242
        Profile: Green Power (0xa1e0)
        Application Device: 0x0061
        Application Version: 0x0000
        Input Cluster Count: 0
        Output Cluster Count: 1
        Output Cluster List
            Output Cluster: Green Power (0x0021)

1265 Power Descriptor Response

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Power Descriptor Response (Cluster ID: 0x8003)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 168
ZigBee Device Profile, Power Descriptor Response, Nwk Addr: 0xc09c, Status: Success
    Sequence Number: 122
    Status: Success (0)
    Nwk Addr of Interest: 0xc09c
    Power Descriptor: 0xc110
        .... .... .... 0000 = Mode: Receiver Always On (0)
        .... .... ...1 .... = Available AC Power: True
        .... .... ..0. .... = Available Rechargeable Battery: False
        .... .... .0.. .... = Available Disposeable Battery: False
        .... ...1 .... .... = Using AC Power: True
        .... ..0. .... .... = Using Rechargeable Battery: False
        .... .0.. .... .... = Using Disposeable Battery: False
        1100 .... .... .... = Level: Unknown (12)

1366 Read Attributes Response: Current Summation Delivered

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Simple Metering (0x0702)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 180
ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 179
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 179
    Command: Read Attributes Response (0x01)
    Status Record, Uint: 0
        Attribute: Current Summation Delivered (0x0000)
        Status: Success (0x00)
        Data Type: 48-Bit Unsigned Integer (0x25)
        Uint48: 0 (0x0000000000000000)

1379 Read Reporting Configuration Reponse

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Simple Metering (0x0702)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 181
ZigBee Cluster Library Frame, Command: Read Reporting Configuration Response, Seq: 185
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 185
    Command: Read Reporting Configuration Response (0x09)
    Reporting Configuration Record
        Status: Not Found (0x8b)
        Direction: Reported (0x00)
        Attribute: Current Summation Delivered (0x0000)
smartypantsuk commented 4 years ago

@SwoopX, I'm continually updating the useful stuff to the post above, but while looking through the packets I noticed that in the first Node Descriptor Response the Manufacturer Device code is read as 0x1168, but in the next one I came to, about 5 seconds later the Manufacturer Code read 0x1135...

Is this right?

The Manufacturer Code is definately 0x1168 as I've found this under 'Match Descriptor': Manufacturer Code: Leedarson Lighting Co., Ltd. (0x1168)

Further, If you examine above the Read Attribute Response for Summation it gives a successfull read, however, following that packet is a request for 'Read Reporting Configuration' in which the response above (1379) gives a 'Status: Not Found (0x8b)'?

I think that's about as much interesting stuff I can find. There were a few more 'Read Atttribute' packets but one was just a read of the Software Build and the other was the Device Identifier or something that's been repeated above.

SwoopX commented 4 years ago

That's cool, thx. I'll check it out. Btw, the 2nd node descriptor response is from conbee II, that's fine.

SwoopX commented 4 years ago

Ok, would like to try something different. Can you download the cpp file from https://github.com/SwoopX/st_playground, replace the file in my previously downloaded repo and recompile? Please make sure to launch deconz with the debug output activated. Don't forget to delete and re-pair the plug.

You may see "Bypassed critical handleIndicationSearchSensors check" in the debug output then and eventually lots of additional stuff. It's more like a dirty hack (if it plays well) but should give the expected result

smartypantsuk commented 4 years ago

Ok, would like to try something different. Can you download the cpp file from https://github.com/SwoopX/st_playground, replace the file in my previously downloaded repo and recompile? Please make sure to launch deconz with the debug output activated. Don't forget to delete and re-pair the plug.

You may see "Bypassed critical handleIndicationSearchSensors check" in the debug output then and eventually lots of additional stuff. It's more like a dirty hack (if it plays well) but should give the expected result

Okay doing it now.

smartypantsuk commented 4 years ago

I've come back from the pub Lucky you 😄

I can't answer your question. All I know is if you want out doing round here....

SwoopX the man, SwoopX the man, Ya know that SwoopX the man!

smartypantsuk commented 4 years ago

Ok, would like to try something different. Can you download the cpp file from https://github.com/SwoopX/st_playground, replace the file in my previously downloaded repo and recompile? Please make sure to launch deconz with the debug output activated. Don't forget to delete and re-pair the plug.

You may see "Bypassed critical handleIndicationSearchSensors check" in the debug output then and eventually lots of additional stuff. It's more like a dirty hack (if it plays well) but should give the expected result

Well aren't you a smart little Bunny 😄... guess who's got sensors for consumption !

SwoopX commented 4 years ago

Oh wicked... :punch:

smartypantsuk commented 4 years ago

sam_join.txt

djashjones commented 4 years ago

They think it's all over!!! it is now!!!!

We got they world in motion...

SwoopX commented 4 years ago

Sweet. That's what I hoped to see. Stuff from the API comming in alright as well?

EDIT Seems to look half ok. A part from the power sensor is missing. Copy&Paste?

smartypantsuk commented 4 years ago

api Okay thats a screenshot of the API sensors, obviously they aren't appearing in Phoscon, or at least I didn't expect them to as I thought that was a seperate bit of work by... er.. manup?

But yeah, I think it's not fully operational yet. We're getting current consumption through 1070w in the test. But I'm not seeing current Summation or voltage. But I can't see voltage in deCONZ either, at least the value isn't being read. It must know the voltage obviously otherwise it wouldn't be able to calculate the consumption.

smartypantsuk commented 4 years ago

Sweet. That's what I hoped to see. Stuff from the API comming in alright as well?

EDIT Seems to look half ok. A part from the power sensor is missing. Copy&Paste?

The sensor I've missed off is just the daylight sensor. It was nice to see bindings in the packets this time, never seen any bindings until now. Progress at last!

SwoopX commented 4 years ago

But yeah, I think it's not fully operational yet. We're getting current consumption through 1070w in the test. But I'm not seeing current Summation or voltage.

Well, power and consumption is what I personally care about. The values look even reasonable, so most likely no changes on the digits required.

Could you paste new screenshots with a load applied from the 2 measurement clusters, having read the attributes again? Feels strange that there's no voltage or current...

You may also check with wireshark if any attribute reporting responses come in. I don't expect any, as the attributes seem to be unreportable.

smartypantsuk commented 4 years ago

But yeah, I think it's not fully operational yet. We're getting current consumption through 1070w in the test. But I'm not seeing current Summation or voltage.

Well, power and consumption is what I personally care about. The values look even reasonable, so most likely no changes on the digits required.

Could you paste new screenshots with a load applied from the 2 measurement clusters, having read the attributes again? Feels strange that there's no voltage or current...

You may also check with wireshark if any attribute reporting responses come in. I don't expect any, as the attributes seem to be unreportable.

Okay will do. I've noticed that, if you remember, the read config button never worked on anything regarding the plug in deCONZ, untill now.

smartypantsuk commented 4 years ago

Here's the screens from deCONZ with a load applied and the attributes read. I've had to split them in two because my Ubuntu display is not letting me select a very good resolution at the moment.I've tried with 1kW+ on the plug and can see no difference in values to having just 20watt on it. The first screen I had my partners hair curlers on it, 350w ish. Rest of screens I just had a laptop.

Screenshot from 2020-01-04 20-52-00

Screenshot from 2020-01-04 21-12-28 Screenshot from 2020-01-04 21-12-35

Screenshot from 2020-01-04 21-13-20 Screenshot from 2020-01-04 21-13-40

smartypantsuk commented 4 years ago

Just looking through the latest capture, will keep updating this comment till end of capture file.

606 Bind Request: Simple Metering

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Bind Request (Cluster ID: 0x0021)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 52
ZigBee Device Profile, Bind Request, Simple Metering (Cluster ID: 0x0702) Src: SiliconL_ff:fe:6e:2f:7d, Dst: Dresden-_ff:ff:04:fc:3b
    Sequence Number: 185
    Source: SiliconL_ff:fe:6e:2f:7d (cc:cc:cc:ff:fe:6e:2f:7d)
    Source Endpoint: 1
    Cluster: 0x0702 (Simple Metering)
    Address Mode: Unicast (3)
    Destination: Dresden-_ff:ff:04:fc:3b (00:21:2e:ff:ff:04:fc:3b)
    Destination Endpoint: 1

618 Bind Request: Electrical Measurement

ZigBee Application Support Layer Data, Dst Endpt: 0, Src Endpt: 0
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 0
    Bind Request (Cluster ID: 0x0021)
    Profile: ZigBee Device Profile (0x0000)
    Source Endpoint: 0
    Counter: 53
ZigBee Device Profile, Bind Request, Electrical Measurement (Cluster ID: 0x0b04) Src: SiliconL_ff:fe:6e:2f:7d, Dst: Dresden-_ff:ff:04:fc:3b
    Sequence Number: 193
    Source: SiliconL_ff:fe:6e:2f:7d (cc:cc:cc:ff:fe:6e:2f:7d)
    Source Endpoint: 1
    Cluster: 0x0b04 (Electrical Measurement)
    Address Mode: Unicast (3)
    Destination: Dresden-_ff:ff:04:fc:3b (00:21:2e:ff:ff:04:fc:3b)
    Destination Endpoint: 1

662 Configure Reporting Response: Simple Metering

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Simple Metering (0x0702)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 160
ZigBee Cluster Library Frame, Command: Configure Reporting Response, Seq: 5
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 5
    Command: Configure Reporting Response (0x07)
    Attribute Status Record
        Status: Unsupported Attribute (0x86)
        Direction: Reported (0x00)
        Attribute: Instantaneous Demand (0x0400)

677 Configure Reporting Response: Electrical Measurement

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Electrical Measurement (0x0b04)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 162
ZigBee Cluster Library Frame, Command: Configure Reporting Response, Seq: 7
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 7
    Command: Configure Reporting Response (0x07)
    Status: Success (0x00)

644 Configure Reporting: Simple Metering

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Simple Metering (0x0702)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 55
ZigBee Cluster Library Frame, Command: Configure Reporting, Seq: 5
    Frame Control Field: Profile-wide (0x10)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 0... = Direction: Client to Server
        ...1 .... = Disable Default Response: True
    Sequence Number: 5
    Command: Configure Reporting (0x06)
    Reporting Configuration Record, Uint: 1
        Direction: Reported (0x00)
        Attribute: Current Summation Delivered (0x0000)
        Data Type: 48-Bit Unsigned Integer (0x25)
        Uint48: 1 (0x0000000000000001)
    Minimum Interval: 1
    Maximum Interval: 300
    Reporting Configuration Record, Int24: 1
        Direction: Reported (0x00)
        Attribute: Instantaneous Demand (0x0400)
        Data Type: 24-Bit Signed Integer (0x2a)
        Int24: 1
    Minimum Interval: 1
    Maximum Interval: 300

658 Configure Reporting: Electrical Measurment

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Electrical Measurement (0x0b04)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 57
ZigBee Cluster Library Frame, Command: Configure Reporting, Seq: 7
    Frame Control Field: Profile-wide (0x10)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 0... = Direction: Client to Server
        ...1 .... = Disable Default Response: True
    Sequence Number: 7
    Command: Configure Reporting (0x06)
    Reporting Configuration Record, Int16: 1
        Direction: Reported (0x00)
        Attribute: Active Power (0x050b)
        Data Type: 16-Bit Signed Integer (0x29)
        Int16: 1
    Minimum Interval: 1
    Maximum Interval: 300
    Reporting Configuration Record, Uint16: 1
        Direction: Reported (0x00)
        Attribute: RMS Voltage (0x0505)
        Data Type: 16-Bit Unsigned Integer (0x21)
        Uint16: 1 (0x0001)
    Minimum Interval: 1
    Maximum Interval: 300
    Reporting Configuration Record, Uint16: 1
        Direction: Reported (0x00)
        Attribute: RMS Current (0x0508)
        Data Type: 16-Bit Unsigned Integer (0x21)
        Uint16: 1 (0x0001)
    Minimum Interval: 1
    Maximum Interval: 300

2483 Read Attributes Response: Level Control -> Current Level

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 11 Frame Control Field: Data (0x00) .... ..00 = Frame Type: Data (0x0) .... 00.. = Delivery Mode: Unicast (0x0) ..0. .... = Security: False .0.. .... = Acknowledgement Request: False 0... .... = Extended Header: False Destination Endpoint: 1 Cluster: Level Control (0x0008) Profile: Home Automation (0x0104) Source Endpoint: 11 Counter: 109 ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 101 Frame Control Field: Profile-wide (0x18) .... ..00 = Frame Type: Profile-wide (0x0) .... .0.. = Manufacturer Specific: False .... 1... = Direction: Server to Client ...1 .... = Disable Default Response: True Sequence Number: 101 Command: Read Attributes Response (0x01) Status Record Attribute: Current Level (0x0000) Status: Success (0x00) Data Type: 8-Bit Unsigned Integer (0x20) Current Level: 254

1856 Read Attributes Response: Electrical Measurement -> Active Power

ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x40)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .1.. .... = Acknowledgement Request: True
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: Electrical Measurement (0x0b04)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 191
ZigBee Cluster Library Frame, Command: Read Attributes Response, Seq: 207
    Frame Control Field: Profile-wide (0x08)
        .... ..00 = Frame Type: Profile-wide (0x0)
        .... .0.. = Manufacturer Specific: False
        .... 1... = Direction: Server to Client
        ...0 .... = Disable Default Response: False
    Sequence Number: 207
    Command: Read Attributes Response (0x01)
    Status Record, Int16: 1070
        Attribute: Active Power (0x050b)
        Status: Success (0x00)
        Data Type: 16-Bit Signed Integer (0x29)
        Int16: 1070
smartypantsuk commented 4 years ago

@SwoopX Check out 2483 Read Attributes Response: Level Control -> Current Level above. Not sure if it's relevant but that Level Control (0x0008) cluster with a Current Level (0x0000) attribute doesn't appear in deCONZ, yet it does in the traffic capture and it's making regular appearances, along with on/off and colour temperature read attribute responses.

djashjones commented 4 years ago

Just as a test. I tried it in ZHA in home assistant and it works kinda. updating power takes about 10 secs and using a 100w light bulb, it shows 10W. There is loads of options which mean nothing to me and do not seem adjustable!

smartypantsuk commented 4 years ago

Just as a test. I tried it in ZHA in home assistant and it works kinda. updating power takes about 10 secs and using a 100w light bulb, it shows 10W. There is loads of options which mean nothing to me and do not seem adjustable!

I've no idea about home assistant, never used it. Interestingly the power consumption seems reasonably accurate and within spec on my tests. While I can't find the exact plug specification, I understand the accuracy to be -/+ 2W under 100w or -/+ 2% over 100w. So clearly your reading should be between 98w - 102w not allowing for the actual load of the bulb. So 10w is well out of the ballpark, clearly a problem with the coding somewhere.

SwoopX commented 4 years ago

@smartypantsuk thanks for throwing over all that input. Some further thoughts:

smartypantsuk commented 4 years ago

@smartypantsuk thanks for throwing over all that input. Some further thoughts:

  • Instantaneous Demand: I'd expect this attribute reporting configuration to have failed, as the cluster is not supported or available. We leave it at that since I'd prefer not to fiddle with it and it doesn't cause any harm.

Okay no worries.

  • Level Control: It might be that the device supports dimming. You may want to try it out. If I understand it correctly, you should see a key "bri" as part of the light node in the API (#972). We can remove it, if it is pretty much useless.

Okay will look for that when next I get 5 minutes.

  • Current and Voltage: It feels kinda strange that the attributes should be available but do not have any reasonable data in there. Maybe that's a bug in the firmware. I recall some funny stuff going on with my ubisys S2 before the update. You may want to read the attribute values individually while sniffing. Double click on it (like for the attribute reporting values) and then click read.

If it was a bug in the firmware, would it not cause the same problem when connected to the Smartthings Hub? I can't check this as I don't have one.

Is it possible that the API is interpretting the data incorrectly in those current/voltage attributes?

I'll try again reading the attributes singularly.

SwoopX commented 4 years ago

If it was a bug in the firmware, would it not cause the same problem when connected to the Smartthings Hub? I can't check this as I don't have one.

That's the downside in Zigbee-Land. Very few manufacturers provide updates publicly for download. So without the corresponding gateway (or partner GWs), no cookies...

Is it possible that the API is interpretting the data incorrectly in those current/voltage attributes?

Don't thinks so.. Sniffer data should let us see clearer. If there would be a misinterpretation in data, it's in deconz core component. As the data types are settled in ZCL-Library, I'd rather put my bet on the firmware.

ebaauw commented 4 years ago

Is it possible that the API is interpretting the data incorrectly in those current/voltage attributes?

Don't thinks so.. Sniffer data should let us see clearer. If there would be a misinterpretation in data, it's in deconz core component. As the data types are settled in ZCL-Library, I'd rather put my bet on the firmware.

The attributes and data types are defined in the ZCL, but the units of the reported values differ per device. This is what the various Multiplier and Divisor attributes are for, but not all devices support these and (therefore?) the REST API plugin doesn't use these. That's why the devices are whitelisted when handling the 0x0702 and 0x0B04 attributes, hardcoding the rescaling per device type. See https://github.com/dresden-elektronik/deconz-rest-plugin/blob/bb47cdbc19c257e3000fdb8475aa456830e6df94/de_web_plugin.cpp#L6769 and https://github.com/dresden-elektronik/deconz-rest-plugin/blob/bb47cdbc19c257e3000fdb8475aa456830e6df94/de_web_plugin.cpp#L6847

Afaik, the deCONZ core doesn't interpret any data, other than hex/dec formatting in the GUI, as specified in general.xml.

Of course, it's perfectly possible for a device to report incorrect values: ubisys used to have a firmware bug (see https://github.com/dresden-elektronik/deconz-rest-plugin/issues/712#issuecomment-465744443), and the OSRAM plugs don't report anything useful.

SwoopX commented 4 years ago

The attributes and data types are defined in the ZCL, but the units of the reported values differ per device. This is what the various Multiplier and Divisor attributes are for, but not all devices support these and (therefore?) the REST API plugin doesn't use these. That's why the devices are whitelisted when handling the 0x0702 and 0x0B04 attributes, hardcoding the rescaling per device type.

That's what I meant, better expressed ;)

Of course, it's perfectly possible for a device to report incorrect values: ubisys used to have a firmware bug (see #712 (comment)), and the OSRAM plugs don't report anything useful.

Indeed, Chances are 50/50.