zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Trying to add Hive Motion sensors (will be adding many more tihngs)

Open matchett808 opened this issue 8 years ago • 73 comments

This is the first lot of things I'm trying to add - will also need to add Hive plugs, thermostat and other zigbee devices.

I get this message in my logs on startup (I added it to devices.js, think this part is ok):

2018-6-23 14:00:13 INFO 0x00124b000fa0779e (0x00124b000fa0779e): MOT003 - Hive Hive Motion Sensor (EndDevice)

I have this in the devices.js:

    {
        zigbeeModel: ['MOT003'],
        model: 'MOT003',
        vendor: 'Hive',
        description: 'Hive Motion Sensor',
        supports: 'occupancy',
        fromZigbee: [fz.hive_ias, fz.hive_occupancy, fz.hive_illum, fz.hive_temp],
        toZigbee: [],
    },

and here are the entries in fromZigbee.js:

  hive_occupancy: {
        cid: 'msOccupancySensing',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
            console.log(msg);
        },
    },
    hive_illum: {
        cid: 'msIlluminanceMeasurement',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
            console.log(msg);
        },
    },
    hive_temp: {
        cid: 'msTemperatureMeasurement',
        type: 'attReport',
        convert: (model, msg, publish, options) => {
            console.log(msg);
        },
    },

    hive_ias: {
        cid: 'ssIasZone',
        type: 'statusChange',
        convert: (model, msg, publish, options) => {
            return {motion: msg.data.zoneStatus === 1};
        },
    },

Thing is that I don't get any messages in the logs or over MQTT - here is the entry in database.db:

{
   "id":2,
   "type":"EndDevice",
   "ieeeAddr":"0x00124b000fa0779e",
   "nwkAddr":39651,
   "manufId":4153,
   "manufName":"HiveHome.com",
   "powerSource":"Battery",
   "modelId":"MOT003",
   "epList":[
      6
   ],
   "status":"online",
   "joinTime":1529757538,
   "endpoints":{
      "6":{
         "profId":260,
         "epId":6,
         "devId":1026,
         "inClusterList":[
            0,
            1,
            3,
            32,
            1024,
            1026,
            1030,
            1280
         ],
         "outClusterList":[
            25
         ],
         "clusters":{
            "genBasic":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "zclVersion":1,
                  "appVersion":4,
                  "stackVersion":38,
                  "hwVersion":0,
                  "manufacturerName":"HiveHome.com",
                  "modelId":"MOT003",
                  "dateCode":"20170809",
                  "powerSource":3,
                  "appProfileVersion":16908544,
                  "locationDesc":"",
                  "physicalEnv":0,
                  "deviceEnabled":1
               }
            },
            "genPowerCfg":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "batteryVoltage":30,
                  "batteryPercentageRemaining":181,
                  "batteryManufacturer":"CR123A",
                  "batterySize":2,
                  "batteryAHrRating":155,
                  "batteryQuantity":1,
                  "batteryRatedVoltage":30,
                  "batteryVoltMinThres":25
               }
            },
            "genIdentify":{
               "dir":{
                  "value":1
               },
               "attrs":{

               }
            },
            "genOta":{
               "dir":{
                  "value":2
               },
               "attrs":{

               }
            },
            "genPollCtrl":{
               "dir":{
                  "value":1
               },
               "attrs":{

               }
            },
            "msIlluminanceMeasurement":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "measuredValue":23538,
                  "minMeasuredValue":65535,
                  "maxMeasuredValue":65535,
                  "tolerance":65535,
                  "lightSensorType":0
               }
            },
            "msTemperatureMeasurement":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "measuredValue":2675,
                  "minMeasuredValue":-2500,
                  "maxMeasuredValue":8500,
                  "tolerance":50
               }
            },
            "msOccupancySensing":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "occupancy":1,
                  "occupancySensorType":0,
                  "pirOToUDelay":30,
                  "pirUToODelay":1,
                  "pirUToOThreshold":2
               }
            },
            "ssIasZone":{
               "dir":{
                  "value":1
               },
               "attrs":{
                  "zoneState":0,
                  "zoneType":13,
                  "zoneStatus":1,
                  "iasCieAddr":"0x0000000000000000",
                  "zoneId":255
               }
            }
         }
      }
   },
   "_id":"ZSCUNpjs70nw1k5V"
}

