Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.04k stars 1.67k forks source link

Unsupported device: Securifi Peanut Smart Plug #809

Closed roger- closed 5 years ago

roger- commented 5 years ago

I'm trying to get the Securifi Peanut Smart Plug working, primarily to act as a router to extend the range of my current setup, but zigbee2mqtt doesn't support it and reports the modelID as undefined.

Log here.

I'm running the latest version of zigbee2mqtt with this firmware on a CC2531 USB stick. I have 6 Xiaomi sensors that are all connected and working.

A couple questions: 1) how do I add support for a modelID that's unknown? 2) will it still function as a router even though it's unsupported? Is it still paired? 3) is there any reason to update my firmware (my network is small)? I tried the latest one before (after deleting the second to last line in the hex file and flashing with an Arduino) but it didn't work.

Thanks!

EDIT: seems that it's recognized in database.db, see here. And SmartThings support code here.

Koenkk commented 5 years ago
  1. Not, we first need a modelID, can you try repairing while having it close to the coordinator?
  2. Yes, router functionality has nothing to do with zigbee2mqtt, it's part of zigbee itself.
  3. no
roger- commented 5 years ago

Will try, but how do I repair?

Koenkk commented 5 years ago
roger- commented 5 years ago

Thanks, I did that and moved the plug close to the coordinator and re-paired it, but still there's no modelID. Here's the JSON:

{
   "id":2,
   "type":"Router",
   "ieeeAddr":"0x000d6f000a798c7b",
   "nwkAddr":4957,
   "manufId":4098,
   "manufName":"Securifi Ltd.\u0000\u0000\u0000\u0000\u0000\u0000�W\u0001\b�#\u0000 �Y\u0001\b�",
   "powerSource":"Unknown",
   "epList":[
      1
   ],
   "status":"online",
   "joinTime":1546791322,
   "endpoints":{
      "1":{
         "profId":260,
         "epId":1,
         "devId":0,
         "inClusterList":[
            0,
            1,
            3,
            4,
            5,
            6,
            2820,
            2821
         ],
         "outClusterList":[
            0,
            1,
            3,
            4,
            5,
            6,
            25,
            2820,
            2821
         ],
         "clusters":{
            "genBasic":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "zclVersion":1,
                  "stackVersion":0,
                  "manufacturerName":"Securifi Ltd.\u0000\u0000\u0000\u0000\u0000\u0000�W\u0001\b�#\u0000 �Y\u0001\b�",
                  "powerSource":0
               }
            },
            "genPowerCfg":{
               "dir":{
                  "value":3
               },
               "attrs":{

               }
            },
            "genIdentify":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "identifyTime":0
               }
            },
            "genGroups":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "nameSupport":0
               }
            },
            "genScenes":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "count":0,
                  "currentScene":0,
                  "currentGroup":0,
                  "sceneValid":0,
                  "nameSupport":0
               }
            },
            "genOnOff":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "onOff":0
               }
            },
            "genOta":{
               "dir":{
                  "value":2
               },
               "attrs":{

               }
            },
            "haElectricalMeasurement":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "measurementType":8,
                  "acFrequency":0,
                  "acFrequencyMultiplier":1,
                  "acFrequencyDivisor":1,
                  "rmsVoltage":0,
                  "rmsCurrent":0,
                  "activePower":0,
                  "powerFactor":0,
                  "acVoltageMultiplier":180,
                  "acVoltageDivisor":39321,
                  "acCurrentMultiplier":72,
                  "acCurrentDivisor":39321,
                  "acPowerMultiplier":10252,
                  "acPowerDivisor":39321
               }
            },
            "haDiagnostic":{
               "dir":{
                  "value":3
               },
               "attrs":{

               }
            }
         }
      }
   },
   "_id":"vF2UsvBEuvxyRThs"
}

Any ideas? Is it not supposed to be possible that modelID is missing?

Koenkk commented 5 years ago

Could you add the modelId yourself?

