diff --git a/app.json b/app.json index 4f2f8eff..f39800f1 100644 --- a/app.json +++ b/app.json @@ -3231,11 +3231,63 @@ ] }, { - "id": "outdoor_plug", + "id": "outdoor_plug", + "name": { + "en": "Outdoor Plug without metering" + }, + "class": "socket", + "platforms": [ + "local" + ], + "connectivity": [ + "zigbee" + ], + "capabilities": [ + "onoff" + ], + "capabilitiesOptions": { + "measure_power": { + "approximated": true + } + }, + "images": { + "large": "/drivers/outdoor_plug/assets/images/large.png", + "small": "/drivers/outdoor_plug/assets/images/small.png" + }, + "zigbee": { + "manufacturerName": [ + "_TZ3000_pnzfdr9y" + ], + "productId": [ + "TS0101" + ], + "endpoints": { + "1": { + "clusters": [ + 0, + 4, + 5, + 6 + ], + "bindings": [ + 6 + ] + } + }, + "learnmode": { + "instruction": { + "en": "Press and hold down on/off switch for aprox 5 seconds until the LED blinks rapidly." + } + } + }, + "settings": [] + }, + { + "id": "pir_motion_illuminance_sensor", "name": { - "en": "Outdoor Plug without metering" + "en": "PIR motion illuminance sensor" }, - "class": "socket", + "class": "sensor", "platforms": [ "local" ], @@ -3243,44 +3295,71 @@ "zigbee" ], "capabilities": [ - "onoff" + "alarm_motion", + "alarm_battery", + "measure_luminance", + "measure_battery" ], - "capabilitiesOptions": { - "measure_power": { - "approximated": true - } + "energy": { + "batteries": [ + "CR2450" + ] }, "images": { - "large": "/drivers/outdoor_plug/assets/images/large.png", - "small": "/drivers/outdoor_plug/assets/images/small.png" + "large": "/drivers/pir_motion_illuminance_sensor/assets/images/large.png", + "small": "/drivers/pir_motion_illuminance_sensor/assets/images/small.png" }, "zigbee": { "manufacturerName": [ - "_TZ3000_pnzfdr9y" + "_TZE200_3towulqd" ], "productId": [ - "TS0101" + "TS0601" ], "endpoints": { "1": { "clusters": [ 0, - 4, - 5, - 6 + 3, + 1280, + 57346, + 61184, + 60928, + 57344, + 1, + 1024 ], "bindings": [ - 6 + 1, + 1280 ] } }, "learnmode": { + "image": "/drivers/pir_motion_illuminance_sensor/assets/learn.svg", "instruction": { - "en": "Press and hold down on/off switch for aprox 5 seconds until the LED blinks rapidly." + "en": "Press the reset button for aprox 5 seconds until the LED blinks." } } }, - "settings": [] + "settings": [ + { + "id": "batteryThreshold", + "type": "number", + "label": { + "en": "Battery Low Alarm Voltage Threshold (percent)" + }, + "hint": { + "en": "This setting determines the threshold before a battery alarm is given." + }, + "value": 20, + "attr": { + "step": 1, + "min": 10, + "max": 90 + } + } + ] }, { "id": "pir_sensor_2", @@ -9175,4 +9254,4 @@ "setable": true } } -} \ No newline at end of file +} diff --git a/drivers/pir_motion_illuminance_sensor/assets/icon.svg b/drivers/pir_motion_illuminance_sensor/assets/icon.svg new file mode 100644 index 00000000..ebab8558 --- /dev/null +++ b/drivers/pir_motion_illuminance_sensor/assets/icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/drivers/pir_motion_illuminance_sensor/assets/images/large.PNG b/drivers/pir_motion_illuminance_sensor/assets/images/large.PNG new file mode 100644 index 00000000..6e29334c Binary files /dev/null and b/drivers/pir_motion_illuminance_sensor/assets/images/large.PNG differ diff --git a/drivers/pir_motion_illuminance_sensor/assets/images/small.PNG b/drivers/pir_motion_illuminance_sensor/assets/images/small.PNG new file mode 100644 index 00000000..ca208971 Binary files /dev/null and b/drivers/pir_motion_illuminance_sensor/assets/images/small.PNG differ diff --git a/drivers/pir_motion_illuminance_sensor/device.js b/drivers/pir_motion_illuminance_sensor/device.js new file mode 100644 index 00000000..991bce4e --- /dev/null +++ b/drivers/pir_motion_illuminance_sensor/device.js @@ -0,0 +1,341 @@ +'use strict'; + +const Homey = require('homey'); +const { ZigBeeDevice } = require('homey-zigbeedriver'); +const { debug, CLUSTER } = require('zigbee-clusters'); + +class pir_motion_illuminance_sensor extends ZigBeeDevice { + + async onNodeInit({ zclNode }) { + + this.printNode(); + + // alarm_motion + zclNode.endpoints[1].clusters[CLUSTER.IAS_ZONE.NAME].onZoneStatusChangeNotification = payload => { + this.onIASZoneStatusChangeNotification(payload); + } + // measure_battery // alarm_battery + zclNode.endpoints[1].clusters[CLUSTER.POWER_CONFIGURATION.NAME] + .on('attr.batteryPercentageRemaining', this.onBatteryPercentageRemainingAttributeReport.bind(this)); + // measure_luminance + zclNode.endpoints[1].clusters[CLUSTER.ILLUMINANCE_MEASUREMENT.NAME] + .on('attr.measuredValue', this.onIlluminanceMeasuredAttributeReport.bind(this)); + + } + + onIlluminanceMeasuredAttributeReport(measuredValue) { + const parsedValue = Math.round(Math.pow(10,((measuredValue - 1) / 10000))); + this.log('measure_luminance | Luminance - measuredValue (lux):', parsedValue); + this.setCapabilityValue('measure_luminance', parsedValue).catch(this.error); + } + + onIASZoneStatusChangeNotification({ zoneStatus, extendedStatus, zoneId, delay, }) { + this.log('IASZoneStatusChangeNotification received:', zoneStatus, extendedStatus, zoneId, delay); + this.setCapabilityValue('alarm_motion', zoneStatus.alarm1).catch(this.error); + } + + onBatteryPercentageRemainingAttributeReport(batteryPercentageRemaining) { + const batteryThreshold = this.getSetting('batteryThreshold') || 20; + this.log("measure_battery | powerConfiguration - batteryPercentageRemaining (%): ", batteryPercentageRemaining/2); + this.setCapabilityValue('measure_battery', batteryPercentageRemaining/2).catch(this.error); + this.setCapabilityValue('alarm_battery', (batteryPercentageRemaining/2 < batteryThreshold) ? true : false).catch(this.error); + } + + onDeleted(){ + this.log("PIR motion illuminance sensor removed") + } + +} + +module.exports = pir_motion_illuminance_sensor; + +//{ +// "ids": { +// "modelId": "TS0601", +// "manufacturerName": "_TZE200_3towulqd" +// }, +// "endpoints": { +// "ieeeAddress": "a4:c1:38:5e:ab:6e:a8:db", +// "networkAddress": 10175, +// "modelId": "TS0601", +// "manufacturerName": "_TZE200_3towulqd", +// "endpointDescriptors": [ +// { +// "status": "SUCCESS", +// "nwkAddrOfInterest": 10175, +// "_reserved": 26, +// "endpointId": 1, +// "applicationProfileId": 260, +// "applicationDeviceId": 1026, +// "applicationDeviceVersion": 0, +// "_reserved1": 1, +// "inputClusters": [ +// 0, +// 3, +// 1280, +// 57346, +// 61184, +// 60928, +// 57344, +// 1, +// 1024 +// ], +// "outputClusters": [] +// } +// ], +// "deviceType": "enddevice", +// "receiveWhenIdle": false, +// "swBuildId": "0122052017", +// "capabilities": { +// "alternatePANCoordinator": false, +// "deviceType": false, +// "powerSourceMains": false, +// "receiveWhenIdle": false, +// "security": false, +// "allocateAddress": true +// }, +// "extendedEndpointDescriptors": { +// "1": { +// "clusters": { +// "basic": { +// "attributes": [ +// { +// "acl": [ +// "readable" +// ], +// "id": 0, +// "name": "zclVersion" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 1, +// "name": "appVersion" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 2, +// "name": "stackVersion" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 3, +// "name": "hwVersion" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 4, +// "name": "manufacturerName" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 5, +// "name": "modelId" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 7, +// "name": "powerSource" +// }, +// { +// "acl": [ +// "readable", +// "writable" +// ], +// "id": 18, +// "name": "deviceEnabled" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 16384, +// "name": "swBuildId" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 65533, +// "name": "clusterRevision" +// } +// ], +// "commandsGenerated": "UNSUP_GENERAL_COMMAND", +// "commandsReceived": "UNSUP_GENERAL_COMMAND" +// }, +// "identify": { +// "attributes": [ +// { +// "acl": [ +// "readable", +// "writable" +// ], +// "id": 0, +// "name": "identifyTime", +// "value": 0 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 65533, +// "name": "clusterRevision", +// "value": 1 +// } +// ], +// "commandsGenerated": "UNSUP_GENERAL_COMMAND", +// "commandsReceived": "UNSUP_GENERAL_COMMAND" +// }, +// "iasZone": { +// "attributes": [ +// { +// "acl": [ +// "readable" +// ], +// "id": 0, +// "name": "zoneState", +// "value": "notEnrolled" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 1, +// "name": "zoneType", +// "value": "motionSensor" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 2, +// "name": "zoneStatus", +// "value": { +// "type": "Buffer", +// "data": [ +// 0, +// 0 +// ] +// } +// }, +// { +// "acl": [ +// "readable", +// "writable" +// ], +// "id": 16, +// "name": "iasCIEAddress", +// "value": "5c:c7:c1:ff:fe:5b:ce:ab" +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 17, +// "name": "zoneId", +// "value": 0 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 65533, +// "name": "clusterRevision", +// "value": 1 +// } +// ], +// "commandsGenerated": "UNSUP_GENERAL_COMMAND", +// "commandsReceived": "UNSUP_GENERAL_COMMAND" +// }, +// "powerConfiguration": { +// "attributes": [ +// { +// "acl": [ +// "readable" +// ], +// "id": 0 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 32, +// "name": "batteryVoltage", +// "value": 33 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 33, +// "name": "batteryPercentageRemaining", +// "value": 200 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 65533, +// "name": "clusterRevision", +// "value": 1 +// } +// ], +// "commandsGenerated": "UNSUP_GENERAL_COMMAND", +// "commandsReceived": "UNSUP_GENERAL_COMMAND" +// }, +// "illuminanceMeasurement": { +// "attributes": [ +// { +// "acl": [ +// "readable" +// ], +// "id": 0, +// "name": "measuredValue", +// "value": 1000 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 1, +// "name": "minMeasuredValue", +// "value": 0 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 2, +// "name": "maxMeasuredValue", +// "value": 4000 +// }, +// { +// "acl": [ +// "readable" +// ], +// "id": 65533, +// "name": "clusterRevision", +// "value": 1 +// } +// ], +// "commandsGenerated": "UNSUP_GENERAL_COMMAND", +// "commandsReceived": "UNSUP_GENERAL_COMMAND" +// } +// }, +// "bindings": { } +// } +// } +// } +//} + diff --git a/drivers/pir_motion_illuminance_sensor/driver.compose.json b/drivers/pir_motion_illuminance_sensor/driver.compose.json new file mode 100644 index 00000000..b971f567 --- /dev/null +++ b/drivers/pir_motion_illuminance_sensor/driver.compose.json @@ -0,0 +1,57 @@ +{ + "id": "pir_motion_illuminance_sensor", + "name": { + "en": "PIR motion illuminance sensor" + }, + "class": "sensor", + "platforms": [ "local" ], + "connectivity": [ "zigbee" ], + "capabilities": [ + "alarm_motion", + "alarm_battery", + "measure_luminance", + "measure_battery" + ], + "energy": { + "batteries": [ + "CR2450" + ] + }, + "images": { + "large": "{{driverAssetsPath}}/images/large.png", + "small": "{{driverAssetsPath}}/images/small.png" + }, + "zigbee": { + "manufacturerName": [ + "_TZE200_3towulqd" + ], + "productId": [ + "TS0601" + ], + "endpoints": { + "1": { + "clusters": [ + 0, + 3, + 1280, + 57346, + 61184, + 60928, + 57344, + 1, + 1024 + ], + "bindings": [ + 1, + 1280 + ] + } + }, + "learnmode": { + "image": "{{driverAssetsPath}}/learn.svg", + "instruction": { + "en": "Press the reset button for aprox 5 seconds until the LED blinks." + } + } + } +} \ No newline at end of file diff --git a/drivers/pir_motion_illuminance_sensor/driver.settings.compose.json b/drivers/pir_motion_illuminance_sensor/driver.settings.compose.json new file mode 100644 index 00000000..61524650 --- /dev/null +++ b/drivers/pir_motion_illuminance_sensor/driver.settings.compose.json @@ -0,0 +1,18 @@ +[ + { + "id": "batteryThreshold", + "type": "number", + "label": { + "en": "Battery Low Alarm Voltage Threshold (percent)" + }, + "hint": { + "en": "This setting determines the threshold before a battery alarm is given." + }, + "value": 20, + "attr": { + "step": 1, + "min": 10, + "max": 90 + } + } +] \ No newline at end of file