am I missing something? The device should report battery, illumaninance, motion and tempreature - but I never get anything out of it?

matchett808 avatar Jun 23 '18 14:06 matchett808

Looks like there's something up at part 2 of the supporting new devices tutorial - before adding it to devices.js I get the following in the logs:

2018-6-23 14:46:49 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'
2018-6-23 14:46:49 WARN Device with modelID 'MOT003' is not supported.
2018-6-23 14:46:49 WARN Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices

I then add this to devices.js:

    {
        zigbeeModel: ['MOT003'],
        model: 'MOT003',
        vendor: 'Hive',
        description: 'Hive Motion Sensor',
        supports: 'occupancy',
        fromZigbee: [],
        toZigbee: [],
    },

but I never get any of the messages like this:

WARN No converter available

matchett808 avatar Jun 23 '18 15:06 matchett808

We probably need to bind it.

Go to zigbee2mqtt directory:

cd node_modules
rm -rf zigbee-shepherd-converters
git clone https://github.com/Koenkk/zigbee-shepherd-converters.git -b hive_motion
cd zigbee-shepherd-converters
npm install

Now start zigbee2mqtt and trigger events on the motion sensor, do you see any WARN No converter available. ?

Koenkk avatar Jun 23 '18 18:06 Koenkk

I'm running with docker and have a volume mapped there:

      - ./zigbee_conv:/app/node_modules/zigbee-shepherd-converters/

that's where I was adding it to devices.js and fromZigbee.js

matchett808 avatar Jun 23 '18 19:06 matchett808

Just re-did it, still not seeing any, I have 2 hive bulbs in as well (to test) and changed their descriptors:

2018-6-23 19:09:24 INFO hallway_hive_motion_mqtt (0x00124b000fa0779e): MOT003 - Hive Hive Motion Sensor (EndDevice)
2018-6-23 19:09:24 INFO hallway_light (0x00158d00016766fc): HALIGHTDIMWWE27 - Hive Active light dimmable - I WIZ ERE (Router)
2018-6-23 19:09:24 INFO stair_light (0x00158d000166bcf7): HALIGHTDIMWWE27 - Hive Active light dimmable - I WIZ ERE (Router)

so my docker volume is definately hitting the right place (I added 'I WIZ ERE' to the descriptors)

Still not seeing anything in the logs when I trigger motion

matchett808 avatar Jun 23 '18 19:06 matchett808

I'm now trying it with your commit (missed that lol)

matchett808 avatar Jun 23 '18 19:06 matchett808

I now get

2018-06-23T19:16:21.810Z - error: Failed to configure 0x00124b000fa0779e

(0x00124b000fa0779e is the motion sensor) - this appears right after 'device is incoming'

Just as I started to reset and repair it I got this message:

2018-06-23T19:18:19.081Z - warn: Message without device!

so that's possibly done the trick - will reset and repair and let you know

matchett808 avatar Jun 23 '18 19:06 matchett808

after reset/repairing a couple of times - still not seeing any messages in reponse to stimulii

one thing to mention is that it keeps attempting to pair (on every restart) - not sure if this is an acceptable behaviour

matchett808 avatar Jun 23 '18 19:06 matchett808

Just to ensure we're getting all the info in here:

2018-6-23 19:42:04 INFO Starting zigbee2mqtt version 0.0.0 (commit #01a26ad)
2018-6-23 19:42:04 INFO Starting zigbee-shepherd
2018-6-23 19:42:04 INFO zigbee-shepherd started
2018-6-23 19:42:04 INFO Currently 3 devices are joined:
2018-6-23 19:42:04 INFO hallway_light (0x00158d00016766fc): HALIGHTDIMWWE27 - Hive Active light dimmable (Router)
2018-6-23 19:42:04 INFO stair_light (0x00158d000166bcf7): HALIGHTDIMWWE27 - Hive Active light dimmable (Router)
2018-6-23 19:42:04 INFO hallway_hive_motion_mqtt (0x00124b000fa0779e): MOT003 - Hive Hive Motion Sensor (EndDevice)
2018-6-23 19:42:04 WARN `permit_join` set to  `true` in configuration.yaml.
2018-6-23 19:42:04 WARN Allowing new devices to join.
2018-6-23 19:42:04 WARN Set `permit_join` to `false` once you joined all devices.
2018-6-23 19:42:04 INFO Zigbee: allowing new devices to join.
2018-6-23 19:42:04 INFO Connecting to MQTT server at mqtt://192.168.0.8
2018-6-23 19:42:04 INFO zigbee-shepherd ready
spinlock: false []
2018-6-23 19:42:04 INFO Connected to MQTT server
2018-6-23 19:42:04 INFO MQTT publish, topic: 'zb/bridge/state', payload: 'online'
2018-6-23 19:42:04 INFO MQTT publish, topic: 'homeassistant/light/0x00158d00016766fc/light/config', payload: '{"brightness":true,"platform":"mqtt_json","command_topic":"zb/hallway_light/set","state_topic":"zb/hallway_light","availability_topic":"zb/bridge/state","name":"hallway_light","unique_id":"0x00158d00016766fc_light_zb"}'
2018-6-23 19:42:04 INFO MQTT publish, topic: 'homeassistant/light/0x00158d000166bcf7/light/config', payload: '{"brightness":true,"platform":"mqtt_json","command_topic":"zb/stair_light/set","state_topic":"zb/stair_light","availability_topic":"zb/bridge/state","name":"stair_light","unique_id":"0x00158d000166bcf7_light_zb"}'
spinlock: true []
2018-6-23 19:42:05 INFO Connecting with device...
2018-6-23 19:42:05 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:05 INFO Connecting with device...
2018-6-23 19:42:05 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:12 INFO Connecting with device...
2018-6-23 19:42:12 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:13 INFO Connecting with device...
2018-6-23 19:42:13 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:14 INFO Connecting with device...
2018-6-23 19:42:14 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:15 INFO Connecting with device...
2018-6-23 19:42:15 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:16 INFO Connecting with device...
2018-6-23 19:42:16 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:16 INFO Device incoming...
2018-6-23 19:42:16 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'
2018-6-23 19:42:16 INFO Connecting with device...
2018-6-23 19:42:16 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:16 INFO Connecting with device...
2018-6-23 19:42:16 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:16 INFO Connecting with device...
2018-6-23 19:42:16 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:18 INFO Connecting with device...
2018-6-23 19:42:18 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:18 INFO Connecting with device...
2018-6-23 19:42:18 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:18 INFO Connecting with device...
2018-6-23 19:42:18 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:18 INFO Connecting with device...
2018-6-23 19:42:18 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"connecting with device"}'
2018-6-23 19:42:18 INFO Device incoming...
2018-6-23 19:42:18 INFO MQTT publish, topic: 'zb/bridge/log', payload: '{"type":"pairing","message":"device incoming"}'
2018-6-23 19:42:54 INFO Succesfully configured 0x00124b000fa0779e

Other than any other pairing attempts and weird 'spinlock' messages, the logs are silent(ish) after this point)

matchett808 avatar Jun 23 '18 19:06 matchett808

Used the Debug=* method - now logs are v. noisy but I can't pinpoint anything for this device

I think the below is pertinent to this device though:

Sat, 23 Jun 2018 20:20:17 GMT cc-znp:AREQ <-- ZDO:tcDeviceInd, { nwkaddr: 54397, extaddr: '0x00124b000fa0779e', parentaddr: 16507 }
Sat, 23 Jun 2018 20:20:17 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:tcDeviceInd
Sat, 23 Jun 2018 20:20:17 GMT cc-znp:AREQ <-- ZDO:tcDeviceInd, { nwkaddr: 54397, extaddr: '0x00124b000fa0779e', parentaddr: 16507 }
Sat, 23 Jun 2018 20:20:17 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:tcDeviceInd
Sat, 23 Jun 2018 20:20:17 GMT cc-znp:AREQ <-- ZDO:endDeviceAnnceInd, { srcaddr: 54397, nwkaddr: 54397, ieeeaddr: '0x00124b000fa0779e', capabilities: 128 }
spinlock: false []
Sat, 23 Jun 2018 20:20:17 GMT zigbee-shepherd:request REQ --> ZDO:nodeDescReq
Sat, 23 Jun 2018 20:20:17 GMT cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 54397, nwkaddrofinterest: 54397 }
Sat, 23 Jun 2018 20:20:17 GMT serialport write 9 bytes of data
Sat, 23 Jun 2018 20:20:17 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd
Sat, 23 Jun 2018 20:20:17 GMT cc-znp:SRSP <-- ZDO:nodeDescReq, { status: 0 }
Sat, 23 Jun 2018 20:20:27 GMT zigbee-shepherd:request REQ --> ZDO:nodeDescReq
Sat, 23 Jun 2018 20:20:27 GMT cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 54397, nwkaddrofinterest: 54397 }
Sat, 23 Jun 2018 20:20:27 GMT serialport write 9 bytes of data
Sat, 23 Jun 2018 20:20:27 GMT cc-znp:SRSP <-- ZDO:nodeDescReq, { status: 0 }
2018-6-23 21:20:37 ERROR Cannot get the Node Descriptor of the Device: 0x00124b000fa0779e (Error: Timed out after 10000 ms)

matchett808 avatar Jun 23 '18 20:06 matchett808

yeah - the above messages are produced in response to removing and re-adding the battery

matchett808 avatar Jun 23 '18 20:06 matchett808

Updated the code, can you try this again?

cd node_modules
rm -rf zigbee-shepherd-converters
git clone https://github.com/Koenkk/zigbee-shepherd-converters.git -b hive_motion
cd zigbee-shepherd-converters
npm install

Koenkk avatar Jun 23 '18 20:06 Koenkk

Tried that, I did get this - but only because the device was sitting for a while (and woke up I reckon):


Sat, 23 Jun 2018 20:49:53 GMT cc-znp:AREQ <-- ZDO:endDeviceAnnceInd, { srcaddr: 11322, nwkaddr: 11322, ieeeaddr: '0x00124b000fa0779e', capabilities: 128 }
spinlock: false []
device already in network
Sat, 23 Jun 2018 20:49:53 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd

Sat, 23 Jun 2018 20:49:53 GMT cc-znp:AREQ <-- ZDO:tcDeviceInd, { nwkaddr: 11322, extaddr: '0x00124b000fa0779e', parentaddr: 0 }
Sat, 23 Jun 2018 20:49:53 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:tcDeviceInd

It didn't report the 2nd or 3rd time I tried it (there's an LED on it for when it detects motion)

Don't know if it will help much but there are smartthings device handlers: https://community.smartthings.com/t/hive-motion-contact-sensors/57452 this doesn't work for motion with this version - but the orvibo one apparently does https://github.com/Kriskit/SmartThingsPublic/blob/master/devicetypes/kriskit/orvibo/orvibo-motion-sensor.groovy#L68

The orvibo DTH looks at IASzone 19?

matchett808 avatar Jun 23 '18 20:06 matchett808

Pulling the battery also produces this:

spinlock: false []
device already in network
Sat, 23 Jun 2018 20:54:54 GMT cc-znp:AREQ <-- ZDO:endDeviceAnnceInd, { srcaddr: 11322, nwkaddr: 11322, ieeeaddr: '0x00124b000fa0779e', capabilities: 128 }
Sat, 23 Jun 2018 20:54:54 GMT zigbee-shepherd:msgHdlr IND <-- ZDO:endDeviceAnnceInd