{
   "id":2,
   "type":"Router",
   "ieeeAddr":"0x000d6f000a798c7b",
   "nwkAddr":4957,
   "manufId":4098,
   "modelId": "Securifi",
   "manufName":"Securifi Ltd.\u0000\u0000\u0000\u0000\u0000\u0000�W\u0001\b�#\u0000 �Y\u0001\b�",
   "powerSource":"Unknown",
   "epList":[
      1
   ],
   "status":"online",
   "joinTime":1546791322,
   "endpoints":{
      "1":{
         "profId":260,
         "epId":1,
         "devId":0,
         "inClusterList":[
            0,
            1,
            3,
            4,
            5,
            6,
            2820,
            2821
         ],
         "outClusterList":[
            0,
            1,
            3,
            4,
            5,
            6,
            25,
            2820,
            2821
         ],
         "clusters":{
            "genBasic":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "zclVersion":1,
                  "stackVersion":0,
                  "manufacturerName":"Securifi Ltd.\u0000\u0000\u0000\u0000\u0000\u0000�W\u0001\b�#\u0000 �Y\u0001\b�",
                  "powerSource":0
               }
            },
            "genPowerCfg":{
               "dir":{
                  "value":3
               },
               "attrs":{

               }
            },
            "genIdentify":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "identifyTime":0
               }
            },
            "genGroups":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "nameSupport":0
               }
            },
            "genScenes":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "count":0,
                  "currentScene":0,
                  "currentGroup":0,
                  "sceneValid":0,
                  "nameSupport":0
               }
            },
            "genOnOff":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "onOff":0
               }
            },
            "genOta":{
               "dir":{
                  "value":2
               },
               "attrs":{

               }
            },
            "haElectricalMeasurement":{
               "dir":{
                  "value":3
               },
               "attrs":{
                  "measurementType":8,
                  "acFrequency":0,
                  "acFrequencyMultiplier":1,
                  "acFrequencyDivisor":1,
                  "rmsVoltage":0,
                  "rmsCurrent":0,
                  "activePower":0,
                  "powerFactor":0,
                  "acVoltageMultiplier":180,
                  "acVoltageDivisor":39321,
                  "acCurrentMultiplier":72,
                  "acCurrentDivisor":39321,
                  "acPowerMultiplier":10252,
                  "acPowerDivisor":39321
               }
            },
            "haDiagnostic":{
               "dir":{
                  "value":3
               },
               "attrs":{

               }
            }
         }
      }
   },
   "_id":"vF2UsvBEuvxyRThs"
}
roger- commented 5 years ago

To the database.db file? I tried adding a modelId to the three lines the device showed up in but it ignored them and created three new ones.

roger- commented 5 years ago

Finally got the modelID recognized! I had to delete all the entries from database.db and configuration.json, re-pair and then add the modelId to database.db.

Any hints on modifying the js file to control the switch and read the power readings?

Also the plug doesn't seem to be routing as other devices are still out of range (even after restarting the coordinator).

Koenkk commented 5 years ago

Please change the modelId to PP-WHT-US.

Add the following to devices.js

{
        zigbeeModel: ['PP-WHT-US'],
        model: 'PP-WHT-US',
        vendor: 'Securifi',
        description: 'Peanut smart plug',
        supports: 'on/off, power measurement',
        fromZigbee: [fz.ignore_electrical_change, fz.generic_state, fz.ignore_onoff_change],
        toZigbee: [tz.on_off],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 1);
            const onOff = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 1000, repChange: 0};
            const activePower = {
                direction: 0, attrId: 1291, dataType: 41, minRepIntval: 1, maxRepIntval: 300, repChange: 1,
            };

            const rmsCurrent = {
                direction: 0, attrId: 1288, dataType: 33, minRepIntval: 1, maxRepIntval: 300, repChange: 100,
            };

            const rmsVoltage = {
                direction: 0, attrId: 1285, dataType: 33, minRepIntval: 1, maxRepIntval: 300, repChange: 1,
            };

            const electricalCfg = [rmsCurrent, rmsVoltage, activePower];
            const actions = [
                (cb) => device.foundation('genOnOff', 'configReport', [onOff], foundationCfg, cb),
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.foundation('haElectricalMeasurement', 'configReport', electricalCfg, foundationCfg, cb),
                (cb) => device.bind('haElectricalMeasurement', coordinator, cb),
            ];

            execute(device, actions, callback);
        },
    },
