Skip to content

Commit

Permalink
[WWST-5069] Added FP and integrated Everpring Motion Sensor SP815 (Sm…
Browse files Browse the repository at this point in the history
…artThingsCommunity#31385)

* Added FP and integrated Everpring Motion Sensor SP815

* Changed minimum value for the Temp and Humidity Report

* Added requested fixes

Co-authored-by: Zuzanna Wozniak/Home IoT Development (IoT) /SRPOL/Engineer/Samsung Electronics <[email protected]>
  • Loading branch information
ZWozniakS and Zuzanna Wozniak/Home IoT Development (IoT) /SRPOL/Engineer/Samsung Electronics authored May 26, 2020
1 parent d87803e commit d2f4a1f
Showing 1 changed file with 139 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ metadata {
capability "Battery"
capability "Health Check"
capability "Tamper Alert"
capability "Configuration"

fingerprint mfr: "011F", prod: "0001", model: "0001", deviceJoinName: "Schlage Motion Sensor" // Schlage motion //Schlage Motion Sensor
fingerprint mfr: "014A", prod: "0001", model: "0001", deviceJoinName: "Ecolink Motion Sensor" // Ecolink motion //Ecolink Motion Sensor
fingerprint mfr: "014A", prod: "0004", model: "0001", deviceJoinName: "Ecolink Motion Sensor" // Ecolink motion + //Ecolink Motion Sensor
fingerprint mfr: "0060", prod: "0001", model: "0002", deviceJoinName: "Everspring Motion Sensor" // Everspring SP814 //Everspring Motion Sensor
fingerprint mfr: "0060", prod: "0001", model: "0003", deviceJoinName: "Everspring Motion Sensor" // Everspring HSP02 //Everspring Motion Sensor
fingerprint mfr: "0060", prod: "0001", model: "0005", deviceJoinName: "Everspring Motion Sensor" //Everspring SP817 //Everspring Motion Detector
fingerprint mfr: "0060", prod: "0001", model: "0006", deviceJoinName: "Everspring Motion Sensor" //Everspring Motion Detector
fingerprint mfr: "0060", prod: "0001", model: "0004", deviceJoinName: "Everspring Motion Sensor" //Everspring SP815 //Everspring Motion Detector
fingerprint mfr: "0060", prod: "0001", model: "0005", deviceJoinName: "Everspring Motion Sensor" //Everspring Motion Detector
fingerprint mfr: "0060", prod: "0001", model: "0006", deviceJoinName: "Everspring Motion Sensor" //Everspring SP817 //Everspring Motion Detector
fingerprint mfr: "011A", prod: "0601", model: "0901", deviceJoinName: "Enerwave Motion Sensor" // Enerwave ZWN-BPC //Enerwave Motion Sensor
fingerprint mfr: "0063", prod: "4953", model: "3133", deviceJoinName: "GE Motion Sensor" //GE Portable Smart Motion Sensor
fingerprint mfr: "0214", prod: "0003", model: "0002", deviceJoinName: "BeSense Motion Sensor" //BeSense Motion Detector
Expand Down Expand Up @@ -61,18 +63,57 @@ metadata {
main "motion"
details(["motion", "battery", "tamper"])
}
}

// Preferences for Everspring SP815 and Everspring SP817
// preferences {
section {
input(
title: "Settings Available For Everspring SP815 and SP817 only",
description: "",
type: "paragraph",
element: "paragraph"
)
input (
title: "Temperature and Humidity Auto Report (Everspring SP815 only):",
description: "This setting allows to adjusts report time (in seconds) of temperature and humidity report.",
name: "temperatureAndHumidityReport",
type: "number",
range: "600..1440",
defaultValue: 600
) // defaultValue: 600
input (
title: "Re-trigger Interval Setting (Everspring SP815 and Everspring SP817 only):",
description: "The setting adjusts the sleep period (in seconds) after the detector has been triggered. No response will be made during this interval if a movement is presented. Longer re-trigger interval will result in longer battery life.",
name: "retriggerIntervalSettings",
type: "number",
range: "10..3600",
defaultValue: 180
) // defaultValue: 180
}
}

def installed() {
// Device wakes up every 4 hours, this interval allows us to miss one wakeup notification before marking offline
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
sendEvent(name: "tamper", value: "clear", displayed: false)
response(initialPoll())
}

def updated() {
log.debug "updated"
// Device wakes up every 4 hours, this interval allows us to miss one wakeup notification before marking offline
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
response(getConfigurationCommands())
}

def configure() {
if (isEverspringSP815orSP817()) {
state.configured = false
state.intervalConfigured = false
if(isEverspringSP815()){
state.temperatureConfigured = false
}
}
response(initialPoll())
}

private getCommandClassVersions() {
Expand Down Expand Up @@ -153,6 +194,11 @@ def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cm
def value = cmd.v1AlarmLevel == 255 ? "active" : cmd.v1AlarmLevel ?: "inactive"
result << createEvent(name: "alarm $cmd.v1AlarmType", value: value, isStateChange: true, displayed: false)
}

log.debug "isConfigured: ${isConfigured()}"
if (isEverspringSP815orSP817() && !isConfigured()) {
result += lateConfigure()
}
result
}

