zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Unsupported device: Securifi Peanut Smart Plug

Open roger- opened this issue 7 years ago • 46 comments

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.

roger- avatar Jan 05 '19 20:01 roger-

  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

Koenkk avatar Jan 06 '19 14:01 Koenkk

Will try, but how do I repair?

roger- avatar Jan 06 '19 15:01 roger-

  • Stop zigbee2mqtt
  • Remove all lines containing 0x000d6f000a798c7b from database.db
  • Start zigbee2mqtt
  • Pair

Koenkk avatar Jan 06 '19 15:01 Koenkk

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?

roger- avatar Jan 06 '19 16:01 roger-

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"
}

Koenkk avatar Jan 07 '19 19:01 Koenkk

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- avatar Jan 07 '19 20:01 roger-

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

roger- avatar Jan 08 '19 01:01 roger-

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);
        },
    },

Koenkk avatar Jan 08 '19 18:01 Koenkk

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.

roger- avatar Jan 09 '19 01:01 roger-

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

Koenkk avatar Jan 09 '19 19:01 Koenkk

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!

henworth avatar Jan 09 '19 20:01 henworth

@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?

roger- avatar Jan 10 '19 01:01 roger-

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);
        },
    },

Koenkk avatar Jan 10 '19 16:01 Koenkk

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.

henworth avatar Jan 10 '19 16:01 henworth

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

Koenkk avatar Jan 10 '19 17:01 Koenkk

Yep, I have something connected to it.

henworth avatar Jan 10 '19 17:01 henworth

Where do dataType, attrId, etc. come from?

roger- avatar Jan 10 '19 23:01 roger-

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.

Koenkk avatar Jan 11 '19 07:01 Koenkk

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

roger- avatar Jan 11 '19 12:01 roger-

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

Koenkk avatar Jan 11 '19 13:01 Koenkk