roger- commented 5 years ago

Thanks, that does seem to work (I had to restart zigbee2mqtt a couple times though) when I manually press the "on" button:

  zigbee2mqtt:info 1/9/2019, 1:49:59 AM Succesfully configured 0x000d6f000a798c7b 0x000d6f000a798c7b
  zigbee2mqtt:debug 1/9/2019, 1:50:21 AM Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:info 1/9/2019, 1:50:21 AM MQTT publish: topic 'zigbee2mqtt/0x000d6f000a798c7b', payload '{"state":"ON","linkquality":70}'
  zigbee2mqtt:debug 1/9/2019, 1:50:21 AM Received zigbee message of type 'devChange' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:debug 1/9/2019, 1:50:26 AM Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:info 1/9/2019, 1:50:26 AM MQTT publish: topic 'zigbee2mqtt/0x000d6f000a798c7b', payload '{"state":"OFF","linkquality":68}'
  zigbee2mqtt:debug 1/9/2019, 1:50:26 AM Received zigbee message of type 'devChange' with data '{"cid":"genOnOff","data":{"onOff":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)

However I also get this error related to power measurements:

  zigbee2mqtt:debug 1/9/2019, 1:52:09 AM Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}'
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM Please see: https://koenkk.github.io/zigbee2mqtt/how_tos/how_to_support_new_devices.html.
  zigbee2mqtt:debug 1/9/2019, 1:52:09 AM Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsVoltage":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsVoltage":0}}'
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM Please see: https://koenkk.github.io/zigbee2mqtt/how_tos/how_to_support_new_devices.html.
  zigbee2mqtt:debug 1/9/2019, 1:52:09 AM Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"activePower":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"activePower":0}}'
  zigbee2mqtt:warn 1/9/2019, 1:52:09 AM Please see: https://koenkk.github.io/zigbee2mqtt/how_tos/how_to_support_new_devices.html.

I noticed that the converter you posted doesn't use the acPowerMultiplier, etc. fields. Not ssure if that's related the 0 values.

Also nothing shows up in home assistant via MQTT discovery.

Koenkk commented 5 years ago

Home Assistant discovery requires some extra changes, when you connect something to the plug, is the power consumption still 0? ({"activePower":0}})

henworth commented 5 years ago

I've gotten this to work by adding fz.SP120_power to fromZigbee, so the full line looks like:

fromZigbee: [fz.ignore_electrical_change, fz.SP120_power, fz.generic_state, fz.ignore_onoff_change],

Also, adding 'PP-WHT-US': [configurations.switch, configurations.sensor_power], to the mapping variable in lib/extension/homeassistant.js gets it to show up in home assistant.

I can now toggle it on/off from home assistant and toggling the switch on the device updates status in HA as well. However, the power fields in the sensor entity are just 0. Not sure if that means it isn't working or not supported or I don't have enough load on it. Either way, it's essentially working now!

roger- commented 5 years ago

@henworth

Thanks, tried that and now it shows up in HA and the switch works!

@Koenkk

About two and a half minutes after turning on the plug (with a load) I get this message:

Jan 10 01:05:46 raspberrypi npm[32478]:   zigbee2mqtt:debug 1/10/2019, 1:05:46 AM Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0,"rmsVoltage":0,"activePower":0}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
Jan 10 01:05:46 raspberrypi npm[32478]:   zigbee2mqtt:info 1/10/2019, 1:05:46 AM MQTT publish: topic 'zigbee2mqtt/0x000d6f000a798c7b', payload '{"state":"ON","linkquality":89,"power":0,"current":0,"voltage":0}'