Expand All @@ -164,6 +210,10 @@ def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)
{
def result = [createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)]

if (isEverspringSP815orSP817() && !isConfigured()) {
result += lateConfigure(true)
}

if (isEnerwave() && device.currentState('motion') == null) { // Enerwave motion doesn't always get the associationSet that the hub sends on join
result << response(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId))
}
Expand Down Expand Up @@ -279,9 +329,13 @@ def initialPoll() {
if (isEnerwave()) { // Enerwave motion doesn't always get the associationSet that the hub sends on join
request << zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId)
}
if (isEverspringSP815orSP817()) {
request += getConfigurationCommands()
}
request << zwave.batteryV1.batteryGet()
request << zwave.sensorBinaryV2.sensorBinaryGet(sensorType: 0x0C) //motion
request << zwave.notificationV3.notificationGet(notificationType: 0x07, event: 0x08) //motion for Everspiring
log.debug "Request is: ${request}"
commands(request) + ["delay 20000", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]
}

Expand All @@ -300,6 +354,87 @@ private command(physicalgraph.zwave.Command cmd) {
}
}

def getConfigurationCommands() {
log.debug "getConfigurationCommands"
def result = []
if (isEverspringSP815()) {
if (!state.temperatureAndHumidityReport) state.temperatureAndHumidityReport = getEverspringDefaults[1]
if (!state.retriggerIntervalSettings) state.retriggerIntervalSettings = getEverspringDefaults[2]

Integer temperatureAndHumidityReport = (settings.temperatureAndHumidityReport as Integer) ?: everspringDefaults[1]
Integer retriggerIntervalSettings = (settings.retriggerIntervalSettings as Integer) ?: everspringDefaults[2]

if (!isConfigured() || (temperatureAndHumidityReport != state.temperatureAndHumidityReport || retriggerIntervalSettings != state.retriggerIntervalSettings)) {
state.configured = false // this flag needs to be set to false when settings are changed (and the device was initially configured before)
if (!state.temperatureConfigured || temperatureAndHumidityReport != state.temperatureAndHumidityReport) {
state.temperatureConfigured = false
result << zwave.configurationV2.configurationSet(parameterNumber: 1, size: 2, scaledConfigurationValue: temperatureAndHumidityReport)
result << zwave.configurationV2.configurationGet(parameterNumber: 1)
}
if (!state.intervalConfigured || retriggerIntervalSettings != state.retriggerIntervalSettings) {
state.intervalConfigured = false
result << zwave.configurationV2.configurationSet(parameterNumber: 2, size: 2, scaledConfigurationValue: retriggerIntervalSettings)
result << zwave.configurationV2.configurationGet(parameterNumber: 2)
}
}
} else if (isEverspringSP817()) {
if (!state.retriggerIntervalSettings) state.retriggerIntervalSettings = everspringDefaults[2]
Integer retriggerIntervalSettings = (settings.retriggerIntervalSettings as Integer) ?: everspringDefaults[2]
if (!isConfigured() || (retriggerIntervalSettings != state.retriggerIntervalSettings)) {
state.configured = false
if (!state.intervalConfigured || retriggerIntervalSettings != state.retriggerIntervalSettings) {
state.intervalConfigured = false
result << zwave.configurationV2.configurationSet(parameterNumber: 4, size: 2, scaledConfigurationValue: retriggerIntervalSettings)
result << zwave.configurationV2.configurationGet(parameterNumber: 4)
}
}
}
return result
}

def getEverspringDefaults() {
[1: 600,
2: 180]
}

def lateConfigure() {
log.debug "lateConfigure"
sendHubCommand(commands(getConfigurationCommands(),200))
}

private isConfigured() {
return state.configured == true
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {
if (isEverspringSP815orSP817()) {
if (cmd.parameterNumber == 1) {
state.temperatureAndHumidityReport = scaledConfigurationValue
state.temperatureConfigured = true
} else if ((isEverspringSP815() && cmd.parameterNumber == 2) || (isEverspringSP817() && cmd.parameterNumber == 4)) {
state.retriggerIntervalSettings = scaledConfigurationValue
state.intervalConfigured = true
}
if (state.intervalConfigured == true && (isEverspringSP817() || (isEverspringSP815() && state.temperatureConfigured== true))) {
state.configured = true
}
log.debug "Everspring Configuration Report: ${cmd}"
return [:]
}
}

private isEnerwave() {
zwaveInfo?.mfr?.equals("011A") && zwaveInfo?.prod?.equals("0601") && zwaveInfo?.model?.equals("0901")
}

private isEverspringSP815() {
zwaveInfo?.mfr?.equals("0060") && zwaveInfo?.model?.equals("0004")
}

private isEverspringSP817() {
zwaveInfo?.mfr?.equals("0060") && zwaveInfo?.model?.equals("0006")
}

private isEverspringSP815orSP817() {
zwaveInfo?.mfr?.equals("0060") && (zwaveInfo?.model?.equals("0004") || zwaveInfo?.model?.equals("0006"))
}

0 comments on commit d2f4a1f

Please sign in to comment.