matchett808 avatar Jun 23 '18 20:06 matchett808

Did it also confgure correctly with my new change? e.g. 2018-6-23 19:42:54 INFO Succesfully configured 0x00124b000fa0779e

Koenkk avatar Jun 23 '18 21:06 Koenkk

🎉 getting something now, needed to completely strip it out completely in order to get it (didn't get a configured correctly/incorrectly message)

2018-06-23T21:40:04.274Z - debug: Recieved zigbee message with data {"cid":"msOccupancySensing","data":{"occupancy":0}}
2018-06-23T21:40:04.275Z - warn: No converter available for 'MOT003' with cid 'msOccupancySensing' and type 'attReport'
2018-06-23T21:40:04.275Z - warn: Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
2018-06-23T21:40:04.277Z - debug: Recieved zigbee message with data {"cid":"msOccupancySensing","data":{"occupancy":0}}
2018-06-23T21:40:04.279Z - warn: No converter available for 'MOT003' with cid 'msOccupancySensing' and type 'devChange'
2018-06-23T21:40:04.282Z - warn: Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.

However - even with debug=* as an environement variable - I'm still not seeing anything happening (attaching to the docker container or in the logs - but is that the right behaviour?) I'll add a converter and see what happens

matchett808 avatar Jun 23 '18 21:06 matchett808

Yes this looks good! How does your configure() now look?

Koenkk avatar Jun 23 '18 22:06 Koenkk

I get this now:

2018-06-23T21:54:15.409Z - info: Succesfully configured 0x00124b000fa0779e
2018-06-23T21:54:15.793Z - debug: Recieved zigbee message with data {"cid":"msOccupancySensing","data":{"occupancy":1}}

but no actual reaction to the device LED telling me that it's sensing motion

  {
        zigbeeModel: ['MOT003'],
        model: 'MOT003',
        vendor: 'Hive',
        description: 'Hive Motion Sensor',
        supports: 'occupancy',
        fromZigbee: [fz.hive_occupancy],
        toZigbee: [],
        configure: (ieeeAddr, shepherd, coordinator, callback) => {
            const cfgRptRec = {
                direction: 0, attrId: 0, dataType: 24, minRepIntval: 0, maxRepIntval: 1000, repChange: 0,
            };

            const device = shepherd.find(ieeeAddr, 6);
            if (device) {
                device.bind('msOccupancySensing', coordinator, (error) => {
                    if (error) {
                        callback(error);
                    } else {
                        device.foundation('msOccupancySensing', 'configReport', [cfgRptRec]).then((rsp) => {
                            callback(rsp[0].status === 0);
                        });
                    }
                });
            }
        },
    },

matchett808 avatar Jun 23 '18 22:06 matchett808

But does it send

2018-06-23T21:54:15.793Z - debug: Recieved zigbee message with data {"cid":"msOccupancySensing","data":{"occupancy":1}}

when you trigger the sensor?

Koenkk avatar Jun 23 '18 22:06 Koenkk

Not when I trigger the sensor - that happens when the configure happens

matchett808 avatar Jun 23 '18 22:06 matchett808

By attaching to the docker container I get logs like this for other devices:

2018-6-23 23:09:10 DEBUG Check online 0x00158d00016766fc
Sat, 23 Jun 2018 22:09:10 GMT zigbee-shepherd:request REQ --> ZDO:nodeDescReq
Sat, 23 Jun 2018 22:09:10 GMT cc-znp:SREQ --> ZDO:nodeDescReq, { dstaddr: 16507, nwkaddrofinterest: 16507 }
Sat, 23 Jun 2018 22:09:10 GMT serialport write 9 bytes of data

But nothing for this device (other than when it wakes)

matchett808 avatar Jun 23 '18 22:06 matchett808