So the decoded (?) measurement data is all zeros.

Where does the data get decoded? Is there somewhere I can see the pre-decoded messages to see if it's a decoding error?

Koenkk commented 5 years ago

Can you try with:

{
        zigbeeModel: ['PP-WHT-US'],
        model: 'PP-WHT-US',
        vendor: 'Securifi',
        description: 'Peanut smart plug',
        supports: 'on/off, power measurement',
        fromZigbee: [fz.ignore_electrical_change, fz.generic_state, fz.ignore_onoff_change],
        toZigbee: [tz.on_off],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const device = shepherd.find(ieeeAddr, 1);
            const onOff = {direction: 0, attrId: 0, dataType: 16, minRepIntval: 0, maxRepIntval: 1000, repChange: 0};
            const rmsCurrent = {
                direction: 0, attrId: 1288, dataType: 33, minRepIntval: 0, maxRepIntval: 3, repChange: 0,
            };
            const electricalCfg = [rmsCurrent];
            const actions = [
                (cb) => device.foundation('genOnOff', 'configReport', [onOff], foundationCfg, cb),
                (cb) => device.bind('genOnOff', coordinator, cb),
                (cb) => device.foundation('haElectricalMeasurement', 'configReport', electricalCfg, foundationCfg, cb),
                (cb) => device.bind('haElectricalMeasurement', coordinator, cb),
            ];

            execute(device, actions, callback);
        },
    },
henworth commented 5 years ago

This message comes back:

  zigbee2mqtt:warn 2019-1-10 11:51:26 Please see: https://koenkk.github.io/zigbee2mqtt/how_tos/how_to_support_new_devices.html.
  zigbee2mqtt:warn 2019-1-10 11:51:29 No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}'
  zigbee2mqtt:warn 2019-1-10 11:51:29 Please see: https://koenkk.github.io/zigbee2mqtt/how_tos/how_to_support_new_devices.html.
Koenkk commented 5 years ago

@henworth still no current, did you connect a device which consumes power?

henworth commented 5 years ago

Yep, I have something connected to it.

roger- commented 5 years ago

Where do dataType, attrId, etc. come from?

Koenkk commented 5 years ago

dataType: https://github.com/zigbeer/zcl-id/blob/master/definitions/cluster_defs.json#L1187 attrId: https://github.com/zigbeer/zcl-id/blob/master/definitions/common.json#L219 direction always 0 min/max rep interval: minimum/maximum report interval in seconds repChange: reportable change (0 doesn't require changes) of the value.

roger- commented 5 years ago

Thanks, that helps a lot.

Is there a way to view the raw ZB packets? I’d like to know if the device is outputting zeros (perhaps due to old firmware).

Koenkk commented 5 years ago

Yes: https://github.com/Koenkk/zigbee2mqtt/blob/dev/docs/how_tos/how_to_sniff_zigbee_traffic.md

roger- commented 5 years ago

