diff --git a/drivers/SmartThings/zwave-sensor/fingerprints.yml b/drivers/SmartThings/zwave-sensor/fingerprints.yml index 727f02a2d6..a58a04f233 100644 --- a/drivers/SmartThings/zwave-sensor/fingerprints.yml +++ b/drivers/SmartThings/zwave-sensor/fingerprints.yml @@ -548,6 +548,11 @@ zwaveManufacturer: productType: 0x0100 productId: 0x0082 deviceProfileName: shelly-wave-motion + - id: "aeotec/water/8" + deviceLabel: Aeotec Water Sensor 8 + manufacturerId: 0x0371 + productId: 0x0038 + deviceProfileName: aeotec-water-sensor-8 zwaveGeneric: - id: "GenericSensorAlarm" deviceLabel: Z-Wave Sensor diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co.yml new file mode 100644 index 0000000000..38682e8c96 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-co +components: +- id: main + capabilities: + - id: carbonMonoxideDetector + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: SmokeDetector +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co2.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co2.yml new file mode 100644 index 0000000000..a048d5bd8e --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-co2.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-co2 +components: +- id: main + capabilities: + - id: carbonDioxideHealthConcern + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: SmokeDetector +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-contact.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-contact.yml new file mode 100644 index 0000000000..eb476d9d9c --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-contact.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-contact +components: +- id: main + capabilities: + - id: contactSensor + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: ContactSensor +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-glass-break.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-glass-break.yml new file mode 100644 index 0000000000..287efe5bba --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-glass-break.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-glass-break +components: +- id: main + capabilities: + - id: soundDetection + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: SoundSensor +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-motion.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-motion.yml new file mode 100644 index 0000000000..d9f2e6ba8b --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-motion.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-motion +components: +- id: main + capabilities: + - id: motionSensor + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: MotionSensor +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-panic.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-panic.yml new file mode 100644 index 0000000000..d366cee6b7 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-panic.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-panic +components: +- id: main + capabilities: + - id: panicAlarm + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: PanicButton +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-smoke.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-smoke.yml new file mode 100644 index 0000000000..06023a4962 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8-smoke.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8-smoke +components: +- id: main + capabilities: + - id: smokeDetector + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: SmokeDetector +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8.yml b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8.yml new file mode 100644 index 0000000000..0e27580c9f --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/profiles/aeotec-water-sensor-8.yml @@ -0,0 +1,146 @@ +name: aeotec-water-sensor-8 +components: +- id: main + capabilities: + - id: waterSensor + version: 1 + - id: temperatureMeasurement + config: + values: + - key: "temperature.value" + range: [-10, 60] + version: 1 + - id: relativeHumidityMeasurement + version: 1 + - id: dewPoint + version: 1 + - id: moldHealthConcern + version: 1 + - id: tamperAlert + version: 1 + - id: powerSource + version: 1 + - id: battery + version: 1 + - id: refresh + version: 1 + categories: + - name: LeakSensor +preferences: + - name: "parameter1" + title: "1 Set threshold Check Time" + description: "When using battery power, follow this configuration, the minimum time is 30 seconds. When using USB power supply, for real-time detection." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 900 + - name: "parameter2" + title: "2 Min. temperature change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 20 + - name: "parameter3" + title: "3 Min. humidity change to report" + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 255 + default: 50 + - name: "parameter4" + title: "4 Enable led indication" + description: "This parameter defines when the green or red LED will indicate events. Disabling all indications may extend battery life. Off means no indications." + required: false + preferenceType: enumeration + definition: + options: + 0: "Off" + 1: "On" + default: 0 + - name: "parameter5" + title: "5 Dry contact sensor polarity" + description: "This parameter allows to set the states of alarm when the dry contact is closed" + required: false + preferenceType: enumeration + definition: + options: + 0: "Closed = Alarm, Open = Idle" + 1: "Open = Alarm, Closed = Idle" + default: 0 + - name: "parameter10" + title: "Notification Type" + description: "Set the notification type." + required: false + preferenceType: enumeration + definition: + options: + 0: "Water Alarm" + 1: "Smoke Alarm" + 2: "CO Alarm" + 3: "CO2 Alarm" + 4: "Door/Window Alarm" + 5: "Tilt Alarm" + 6: "Motion Alarm" + 7: "Glass Break Alarm" + 8: "Panic Alarm" + default: 0 + - name: "parameter13" + title: "13 Mold alarm offset" + description: "Increase the humidity threshold." + required: false + preferenceType: integer + definition: + minimum: -10 + maximum : 10 + default: 0 + - name: "parameter23" + title: "23 Low battery threshold" + description: "Report low battery report when level goes under threshold setting." + required: false + preferenceType: integer + definition: + minimum: 10 + maximum : 50 + default: 20 + - name: "parameter24" + title: "24 Periodic Reports" + description: "The period of battery, temperature and humidity report, the minimum time is 30 seconds." + required: false + preferenceType: integer + definition: + minimum: 0 + maximum : 2678400 + default: 43200 + - name: "parameter25" + title: "25 Offset value for temperature" + description: "Calibrate temperature. Scale is defined by Param 64 .eg: Value 15 means 1.5°C or 1.5F" + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter26" + title: "26 Offset value for Humidity" + description: "Calibrate humidity." + required: false + preferenceType: integer + definition: + minimum: -200 + maximum : 200 + default: 0 + - name: "parameter64" + title: "64 Temperature Scale" + description: "Scale for auto reports and settings." + required: false + preferenceType: enumeration + definition: + options: + 0: "Celsius" + 1: "Fahrenheit" + default: 0 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/src/aeotec-water-sensor-8/init.lua b/drivers/SmartThings/zwave-sensor/src/aeotec-water-sensor-8/init.lua new file mode 100644 index 0000000000..d6ee9c0f1e --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/src/aeotec-water-sensor-8/init.lua @@ -0,0 +1,265 @@ +-- Copyright 2025 SmartThings +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +local capabilities = require "st.capabilities" +--- @type st.zwave.CommandClass +local cc = require "st.zwave.CommandClass" +--- @type st.zwave.CommandClass.Notification +local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 }) +--- @type st.zwave.CommandClass.Battery +local Battery = (require "st.zwave.CommandClass.Battery")({ version = 1 }) +--- @type st.zwave.CommandClass.Configuration +local Configuration = (require "st.zwave.CommandClass.Configuration")({ version = 4 }) + +local log = require "log" +local utils = require "st.utils" + +local MoldHealthConcern = capabilities.moldHealthConcern +local CarbonDioxideHealthConcern = capabilities.carbonDioxideHealthConcern +local SoundDetection = capabilities.soundDetection +local SmokeDetector = capabilities.smokeDetector +local WaterSensor = capabilities.waterSensor +local CarbonMonoxideDetector = capabilities.carbonMonoxideDetector +local TamperAlert = capabilities.tamperAlert +local MotionSensor = capabilities.motionSensor +local PowerSource = capabilities.powerSource +local ContactSensor = capabilities.contactSensor +local PanicAlarm = capabilities.panicAlarm + +local AEOTEC_WATER_SENSOR_8_FINGERPRINTS = { + { manufacturerId = 0x0371, productId = 0x0038 } -- Aeotec Water Sensor 8 EU/US/AU +} + +DEVICE_PROFILES = { + [0] = { profile = "aeotec-water-sensor-8"}, + [1] = { profile = "aeotec-water-sensor-8-smoke"}, + [2] = { profile = "aeotec-water-sensor-8-co"}, + [3] = { profile = "aeotec-water-sensor-8-co2"}, + [4] = { profile = "aeotec-water-sensor-8-contact"}, + [5] = { profile = "aeotec-water-sensor-8-contact"}, + [6] = { profile = "aeotec-water-sensor-8-motion"}, + [7] = { profile = "aeotec-water-sensor-8-glass-break"}, + [8] = { profile = "aeotec-water-sensor-8-panic"} +} + +local function can_handle_aeotec_water_sensor_8(opts, driver, device, ...) + for _, fingerprint in ipairs(AEOTEC_WATER_SENSOR_8_FINGERPRINTS) do + if device:id_match(fingerprint.manufacturerId, fingerprint.productType, fingerprint.productId) then + local subdriver = require("aeotec-water-sensor-8") + return true, subdriver + end + end + return false +end + +local function set_profile(device, profile) + local current = device:get_field("active_profile") + if current ~= profile.profile then + log.info(string.format("Switching profile to: %s", profile.profile)) + + device:try_update_metadata({ profile = profile.profile }) + device:set_field("active_profile", profile.profile) + + -- Set supported modes and default value based on profile + if profile.profile == "aeotec-water-sensor-8" then + device:emit_event(WaterSensor.water.dry()) + elseif profile.profile == "aeotec-water-sensor-8-glass-break" then + device:emit_event(SoundDetection.supportedSoundTypes({"noSound", "glassBreaking"})) + device:emit_event(SoundDetection.soundDetected.noSound()) + elseif profile.profile == "aeotec-water-sensor-8-co2" then + device:emit_event(CarbonDioxideHealthConcern.supportedCarbonDioxideValues({"good", "moderate"})) + device:emit_event(CarbonDioxideHealthConcern.carbonDioxideHealthConcern.good()) + elseif profile.profile == "aeotec-water-sensor-8-co" then + device:emit_event(CarbonMonoxideDetector.carbonMonoxide.clear()) + elseif profile.profile == "aeotec-water-sensor-8-contact" then + device:emit_event(ContactSensor.contact.closed()) + elseif profile.profile == "aeotec-water-sensor-8-motion" then + device:emit_event(MotionSensor.motion.inactive()) + elseif profile.profile == "aeotec-water-sensor-8-panic" then + device:emit_event(PanicAlarm.panicAlarm.clear()) + elseif profile.profile == "aeotec-water-sensor-8-smoke" then + device:emit_event(SmokeDetector.smoke.clear()) + end + end +end + +local function added_handler(driver, device) + -- Get parameter 10 to switch device profile bsaed on the parameter value + device:send(Configuration:Get({ parameter_number = 10 })) + + device:emit_event(MoldHealthConcern.supportedMoldValues({"good", "moderate"})) + -- Default value + device:emit_event(MoldHealthConcern.moldHealthConcern.good()) + + -- Default value + device:emit_event(PowerSource.powerSource.battery()) + + device:send(Battery:Get({})) +end + +local function do_refresh(driver, device) + device:send(Battery:Get({})) +end + +local function notification_report_handler(self, device, cmd) + local active_profile = device:get_field("active_profile") + local event + + local event_parameter + log.info("event_parameter", utils.stringify_table(cmd.args.event_parameter)) + + if (0 ~= string.len(cmd.args.event_parameter)) then + event_parameter = string.byte(cmd.args.event_parameter) + end + + -- MOTION, GLASS_BREAK, TAMPER + if cmd.args.notification_type == Notification.notification_type.HOME_SECURITY then + -- TAMPER + if cmd.args.event == Notification.event.home_security.STATE_IDLE and event_parameter == Notification.event.home_security.TAMPERING_PRODUCT_COVER_REMOVED then + event = TamperAlert.tamper.clear() + elseif active_profile == 'aeotec-water-sensor-8-motion' then -- MOTION + if cmd.args.event == Notification.event.home_security.STATE_IDLE and event_parameter == Notification.event.home_security.MOTION_DETECTION then + event = MotionSensor.motion.inactive() + elseif cmd.args.event == Notification.event.home_security.MOTION_DETECTION then + event = MotionSensor.motion.active() + end + elseif active_profile == 'aeotec-water-sensor-8-glass-break' then -- GLASS_BREAK + if cmd.args.event == Notification.event.home_security.STATE_IDLE and event_parameter == Notification.event.home_security.GLASS_BREAKAGE then + event = SoundDetection.soundDetected.noSound() + elseif cmd.args.event == Notification.event.home_security.GLASS_BREAKAGE then + event = SoundDetection.soundDetected.glassBreaking() + end + end + end + + if cmd.args.notification_type == Notification.notification_type.POWER_MANAGEMENT then + if cmd.args.event == Notification.event.power_management.AC_MAINS_DISCONNECTED then + event = PowerSource.powerSource.battery() + elseif cmd.args.event == Notification.event.power_management.AC_MAINS_RE_CONNECTED then + event = PowerSource.powerSource.dc() + elseif cmd.args.event == Notification.event.power_management.POWER_HAS_BEEN_APPLIED then + device:send(Battery:Get({})) + end + end + + -- WATER + if cmd.args.notification_type == Notification.notification_type.WATER then + if cmd.args.event == Notification.event.water.STATE_IDLE then + event = WaterSensor.water.dry() + elseif cmd.args.event == Notification.event.water.LEAK_DETECTED then + event = WaterSensor.water.wet() + end + end + + -- MOLD + if cmd.args.notification_type == Notification.notification_type.WEATHER_ALARM then + if cmd.args.event == Notification.event.weather_alarm.STATE_IDLE then + event = MoldHealthConcern.moldHealthConcern.good() + elseif cmd.args.event == Notification.event.weather_alarm.MOISTURE_ALARM then + event = MoldHealthConcern.moldHealthConcern.moderate() + end + end + + -- SMOKE + if cmd.args.notification_type == Notification.notification_type.SMOKE then + if cmd.args.event == Notification.event.smoke.STATE_IDLE then + event = SmokeDetector.smoke.clear() + elseif cmd.args.event == Notification.event.smoke.DETECTED then + event = SmokeDetector.smoke.detected() + end + end + + -- CO + if cmd.args.notification_type == Notification.notification_type.CO then + if cmd.args.event == Notification.event.co.STATE_IDLE then + event = CarbonMonoxideDetector.carbonMonoxide.clear() + elseif cmd.args.event == Notification.event.co.CARBON_MONOXIDE_DETECTED then + event = CarbonMonoxideDetector.carbonMonoxide.detected() + end + end + + -- CO2 + if cmd.args.notification_type == Notification.notification_type.CO2 then + if cmd.args.event == Notification.event.co2.STATE_IDLE then + event = capabilities.carbonDioxideHealthConcern.carbonDioxideHealthConcern.good() + elseif cmd.args.event == Notification.event.co2.CARBON_DIOXIDE_DETECTED then + event = capabilities.carbonDioxideHealthConcern.carbonDioxideHealthConcern.moderate() + end + end + + -- DOOR_WINDOW/TILT + if cmd.args.notification_type == Notification.notification_type.ACCESS_CONTROL then + if cmd.args.event == Notification.event.access_control.WINDOW_DOOR_IS_CLOSED then + event = ContactSensor.contact.closed() + elseif cmd.args.event == Notification.event.access_control.WINDOW_DOOR_IS_OPEN then + event = ContactSensor.contact.open() + end + end + + -- PANIC + if cmd.args.notification_type == Notification.notification_type.EMERGENCY then + if cmd.args.event == Notification.event.emergency.STATE_IDLE then + event = PanicAlarm.panicAlarm.clear() + elseif cmd.args.event == Notification.event.emergency.PANIC_ALERT then + event = PanicAlarm.panicAlarm.panic() + end + end + + if (event ~= nil) then + device:emit_event(event) + end +end + +local function configuration_report_handler(self, device, cmd) + local param_number = cmd.args.parameter_number + local value = cmd.args.configuration_value + log.info(string.format("Received Configuration Report #%d = %d", param_number, value)) + + if param_number == 10 then + local mapping = DEVICE_PROFILES[value] + if mapping then + set_profile(device, mapping) + end + end +end + +local aeotec_water_sensor_8 = { + supported_capabilities = { + capabilities.powerSource, + capabilities.carbonMonoxideDetector, + capabilities.carbonDioxideHealthConcern, + capabilities.soundDetection, + capabilities.panicAlarm + }, + zwave_handlers = { + [cc.CONFIGURATION] = { + [Configuration.REPORT] = configuration_report_handler + }, + [cc.NOTIFICATION] = { + [Notification.REPORT] = notification_report_handler + }, + }, + capability_handlers = { + [capabilities.refresh.ID] = { + [capabilities.refresh.commands.refresh.NAME] = do_refresh + } + }, + lifecycle_handlers = { + added = added_handler, + }, + NAME = "Aeotec Water Sensor 8", + can_handle = can_handle_aeotec_water_sensor_8 +} + +return aeotec_water_sensor_8 \ No newline at end of file diff --git a/drivers/SmartThings/zwave-sensor/src/init.lua b/drivers/SmartThings/zwave-sensor/src/init.lua index d92a09fe56..5c85ee26c7 100644 --- a/drivers/SmartThings/zwave-sensor/src/init.lua +++ b/drivers/SmartThings/zwave-sensor/src/init.lua @@ -153,6 +153,7 @@ local driver_template = { lazy_load_if_possible("timed-tamper-clear"), lazy_load_if_possible("wakeup-no-poll"), lazy_load_if_possible("apiv6_bugfix"), + lazy_load_if_possible("aeotec-water-sensor-8"), }, lifecycle_handlers = { added = added_handler, diff --git a/drivers/SmartThings/zwave-sensor/src/preferences.lua b/drivers/SmartThings/zwave-sensor/src/preferences.lua index 4921a996bf..37fb652606 100644 --- a/drivers/SmartThings/zwave-sensor/src/preferences.lua +++ b/drivers/SmartThings/zwave-sensor/src/preferences.lua @@ -162,6 +162,27 @@ local devices = { motionNotdetRepT = {parameter_number = 160, size = 2}, }, }, + AEOTEC_WATER_SENSOR_8 = { + MATCHING_MATRIX = { + mfrs = 0x0371, + product_types = {0x0000, 0x0001, 0x0002}, + product_ids = {0x0038} + }, + PARAMETERS = { + parameter1 = {parameter_number = 1, size = 1}, + parameter2 = {parameter_number = 2, size = 1}, + parameter3 = {parameter_number = 3, size = 1}, + parameter4 = {parameter_number = 4, size = 1}, + parameter5 = {parameter_number = 5, size = 1}, + parameter10 = {parameter_number = 10, size = 1}, + parameter13 = {parameter_number = 13, size = 1}, + parameter23 = {parameter_number = 23, size = 1}, + parameter24 = {parameter_number = 24, size = 4}, + parameter25 = {parameter_number = 25, size = 2}, + parameter26 = {parameter_number = 26, size = 2}, + parameter64 = {parameter_number = 64, size = 1}, + }, + }, } local preferences = {} diff --git a/drivers/SmartThings/zwave-sensor/src/test/test_aeotec_water_sensor_8.lua b/drivers/SmartThings/zwave-sensor/src/test/test_aeotec_water_sensor_8.lua new file mode 100644 index 0000000000..04d767d0c6 --- /dev/null +++ b/drivers/SmartThings/zwave-sensor/src/test/test_aeotec_water_sensor_8.lua @@ -0,0 +1,516 @@ +-- Copyright 2025 SmartThings +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +local test = require "integration_test" +local capabilities = require "st.capabilities" +local zw = require "st.zwave" +local zw_test_utils = require "integration_test.zwave_test_utils" +--- @type st.zwave.CommandClass.Notification +local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 }) +--- @type st.zwave.CommandClass.Battery +local Battery = (require "st.zwave.CommandClass.Battery")({ version = 1 }) +--- @type st.zwave.CommandClass.Configuration +local Configuration = (require "st.zwave.CommandClass.Configuration")({ version = 4 }) +local t_utils = require "integration_test.utils" + +local sensor_endpoints = { + { + command_classes = { + {value = zw.BATTERY}, + {value = zw.NOTIFICATION}, + {value = zw.SENSOR_MULTILEVEL}, + {value = zw.CONFIGURATION} + } + } +} + +local mock_water_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_co_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-co.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_co2_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-co2.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_contact_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-contact.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_glass_break_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-glass-break.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_motion_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-motion.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_panic_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-panic.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +local mock_smoke_sensor = test.mock_device.build_test_zwave_device({ + profile = t_utils.get_profile_definition("aeotec-water-sensor-8-smoke.yml"), + zwave_endpoints = sensor_endpoints, + zwave_manufacturer_id = 0x0371, + zwave_product_type = 0x0002, + zwave_product_id = 0x0038, +}) + +DEVICE_PROFILES = { + [0] = { + profile = "aeotec-water-sensor-8", + mock_device = mock_water_sensor, + default_cap = capabilities.waterSensor.water.dry(), + active_cap = capabilities.waterSensor.water.wet(), + default_cap_str = "dry", + active_cap_str = "wet", + notification_typ = Notification.notification_type.WATER, + on_event = Notification.event.water.LEAK_DETECTED, + off_event = Notification.event.water.STATE_IDLE + }, + [1] = { + profile = "aeotec-water-sensor-8-smoke", + mock_device = mock_smoke_sensor, + default_cap = capabilities.smokeDetector.smoke.clear(), + active_cap = capabilities.smokeDetector.smoke.detected(), + default_cap_str = "clear", + active_cap_str = "detected", + notification_typ = Notification.notification_type.SMOKE, + on_event = Notification.event.smoke.DETECTED, + off_event = Notification.event.smoke.STATE_IDLE + }, + [2] = { + profile = "aeotec-water-sensor-8-co", + mock_device = mock_co_sensor, + default_cap = capabilities.carbonMonoxideDetector.carbonMonoxide.clear(), + active_cap = capabilities.carbonMonoxideDetector.carbonMonoxide.detected(), + default_cap_str = "clear", + active_cap_str = "detected", + notification_typ = Notification.notification_type.CO, + on_event = Notification.event.co.CARBON_MONOXIDE_DETECTED, + off_event = Notification.event.co.STATE_IDLE + }, + [3] = { + profile = "aeotec-water-sensor-8-co2", + mock_device = mock_co2_sensor, + default_cap = capabilities.carbonDioxideHealthConcern.carbonDioxideHealthConcern.good(), + active_cap = capabilities.carbonDioxideHealthConcern.carbonDioxideHealthConcern.moderate(), + default_cap_str = "good", + active_cap_str = "moderate", + notification_typ = Notification.notification_type.CO2, + on_event = Notification.event.co2.CARBON_DIOXIDE_DETECTED, + off_event = Notification.event.co2.STATE_IDLE + }, + [4] = { + profile = "aeotec-water-sensor-8-contact", + mock_device = mock_contact_sensor, + default_cap = capabilities.contactSensor.contact.closed(), + active_cap = capabilities.contactSensor.contact.open(), + default_cap_str = "closed", + active_cap_str = "open", + notification_typ = Notification.notification_type.ACCESS_CONTROL, + on_event = Notification.event.access_control.WINDOW_DOOR_IS_OPEN, + off_event = Notification.event.access_control.WINDOW_DOOR_IS_CLOSED + }, + [5] = { + profile = "aeotec-water-sensor-8-contact", + mock_device = mock_contact_sensor, + default_cap = capabilities.contactSensor.contact.closed(), + active_cap = capabilities.contactSensor.contact.open(), + default_cap_str = "closed", + active_cap_str = "open", + notification_typ = Notification.notification_type.ACCESS_CONTROL, + on_event = Notification.event.access_control.WINDOW_DOOR_IS_OPEN, + off_event = Notification.event.access_control.WINDOW_DOOR_IS_CLOSED + }, + [6] = { + profile = "aeotec-water-sensor-8-motion", + mock_device = mock_motion_sensor, + default_cap = capabilities.motionSensor.motion.inactive(), + active_cap = capabilities.motionSensor.motion.active(), + default_cap_str = "inactive", + active_cap_str = "active", + notification_typ = Notification.notification_type.HOME_SECURITY, + on_event = Notification.event.home_security.MOTION_DETECTION, + off_event = Notification.event.home_security.STATE_IDLE + }, + [7] = { + profile = "aeotec-water-sensor-8-glass-break", + mock_device = mock_glass_break_sensor, + default_cap = capabilities.soundDetection.soundDetected.noSound(), + active_cap = capabilities.soundDetection.soundDetected.glassBreaking(), + default_cap_str = "noSound", + active_cap_str = "glassBreaking", + notification_typ = Notification.notification_type.HOME_SECURITY, + on_event = Notification.event.home_security.GLASS_BREAKAGE, + off_event = Notification.event.home_security.STATE_IDLE + }, + [8] = { + profile = "aeotec-water-sensor-8-panic", + mock_device = mock_panic_sensor, + default_cap = capabilities.panicAlarm.panicAlarm.clear(), + active_cap = capabilities.panicAlarm.panicAlarm.panic(), + default_cap_str = "clear", + active_cap_str = "panic", + notification_typ = Notification.notification_type.EMERGENCY, + on_event = Notification.event.emergency.PANIC_ALERT, + off_event = Notification.event.emergency.STATE_IDLE + } +} + +local function test_init() + test.mock_device.add_test_device(mock_water_sensor) + test.mock_device.add_test_device(mock_smoke_sensor) + test.mock_device.add_test_device(mock_co_sensor) + test.mock_device.add_test_device(mock_co2_sensor) + test.mock_device.add_test_device(mock_contact_sensor) + test.mock_device.add_test_device(mock_contact_sensor) + test.mock_device.add_test_device(mock_motion_sensor) + test.mock_device.add_test_device(mock_glass_break_sensor) + test.mock_device.add_test_device(mock_panic_sensor) +end + +test.set_test_init_function(test_init) + +test.register_coroutine_test( + "Device added lifecycle event for profile", + function() + test.socket.device_lifecycle:__queue_receive({ mock_water_sensor.id, "added" }) + test.socket.zwave:__expect_send( + zw_test_utils.zwave_test_build_send_command( + mock_water_sensor, + Configuration:Get({ + parameter_number = 10 + }) + ) + ) + test.socket.capability:__expect_send( + mock_water_sensor:generate_test_message("main", capabilities.moldHealthConcern.supportedMoldValues({"good", "moderate"})) + ) + + test.socket.capability:__expect_send( + mock_water_sensor:generate_test_message("main", capabilities.moldHealthConcern.moldHealthConcern.good()) + ) + + test.socket.capability:__expect_send( + mock_water_sensor:generate_test_message("main", capabilities.powerSource.powerSource.battery()) + ) + + + test.socket.zwave:__expect_send( + zw_test_utils.zwave_test_build_send_command( + mock_water_sensor, + Battery:Get({}) + ) + ) + end +) + +test.register_message_test( + "Refresh should generate the correct commands", + { + { + channel = "capability", + direction = "receive", + message = { + mock_water_sensor.id, + { capability = "refresh", command = "refresh", args = {} } + } + }, + { + channel = "zwave", + direction = "send", + message = zw_test_utils.zwave_test_build_send_command( + mock_water_sensor, + Battery:Get({}) + ) + }, + }, + { + inner_block_ordering = "relaxed" + } +) + +test.register_message_test( + "Notification report STATE_IDLE event should be handled tamper alert state clear", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.HOME_SECURITY, + event = Notification.event.home_security.STATE_IDLE, + event_parameter = string.char(Notification.event.home_security.TAMPERING_PRODUCT_COVER_REMOVED) + })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.tamperAlert.tamper.clear()) + } + } +) + +test.register_coroutine_test( + "Notification report TAMPERING_PRODUCT_COVER_REMOVED event should be handled as tamperAlert detected", + function() + test.timer.__create_and_queue_test_time_advance_timer(10, "oneshot") + test.socket.zwave:__queue_receive( + { + mock_water_sensor.id, + zw_test_utils.zwave_test_build_receive_command( + Notification:Report( + { + notification_type = Notification.notification_type.HOME_SECURITY, + event = Notification.event.home_security.TAMPERING_PRODUCT_COVER_REMOVED + }) + ) + } + ) + test.socket.capability:__expect_send(mock_water_sensor:generate_test_message("main", capabilities.tamperAlert.tamper.detected())) + end +) + +test.register_message_test( + "Battery report should be handled", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Battery:Report({ battery_level = 0x63 })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.battery.battery(99)) + } + } +) + +test.register_message_test( + "Notification report AC_MAINS_DISCONNECTED event should be handled power source state battery", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.POWER_MANAGEMENT, + event = Notification.event.power_management.AC_MAINS_DISCONNECTED, + })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.powerSource.powerSource.battery()) + } + } +) + +test.register_message_test( + "Notification report AC_MAINS_RE_CONNECTED event should be handled power source state dc", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.POWER_MANAGEMENT, + event = Notification.event.power_management.AC_MAINS_RE_CONNECTED, + })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.powerSource.powerSource.dc()) + } + } +) + +test.register_message_test( + "Notification report POWER_HAS_BEEN_APPLIED event should be send battery get", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.POWER_MANAGEMENT, + event = Notification.event.power_management.POWER_HAS_BEEN_APPLIED, + })) } + }, + { + channel = "zwave", + direction = "send", + message = zw_test_utils.zwave_test_build_send_command( + mock_water_sensor, + Battery:Get({}) + ) + } + } +) + +test.register_message_test( + "Notification report LEAK_DETECTED event should be handled water sensor state wet", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.WATER, + event = Notification.event.water.LEAK_DETECTED, + })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.waterSensor.water.wet()) + } + } +) + +test.register_message_test( + "Notification report STATE_IDLE event should be handled water sensor state dry", + { + { + channel = "zwave", + direction = "receive", + message = { mock_water_sensor.id, zw_test_utils.zwave_test_build_receive_command(Notification:Report({ + notification_type = Notification.notification_type.WATER, + event = Notification.event.water.STATE_IDLE, + })) } + }, + { + channel = "capability", + direction = "send", + message = mock_water_sensor:generate_test_message("main", capabilities.waterSensor.water.dry()) + } + } +) + + +for param_value, data in pairs(DEVICE_PROFILES) do + local value = param_value + local profile = data.profile + local mock_device = data.mock_device + local default_cap = data.default_cap + local active_cap = data.active_cap + local notification_type = data.notification_typ + local on_event = data.on_event + local off_event = data.off_event + + + test.register_coroutine_test( + "Profile should update when Configuration Report parameter 10 = " .. value, + function() + test.socket.zwave:__queue_receive({ + mock_device.id, + Configuration:Report({ + parameter_number = 10, + configuration_value = value + }) + }) + + test.socket.device_lifecycle:__expect_send( + mock_device:expect_metadata_update({ + profile = profile + }) + ) + + if profile == "aeotec-water-sensor-8-glass-break" then + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", capabilities.soundDetection.supportedSoundTypes({"noSound", "glassBreaking"})) + ) + elseif profile == "aeotec-water-sensor-8-co2" then + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", capabilities.carbonDioxideHealthConcern.supportedCarbonDioxideValues({"good", "moderate"})) + ) + end + + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", default_cap) + ) + end + ) + + test.register_coroutine_test( + "Notification report type " .. notification_type .. " event ".. off_event .. " should be handled " .. data.default_cap_str, + function() + mock_device:set_field("active_profile", profile) + + test.socket.zwave:__queue_receive({ + mock_device.id, + Notification:Report({ + notification_type = notification_type, + event = off_event, + event_parameter = string.char(on_event) + }) + }) + + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", default_cap) + ) + end + ) + + test.register_coroutine_test( + "Notification report type " .. notification_type .. " event ".. on_event .. " should be handled " .. data.active_cap_str, + function() + mock_device:set_field("active_profile", profile) + + test.socket.zwave:__queue_receive({ + mock_device.id, + Notification:Report({ + notification_type = notification_type, + event = on_event, + }) + }) + + test.socket.capability:__expect_send( + mock_device:generate_test_message("main", active_cap) + ) + end + ) +end + +test.run_registered_tests() \ No newline at end of file