I enabled all debug messages and get this when I press the "on" button on the plug with no load:

 cc-znp { sof: 254,
  cc-znp   len: 27,
  cc-znp   type: 'AREQ',
  cc-znp   subsys: 'AF',
  cc-znp   cmd: 'incomingMsg',
  cc-znp   payload:
  cc-znp    { groupid: 0,
  cc-znp      clusterid: 6,
  cc-znp      srcaddr: 12149,
  cc-znp      srcendpoint: 1,
  cc-znp      dstendpoint: 1,
  cc-znp      wasbroadcast: 0,
  cc-znp      linkquality: 70,
  cc-znp      securityuse: 0,
  cc-znp      timestamp: 14880654,
  cc-znp      transseqnumber: 0,
  cc-znp      len: 7,
  cc-znp      data: <Buffer 08 3b 0a 00 00 10 01> },
  cc-znp   fcs: 206,
  cc-znp   csum: 206 } +32s
  serialport:main _read reading +43ms
  serialport:bindings read +48ms
  serialport:unixRead Starting read +46ms
  cc-znp:AREQ <-- AF:incomingMsg, { groupid: 0, clusterid: 6, srcaddr: 12149, srcendpoint: 1, dstendpoint: 1, wasbroadcast: 0, linkquality: 70, securityuse: 0, timestamp: 14880654, transseqnumber: 0, len: 7, data: <Buffer 08 3b 0a 00 00 10 01> } +33ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: incomingMsg, msg: [object Object] +9ms
  zigbee-shepherd:msgHdlr IND <-- AF:incomingMsg, transId: 0 +23ms
  serialport:unixRead waiting for readable because of code: EAGAIN +52ms
  serialport:poller Polling for "readable" +107ms
  zigbee-shepherd:af dispatchIncomingMsg(): type: zclIncomingMsg, msg: [object Object] +20ms
  zigbee2mqtt:debug 1/13/2019, 11:16:06 PM Received zigbee message of type 'attReport' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)
  zigbee2mqtt:info 1/13/2019, 11:16:06 PM MQTT publish: topic 'zigbee2mqtt/0x000d6f000a798c7b', payload '{"state":"ON","linkquality":70,"power":0,"current":0,"voltage":0}'
  zigbee2mqtt:debug 1/13/2019, 11:16:06 PM Received zigbee message of type 'devChange' with data '{"cid":"genOnOff","data":{"onOff":1}}' of device 'PP-WHT-US' (0x000d6f000a798c7b)

The 08 3b 0a 00 00 10 01 part seems to be the actual data from the plug (I noticed that the last byte is 01 when on and 00 when off).

With a load connected I get something like 08 4c 0a 00 00 10 01, which varies according to the load apparently. So it does seem that some power data is being transmitted.

I don't know anything about this protocol, so I still have to figure out how to decode it.

roger- commented 5 years ago

Looking a bit more at the data it seems that the power measurements may be missing. Still useful as a switch.

It doesn't seem to be functioning as a router for my Xaomi devices though. Any ideas why?

Koenkk commented 5 years ago

@roger- can you repair the xiaomi device while having it close to the plug. It is know that Xiaomi devices are picky about connecting to routers.

roger- commented 5 years ago

I've tried but it doesn't seem to work. Does the USB coordinator have to be on (it was)? And is there a way to check if anything is connecting to the router?

Koenkk commented 5 years ago

Yes the coordinator has to be one, otherwise a device cannot join the network. You can use the networkmap to check how devices are connected (https://koenkk.github.io/zigbee2mqtt/information/mqtt_topics_and_message_structure.html)

roger- commented 5 years ago

I don't think this ever worked properly as a router and I believe that the firmware needs to be updated for measurements to be supported. Works fine as a switch though.

Can we get the changes above merged as is? What about the missing ID? How can that be dealt with automatically?

Koenkk commented 5 years ago

The missing ID is something that should be documented (like http://www.zigbee2mqtt.io/getting_started/pairing_devices.html#gledopto). Could you create a PR?

cycloneZ commented 5 years ago

@henworth or @roger-

Were you able to determine the cause of the 'No converter available' issue? The Peanut is now listed as a supported device, and though it did pair I ended up having to modify the database to add the model id manually. It now functions but the logs are flooded by the following every few seconds.

zigbee2mqtt:warn 4/13/2019, 10:01:16 AM No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}' zigbee2mqtt:warn 4/13/2019, 10:01:16 AM Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.

roger- commented 5 years ago

For whatever reason yes you still have to add it manually. The measurements don't seem to work unless you upgrade the firmware on your plug, but that requires a specific hub.

cycloneZ commented 5 years ago

I don't have any way to upgrade the firmware on the device. Is that the only way to get all of the warning messages to stop appearing in the logs?

roger- commented 5 years ago

You can probably remove the haElectricalMeasurement stuff from the relevant files (see above).

wixoff commented 5 years ago

The Peanut Plug entry in devices.js might still need some work. (After following the new documentation steps I added above that are now merged, they paired correctly and work partially.)

I have two firmware-upgraded plugs that do not report power measurements into Home Assistant. However, Home Assistant has sensors for them that show only blank values, and the z2m log shows current measurements being received:

pnut2

The switch operates perfectly and the LQI sensor looks good, but I only get blank values for "Watts":

pnut1

The Z2M log has some interesting information. When I have something plugged into the plug and it's turned on, I'll get log entries about current (not power), like this:

4/19/2019, 1:50:07 PM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":34}}' of device 'PP-WHT-US' (0x000d6f000593651d) of endpoint 1
4/19/2019, 1:50:08 PM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":34}}' of device 'PP-WHT-US' (0x000d6f000593651d) of endpoint 1
4/19/2019, 1:50:11 PM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":34}}' of device 'PP-WHT-US' (0x000d6f000593651d) of endpoint 1
4/19/2019, 1:50:13 PM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":34}}' of device 'PP-WHT-US' (0x000d6f000593651d) of endpoint 1

I grabbed the log entries above a few days ago. With nothing plugged in I get "rmsCurrent":0 as expected. Today I'm getting messages like this:

4/23/2019, 9:03:15 AM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}' of device 'PP-WHT-US' (0x000d6f000593651d) of endpoint 1
4/23/2019, 9:03:15 AM - warn: No converter available for 'PP-WHT-US' with cid haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":0}}'
4/23/2019, 9:03:15 AM - warn: Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.
4/23/2019, 9:03:16 AM - debug: Received zigbee message of type 'attReport' with data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":464}}' of device 'PP-WHT-US' (0x000d6f000549b3b7) of endpoint 1
4/23/2019, 9:03:16 AM - warn: No converter available for 'PP-WHT-US' with cid 'haElectricalMeasurement', type 'attReport' and data '{"cid":"haElectricalMeasurement","data":{"rmsCurrent":464}}'
4/23/2019, 9:03:16 AM - warn: Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html.

etc.

In neither case is anything showing up in the Home Assistant sensor.

As you can see, I'm getting spammed with those reports and log entries every couple of seconds. I'm not sure if this is slowing down my zigbee network, but it sure seems to lag after I added these plugs.

For that "rmsCurrent":34 value, I'm not sure what to make of it. I have a Tradfri 8.6W bulb plugged in, turned up to 100%. If I multiply 34 by a conversion factor of 0.001831 (a default value stolen from the SmartThings device handler at https://github.com/pakmanwg/smartthings-peanut-plug/blob/master/devicetypes/pakmanwg/peanut-plug.src/peanut-plug.groovy), RMS voltage (120), and the Power Factor of around 0.8 (typical for decent bulbs), I get 5.98, which is roughly in the ballpark (I should plug the bulb into my Kill-a-Watt to confirm, as 100% white on a 600lm RGBW bulb might not be the highest-current scenario).

That SmartThings handler seems to have a way of caluclating these conversion factors for current, voltage, and power from data provided by the device; see lines 105-138. I don't see this in our devices.js.

It's also worth noting that the SmartThings is able to report voltage and power in addition to current.

Any thoughts on what needs to change here? I'm no zigbee expert, but I'm happy to help. I'm using z2m 1.3.1 and the firmware (for my CC2530+CC2591 box) is on the early-January release.

j4c3 commented 5 years ago

I just picked one of these up as well, but haven't dug too much into it yet.

At the moment, the devices.js file is looking for three fromZigbee converters, fz.ignore_electrical_change, fz.state, fz.ignore_onoff_change.

The ignore_electrical_change has the right cid, but is looking at devChange types, not attReport. So, we could easily ignore those reports/warnings in the log. But that won't get the measurement data.

When my device joined, in the .db file, there are entries for the things being used by smart things to determine the values. I didn't do any firmware updates, but I also haven't tested with anything plugged into it.

"haElectricalMeasurement":{
"dir":{
"value":3 }, "attrs":{
"measurementType":8, "acFrequency":0, "acFrequencyMultiplier":1, "acFrequencyDivisor":1, "rmsVoltage":0, "rmsCurrent":0, "activePower":0, "powerFactor":0, "acVoltageMultiplier":180, "acVoltageDivisor":39321, "acCurrentMultiplier":72, "acCurrentDivisor":39321, "acPowerMultiplier":10252, "acPowerDivisor":39321 }

wixoff commented 5 years ago

@j4c3 I actually put together most of an implementation to handle all of those attributes just this afternoon. I’m traveling right now so I can’t test it, but with a little luck I might be able to submit a PR within a few days.

wixoff commented 5 years ago

Update - not ready yet. Apparently I know enough about zigbee-shepherd to be dangerous, but not enough to actually make a working converter. That and I haven't had much time to follow up.

In the meantime I can confirm to @j4c3 that my database.db does appear to have a valid value for rmsVoltage (with nothing plugged in) at least, after the multiplier and divider is applied, so it appears the upgraded Peanut firmware is absolutely required.

roygbiv856 commented 5 years ago

@wixoff If I buy one of these, can I go through the standard pairing process to get it to work as just a plug without power monitoring? Or are there still extra steps involved with altering the database file?

j4c3 commented 5 years ago

Yes, it still requires extra steps. In the SecuriFi section here: https://www.zigbee2mqtt.io/getting_started/pairing_devices.html

And, if you aren't going to have monitoring, you may need to make a change to ignore the empty attReport messages.

A few extra steps, but if you just care about on and off, the price is pretty good.

wixoff commented 5 years ago

OK, it took a while, but PR #513 for the power, voltage, and current sensors is now submitted and pending review.

Koenkk commented 5 years ago

Closing this as @wixoff completed the support, will be supported in the dev branch within a few hours.

dsaul560 commented 5 years ago

I don't think this ever worked properly as a router and I believe that the firmware needs to be updated for measurements to be supported. Works fine as a switch though.

Is this device working as router. I bought a couple to increase range but devices far aways still getting disconnected.

wixoff commented 5 years ago

They work for me as routers - in my network map I see several end devices connected to Peanut plugs rather than the coordinator.

Mine are firmware updated, so I don't know if that makes a difference.

j4c3 commented 5 years ago

Are your end devices battery powered Xiaomi/Aqara? I am not 100% on this, but there may be an issue with those dropping off a router, since they don't report within expected time-frames. I've seen talk of some routers that allow you to extend that time (specifically someone said this about the IKEA one), but I don't know the Peanut Plug does/can.

dsaul560 commented 5 years ago

When I pair sometimes I see in the map connected to the peanut, but after 2-3h it disconnect. Tried multiple times and it pairs but disconnect after few hours, bought 3 of them :/. My firmware is not updated as I don’t have a hub. All end device battery is 100%, they are relatively new.

I can see all the routers and coordinator interconnected, not sure what would mean but not the end devices. Also tried lettings permit join true but didn’t do the trick.

My end devices are all Xiaomi battery power, buttons, temp sensor, motion etc. the ones closer.

andrew-d commented 3 years ago

It looks like the zigpy folks figured out how to perform an OTA update with a firmware file here: https://github.com/zigpy/zigpy/issues/522

I am not using zigpy right now (and will probably return the plugs, TBQH), but I figured I'd drop this here in case anyone else comes across this issue and wants to try this.

airdrummingfool commented 3 years ago

@andrew-d support for OTA updates for the Peanut Smart Plug was completed in https://github.com/Koenkk/zigbee-OTA/pull/14 and https://github.com/Koenkk/zigbee-herdsman-converters/pull/2027 and is fully functional.

andrew-d commented 3 years ago

@andrew-d support for OTA updates for the Peanut Smart Plug was completed in Koenkk/zigbee-OTA#14 and Koenkk/zigbee-herdsman-converters#2027 and is fully functional.

Oh, awesome - thank you for the information!