SmartThings Community

Fibaro binary input (Dual contact and temperature sensor)


(Borristhecat) #21

What can’t you get working? If your trying to do the temperature have you installed it in the correct order?

You need to exclude the binary device then install the temperature sensors, then add the device too ST. Once you done that you can then install the DH and then click configure and it should work.


(cjcharles) #22

Hi @borristhecat I have finally had the time to test my coding. Have made quite a lot of changes tbh so while I have done some testing it would be great if you could have a quick test too and let me know feedback before I release a version 1 of it. After adding the child devices (by ticking the flag in configuration menu), it should create the child devices, and you can then rename them as you wish.

Sadly as I have used ST’s default simulated devices I dont have control of the colours or styling, and I think they are out of sync with what ST now recommend as the official ST style, but not by much.

/**
 *  Device Type Definition File
 *
 *  Device Type:		Fibaro UBS - Dual Contact and Temperature Sensor
 *  File Name:			Fibaro UBS - Dual Contact and Temperature Sensor.groovy
 *	Initial Release:	2017-11-07
 *	Author:				Chris Charles
 *
 *  Copyright 2017 Chris Charles, based on original code by carlos.ir33, modified
 *  by Stuart Buchanan and Paul Crookes
 *
 ***************************************************************************************
 */
 
metadata {
	definition (name: "Fibaro UBS", namespace: "cjcharles0", author: "Chris Charles") {
    
    capability "Contact Sensor"
	capability "Motion Sensor"
    capability "Sensor"
	capability "Temperature Measurement"
    capability "Configuration"
    
    command "removeChildDevices"
    command "updateCurrentParams"
    command "listCurrentParams"
    command "open1"
    command "open2"
    command "close1"
    command "close2"
	
	fingerprint deviceId: "0x2001", inClusters: "0x30 0x60 0x85 0x8E 0x72 0x70 0x86 0x7A 0xEF"
}

simulator {
}

tiles(scale: 2) {
	standardTile("contact1", "device.contact1", width: 3, height: 2) {
		state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#e86d13", action: "close1"
		state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00a0dc", action: "open1"
	}
	standardTile("contact2", "device.contact2", width: 3, height: 2) {
		state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#e86d13", action: "close2"
		state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00a0dc", action: "open2"
	}
	
	standardTile("temp1text", "temp1text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 1:', action:"", icon:""
	}
	standardTile("temp2text", "temp2text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 2:', action:"", icon:""
	}
	standardTile("temp3text", "temp3text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 3:', action:"", icon:""
	}
	standardTile("temp4text", "temp4text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 4:', action:"", icon:""
	}
	valueTile("temperature1", "temperature1", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C"//, backgroundColor:"#fab907"//, icon:"st.Weather.weather2"
    }
	valueTile("temperature2", "temperature2", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C"//, backgroundColor:"#fab907"//, icon:"st.Weather.weather2"
    }
	valueTile("temperature3", "temperature3", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C"//, backgroundColor:"#fab907"//, icon:"st.Weather.weather2"
    }
    valueTile("temperature4", "temperature4", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C"//, backgroundColor:"#fab907"//, icon:"st.Weather.weather2"
    }
    
	standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "configure", label:'Send Config', action:"configuration.configure", icon:"st.secondary.configure"
	}

	standardTile("report", "device.configure", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "report", label:'List Config', action:"listCurrentParams"
	}
    
    standardTile("removechildren", "removechildren", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Remove Child Devices', action:"removeChildDevices"
	}
}

main(["contact1"]) //, "contact2"
details(["contact1","contact2",
		"temp1text", "temperature1", "temp2text", "temperature2",
        "temp3text", "temperature3", "temp4text", "temperature4",
        "configure", "report", "removechildren"])

preferences {
        def paragraph = "Device Handler by @cjcharles \n\n"
        input("childcontact1", "bool", title: paragraph + "Create Child Contact1 Device?", required:false, displayDuringSetup: true)
        input("childcontact2", "bool", title:"Create Child Contact2 Device?", required:false, displayDuringSetup: true)

		paragraph = "Parameter Settings:\n\n"
        input name: "param1", type: "number", range: "0..65535", required: false, //defaultValue: "0",
            title: paragraph + "Parameter No. 1 - Input 1 Alarm Cancellation Delay. \n" +
                   "Additional delay after an alarm from input 1 has ceased.\n" +
                   "Time in seconds to delay the ceasing event.\n" +
                   "Default value: 0."
       
        input name: "param2", type: "number", range: "0..65535", required: false, //defaultValue: "0",
            title: "Parameter No. 2 - Input 2 Alarm Cancellation Delay. \n" +
                   "Additional delay after an alarm from input 2 has ceased.\n" +
                   "Time in seconds to delay the ceasing event.\n" +
                   "Default value: 0."
       
        input name: "param3", type: "number", range: "0..3", required: false, //defaultValue: "1",
            title: "Parameter No. 3 - Type of Input No 1." +
                   "Available settings:\n" +
                   "0 – INPUT_NO (Normal Open)\n" +
				   "1 – INPUT_NC (Normal Close)\n" +
				   "2 – INPUT_MONOSTABLE\n" +
				   "3 – INPUT_BISTABLE\n" +
                   "Default value: 1."

		input name: "param4", type: "number", range: "0..3", required: false, //defaultValue: "1",
            title: "Parameter No. 4 - Type of Input No 2." +
                   "Available settings:\n" +
                   "0 – INPUT_NO (Normal Open)\n" +
				   "1 – INPUT_NC (Normal Close)\n" +
				   "2 – INPUT_MONOSTABLE\n" +
				   "3 – INPUT_BISTABLE\n" +
                   "Default value: 1."

		input name: "param5", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 5 - Type of transmitted control or alarm frame for association group 1." +
                   "Available settings:\n" +
				   "0 – Frame ALARM GENERIC\n" +
				   "1 – Frame ALARM SMOKE\n" +
				   "2 – Frame ALARM CO\n" +
				   "3 – Frame ALARM CO2\n" +
				   "4 – Frame ALARM HEAT\n" +
				   "5 – Frame ALARM WATER\n" +
				   "255 – Control frame BASIC_SET\n" +
                   "Default value: 255."

		input name: "param6", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 6 - Type of transmitted control or alarm frame for association group 2." +
                   "Available settings:\n" +
				   "0 – Frame ALARM GENERIC\n" +
				   "1 – Frame ALARM SMOKE\n" +
				   "2 – Frame ALARM CO\n" +
				   "3 – Frame ALARM CO2\n" +
				   "4 – Frame ALARM HEAT\n" +
				   "5 – Frame ALARM WATER\n" +
				   "255 – Control frame BASIC_SET\n" +
                   "Default value: 255."

		input name: "param7", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 7 - Value of the parameter specifying the forced level of dimming / opening sun blinds when " +
            	   "sent a “switch on” / ”open” command from association group no. 1.\n" +
                   "Available settings:\n" +
                   "0-99 - Dimming or Opening Percentage\n" +
                   "255 - Last set percentage\n" +
                   "Default value: 255."

		input name: "param8", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 8 - Value of the parameter specifying the forced level of dimming / opening sun blinds when " +
            	   "sent a “switch on” / ”open” command from association group no. 2.\n" +
                   "Available settings:\n" +
                   "0-99 - Dimming or Opening Percentage\n" +
                   "255 - Last set percentage\n" +
                   "Default value: 255."

		input name: "param9", type: "number", range: "0..3", required: false, //defaultValue: "0",
            title: "Parameter No. 9 - Deactivating transmission of the frame cancelling the alarm or the " +
				   "control frame deactivating the device (Basic). Disable the alarm cancellation function.\n" +
                   "Available settings:\n" +
                   "0 – Cancellation sent for association group 1 and 2\n" +
				   "1 – Cancellation sent for association group 1 only\n" +
				   "2 – Cancellation sent for association group 2 only\n" +
				   "3 - Not sent for association group 1 or 2\n" +
                   "Default value: 0."

		input name: "param10", type: "number", range: "1..255", required: false, //defaultValue: "20",
            title: "Parameter No. 10 - Interval between successive readings of temperature from all " +
				   "sensors connected to the device. (A reading does not result in sending to ST)\n" +
                   "Available settings:\n" +
                   "1-255 - Seconds between readings\n" +
                   "Default value: 20."

		input name: "param11", type: "number", range: "0..255", required: false, //defaultValue: "200",
            title: "Parameter No. 11 - Interval between forcing to send report of the temperature. " +
				   "The forced report is sent immediately after the next temperature reading, " +
				   "irrespective of parameter 12. Advised to be 200 unless rapid temperature changes are expected.\n" +
                   "Available settings:\n" +
                   "0 - Deactivate temperature sending\n" +
                   "1-255 - Seconds between sends\n" +
                   "Default value: 200."

		input name: "param12", type: "number", range: "0..255", required: false, //defaultValue: "8",
            title: "Parameter No. 12 - Insensitiveness to temperature changes. This is the maximum " +
				   "difference between the last reported temperature and the current temperature. " +
				   "If they differ by more than this then a report is sent.\n" +
                   "Available settings:\n" +
                   "0-255 - x/16 = temp diff in C\n" +
                   "x/80*9 = temp diff in F\n" +
                   "Default value: 8 (0.5oC)."

		input name: "param13", type: "number", range: "0..3", required: false, //defaultValue: "0",
            title: "Parameter No. 13 - Transmitting the alarm or control frame in “broadcast” mode (i.e. to " +
				   "all devices within range), this information is not repeated by the mesh network." +
                   "Available settings:\n" +
                   "0 - IN1 and IN2 broadcast inactive,\n" +
                   "1 - IN1 broadcast mode active only,\n" +
                   "2 - IN2 broadcast mode active only,\n" +
                   "3 - INI and IN2 broadcast mode active.\n" +
                   "Default value: 0."

		input name: "param14", type: "number", range: "0..1", required: false, //defaultValue: "0",
            title: "Parameter No. 14 - Scene activation functionality." +
                   "Available settings:\n" +
                   "0 - Deactivated functionality,\n" +
                   "1 - Activated functionality.\n" +
                   "Default value: 0."
	}
}

def installed() {
	log.debug "installed()"
}
def updated() {
	log.debug "updated()"
	createChildDevices()
}
def uninstalled() {
    log.debug "uninstalled()"
    removeChildDevices()
}

def configure() {
	log.debug "configure"
    delayBetween([
	zwave.multiChannelAssociationV2.multiChannelAssociationSet(groupingIdentifier:2, nodeId:[zwaveHubNodeId]).format(),
	zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format(),
	zwave.associationV1.associationRemove(groupingIdentifier:1, nodeId:zwaveHubNodeId).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 1, configurationValue:[param1.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 2, configurationValue:[param2.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 3, configurationValue:[param3.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 4, configurationValue:[param4.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 5, configurationValue:[param5.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 6, configurationValue:[param6.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 7, configurationValue:[param7.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 8, configurationValue:[param8.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 9, configurationValue:[param9.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 10, configurationValue:[param10.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 11, configurationValue:[param11.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 12, configurationValue:[param12.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 13, configurationValue:[param13.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 14, configurationValue:[param14.value]).format(),
    ], 500)
}

private void createChildDevices(){
	log.debug "Adding Child Devices if they are configured"
    if (childcontact1) {
    	log.debug "Creating Contact1 child"
        try {
        	def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (currentchild == null) {
            	addChildDevice("smartthings/testing", "Simulated Contact Sensor", "${device.deviceNetworkId}-contact1", device.hub.id, //cjcharles0 Visonic Contact Zone
                  [completedSetup: true, name: "${device.displayName} (Contact1)", label: "${device.displayName} (Contact1)", isComponent: false])
            }
        } catch (e) {
			log.debug "Error adding Contact1 child: ${e}"
        }
    }
    if (childcontact2) {
    	log.debug "Creating Contact2 child"
        try {
        	def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (currentchild == null) {
            	addChildDevice("smartthings/testing", "Simulated Contact Sensor", "${device.deviceNetworkId}-contact2", device.hub.id, //cjcharles0 - Visonic Contact Zone
                  [completedSetup: true, name: "${device.displayName} (Contact2)", label: "${device.displayName} (Contact2)", isComponent: false])
            }
        } catch (e) {
			log.debug "Error adding Contact2 child: ${e}"
        }
    }
}
private removeChildDevices(){
	log.debug "Removing Child Devices"
    try {
        getChildDevices()?.each {
            deleteChildDevice(it.deviceNetworkId)
        }
    } catch (e) {
        log.debug "Error deleting ${it}, either it didn't exist or probably locked into a SmartApps: ${e}"
    }
}

def parse(String description) {
	def result = null
	def cmd = zwave.parse(description, [ 0x60: 3])
	if (cmd) {
		result = zwaveEvent(cmd)
	}
	log.debug "parsed '$description' to result: ${result}"
	return result
}

def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv1.ManufacturerSpecificReport cmd) {
	log.debug("ManufacturerSpecificReport ${cmd.inspect()}")
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
	log.debug("ConfigurationReport ${cmd.inspect()}")
}

def createEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd, Map item1) { 
	log.debug "manufacturerId:   ${cmd.manufacturerId}"
    log.debug "manufacturerName: ${cmd.manufacturerName}"
    log.debug "productId:        ${cmd.productId}"
    log.debug "productTypeId:    ${cmd.productTypeId}"

}

def createEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd, Map item1) {	
    updateDataValue("applicationVersion", "${cmd.applicationVersion}")
    log.debug "applicationVersion:      ${cmd.applicationVersion}"
    log.debug "applicationSubVersion:   ${cmd.applicationSubVersion}"
    log.debug "zWaveLibraryType:        ${cmd.zWaveLibraryType}"
    log.debug "zWaveProtocolVersion:    ${cmd.zWaveProtocolVersion}"
    log.debug "zWaveProtocolSubVersion: ${cmd.zWaveProtocolSubVersion}"
}

def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
	log.debug "BasicSet V1 ${cmd.inspect()}"
    def currentstate
	if (cmd.value) {
		currentstate = "open"
	} else {
    	currentstate = "closed"
	}
    createEvent(name: "contact1", value: currentstate, descriptionText: "${device.displayName} is ${currentstate}")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: currentstate)
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
    }
}

def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap cmd) {
	log.debug "ZWaveEvent V3 ${cmd.inspect()}"
	def result
	if (cmd.commandClass == 32) {
    	def currentcontact
        def currentstate
		if (cmd.parameter == [0]) {
        	currentstate = "closed"
			if (cmd.sourceEndPoint == 1) {
            	currentcontact = "contact1"
				//result = createEvent(name: "contact1", value: "closed", descriptionText: "$device.displayName is closed")
				//log.debug "Contact1 is closed"
			}
			else
			if (cmd.sourceEndPoint == 2) {
            	currentcontact = "contact2"
				//result = createEvent(name: "contact2", value: "closed", descriptionText: "$device.displayName is closed")
				//log.debug "Contact2 is closed"
			}
		}
		if (cmd.parameter == [255]) {
        	currentstate = "open"
			if (cmd.sourceEndPoint == 1) {
				currentcontact = "contact1"
                //result = createEvent(name: "contact1", value: "open", descriptionText: "$device.displayName is open")
				//log.debug "Contact1 is open"
			}
			else
			if (cmd.sourceEndPoint == 2) {
				currentcontact = "contact2"
                //result = createEvent(name: "contact2", value: "open", descriptionText: "$device.displayName is open")
				//log.debug "Contact2 is open"
			}
		}
        log.debug "${currentcontact} is ${currentstate}"
        sendEvent(name: currentcontact, value: currentstate, descriptionText: "$device.displayName - ${currentcontact} is ${currentstate}")
        if (childcontact1 && (currentcontact == "contact1")) {
            try {
                def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-${currentcontact}"}
                if (childDevice)
                    childDevice.sendEvent(name: "contact", value: currentstate)
            } catch (e) {
                log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
            }
    	}
        if (childcontact2 && (currentcontact == "contact2")) {
            try {
                def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-${currentcontact}"}
                if (childDevice)
                    childDevice.sendEvent(name: "contact", value: currentstate)
            } catch (e) {
                log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
            }
    	}
    } else {
		def encapsulatedCommand = cmd.encapsulatedCommand([0x31: 2, 0x60: 3, 0x85: 2, 0x8E: 2, 0x72: 1, 0x70: 1, 0x86: 1, 0x7A: 1, 0xEF: 1, 0x2B: 1]) // can specify command class versions here like in zwave.parse
		log.debug ("Command from endpoint ${cmd.sourceEndPoint}: ${encapsulatedCommand}")
		if (encapsulatedCommand) {
			result = zwaveEvent(encapsulatedCommand)
		}
	}
    return result
}

def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd)
{
	log.debug "Sensor MultiLevel Report - Sensor Type = ${cmd.sensorType}"
	switch (cmd.sensorType) {
		case 1:
			// temperature
			def cmdScale = cmd.scale == 1 ? "F" : "C"
			def tempval = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision).toDouble().round(1)
            sendEvent(name: "temperature1", value: tempval, displayed: false) //unit: getTemperatureScale()
			break;
	}
    log.debug map
	createEvent(map)
}

def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv1.SensorMultilevelReport cmd) {
    log.debug "SensorMultilevelReport $cmd"
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
	// This will capture any commands not handled by other instances of zwaveEvent
	// and is recommended for development so you can see every command the device sends
	log.debug "Catchall reached for cmd: ${cmd.toString()}}"
	return createEvent(descriptionText: "${device.displayName}: ${cmd}")
}

def listCurrentParams() {
	log.debug "Listing of current parameter settings of ${device.displayName}"
    def cmds = []
	cmds << zwave.multiChannelAssociationV2.multiChannelAssociationGet(groupingIdentifier:2).format()
	cmds << zwave.associationV2.associationGet(groupingIdentifier: 3).format()
	cmds << zwave.associationV1.associationGet(groupingIdentifier: 1).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 1).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 2).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 3).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 4).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 5).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 6).format()
    cmds << zwave.configurationV1.configurationGet(parameterNumber: 7).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 8).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 9).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 10).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 11).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 12).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 13).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 14).format()
	delayBetween(cmds, 500)
}


def open1() {
    sendEvent(name: "contact1", value: "open", descriptionText: "$device.displayName (1) is opened manually")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "open")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def close1() {
    sendEvent(name: "contact1", value: "closed", descriptionText: "$device.displayName (1) is closed manually")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "closed")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def open2() {
    sendEvent(name: "contact2", value: "open", descriptionText: "$device.displayName (2) is opened manually")
    if (childcontact2) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "open")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def close2() {
    sendEvent(name: "contact2", value: "closed", descriptionText: "$device.displayName (2) is closed manually")
    if (childcontact2) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "closed")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

(cjcharles) #23

@anonino.norely - I agree with Borris, I expect that you need to exclude (through the ST dashboard) the UBS and then repair it, since it seems like the contact/motion sensors are working but the temperatures are coming back blank…


(Anon) #24

Device excluded and included again, but temperature sensors doesn’t work… How can I do a debug?

When I send config from ST…


(cjcharles) #25

Can you try filling in the values for every config parameter with the defaults. That should fix it, meanwhile I will look to fix that!

Despite this, it wont fix your temperature not appearing sadly. Are they all connected to the correct three cables of the UBS?


(Borristhecat) #26

Brilliant, no worries I’ll give it a try and let you know :grin:


(Anon) #27

Hi,

I’m trying but no luck… I installed four new temperature sensors DSB18B20, exclude, include, change device handler, but temperature don’t show, contact sensors works well.

GND -> UBS BLUE
VDD -> UBS BROWN
DATA -> UBS WHITE

ds18b20-waterproof 2-500x416




(cjcharles) #28

Are the wires just the length that you can see in the picture? I.e. they arent extended too far inside a cavity or something.

Also does it show any differences in behaviour when only one sensor is plugged in, rather than 4?

Have you tried power cycling the UBS? I know its a silly statement, but perhaps it needs a power cycle aswell as exclude/include. It certainly seems the problem is on the UBS end since the DTH never receives any temperature information according to those logs.


(Anon) #29

Yes, cable length is 1 meter. Same behavior with one or four sensors, several factory resets, include, exclude.

I will test the same UBS on a Fibaro HC2 on Friday.


(Anon) #30

Hi,

I bought a new UBS and 4 new DSB18B20. I repeated the entire installation process, it shows the temperature of only one probe.

Any ideas ?

Thanks!.



(cjcharles) #31

Ah cool you got it working!

Was it just a case of going through the setup one more time?

As for only slowing one temperature, that is a bug of mine, I’ll try and fix it in the next day or two, it’s an easy fix but I couldn’t test it as I only have one sensor connected.


(Borristhecat) #32

Got it all going and it works brilliant thanks!
The things I noticed is I dont see the temperature updating in the IDE logs?
In webCoRE the attributes come up as a contact and motion rather than 2 contacts?
Personally I would prefer to see the temperature as the master so when you see the devices in the app you can quickly see the temperature.

This DH is without a doubt the best one I have seen for the UBS, so for other users is it possible to be able select 2 contacts or a motion sensor and a contact in the option settings or something?

Had a look though the code so am I right in saying it essentially pull the DH from ST library? so if they update it it would update them anyway?


(Borristhecat) #33

I made a few changes that means you can use it directly in webCoRE with out the the need of the child devices, what do you think? The CC is just in reference to 2 contacts as i also going to try and make a contact and motion one. But Im hoping you will be able to combine them and create a option for the two in the parameter menu or something? Then with the 2 combo it will create child devices when needed ie contact, motion and temp but if you don’t need them ie just one contact you wont need it :smile:

/**
 *  Device Type Definition File
 *
 *  Device Type:		Fibaro UBS (CC) - Dual Contact and Temperature Sensor
 *  File Name:			Fibaro UBS (CC) - Dual Contact and Temperature Sensor.groovy
 *	Initial Release:	2017-11-07
 *	Author:				Chris Charles
 *
 *  Copyright 2017 Chris Charles, based on original code by carlos.ir33, modified
 *  by Stuart Buchanan and Paul Crookes
 *
 ***************************************************************************************
 */
 
metadata {
	definition (name: "Fibaro UBS (CC)", namespace: "cjcharles0", author: "Chris Charles") {
    
    capability "Contact Sensor"
 	capability "Motion Sensor"
    capability "Sensor"
	capability "Temperature Measurement"
    capability "Configuration"
    
      
    command "removeChildDevices"
    command "updateCurrentParams"
    command "listCurrentParams"
    command "open1"
    command "open2"
    command "close1"
    command "close2"
    
    attribute "contact1","enum",["open1","close1"]
    attribute "contact2","enum",["open2","close2"]
	
	fingerprint type: "2001", cc: "30,60,85,8E,72,70,86,7A,EF"
}

simulator {
}

tiles(scale: 2) {
	standardTile("contact1", "device.contact1", width: 3, height: 2) {
		state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#e86d13", action: "close1"
		state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00a0dc", action: "open1"
	}
	standardTile("contact2", "device.contact2", width: 3, height: 2) {
		state "open", label: '${name}', icon: "st.contact.contact.open", backgroundColor: "#e86d13", action: "close2"
		state "closed", label: '${name}', icon: "st.contact.contact.closed", backgroundColor: "#00a0dc", action: "open2"
	}
	
	standardTile("temp1text", "temp1text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 1:', action:"", icon:""
	}
	standardTile("temp2text", "temp2text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 2:', action:"", icon:""
	}
	standardTile("temp3text", "temp3text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 3:', action:"", icon:""
	}
	standardTile("temp4text", "temp4text", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Temp 4:', action:"", icon:""
	}
	valueTile("temperature1", "temperature1", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C", backgroundColor:"#fab907", icon:"st.Weather.weather2"
    }
	valueTile("temperature2", "temperature2", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C", backgroundColor:"#fab907", icon:"st.Weather.weather2"
    }
	valueTile("temperature3", "temperature3", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C", backgroundColor:"#fab907", icon:"st.Weather.weather2"
    }
    valueTile("temperature4", "temperature4", width:1, height:1, decoration: "flat") {
		state "default", label:'${currentValue}°', unit:"C", backgroundColor:"#fab907", icon:"st.Weather.weather2"
    }
    
	standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "configure", label:'Send Config', action:"configuration.configure", icon:"st.secondary.configure"
	}

	standardTile("report", "device.configure", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "report", label:'List Config', action:"listCurrentParams"
	}
    
    standardTile("removechildren", "removechildren", inactiveLabel: false, decoration: "flat", width: 2, height: 1) {
		state "default", label:'Remove Child Devices', action:"removeChildDevices"
	}
}

main(["temperature1"]) //, "contact2"
details(["contact1","contact2",
		"temp1text", "temperature1", "temp2text", "temperature2",
        "temp3text", "temperature3", "temp4text", "temperature4",
        "configure", "report", "removechildren"])

preferences {
        def paragraph = "Device Handler by @cjcharles \n\n"
        input("childcontact1", "bool", title: paragraph + "Create Child Contact1 Device?", required:false, displayDuringSetup: true)
        input("childcontact2", "bool", title:"Create Child Contact2 Device?", required:false, displayDuringSetup: true)

		paragraph = "Parameter Settings:\n\n"
        input name: "param1", type: "number", range: "0..65535", required: false, //defaultValue: "0",
            title: paragraph + "Parameter No. 1 - Input 1 Alarm Cancellation Delay. \n" +
                   "Additional delay after an alarm from input 1 has ceased.\n" +
                   "Time in seconds to delay the ceasing event.\n" +
                   "Default value: 0."
       
        input name: "param2", type: "number", range: "0..65535", required: false, //defaultValue: "0",
            title: "Parameter No. 2 - Input 2 Alarm Cancellation Delay. \n" +
                   "Additional delay after an alarm from input 2 has ceased.\n" +
                   "Time in seconds to delay the ceasing event.\n" +
                   "Default value: 0."
       
        input name: "param3", type: "number", range: "0..3", required: false, //defaultValue: "1",
            title: "Parameter No. 3 - Type of Input No 1." +
                   "Available settings:\n" +
                   "0 – INPUT_NO (Normal Open)\n" +
				   "1 – INPUT_NC (Normal Close)\n" +
				   "2 – INPUT_MONOSTABLE\n" +
				   "3 – INPUT_BISTABLE\n" +
                   "Default value: 1."

		input name: "param4", type: "number", range: "0..3", required: false, //defaultValue: "1",
            title: "Parameter No. 4 - Type of Input No 2." +
                   "Available settings:\n" +
                   "0 – INPUT_NO (Normal Open)\n" +
				   "1 – INPUT_NC (Normal Close)\n" +
				   "2 – INPUT_MONOSTABLE\n" +
				   "3 – INPUT_BISTABLE\n" +
                   "Default value: 1."

		input name: "param5", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 5 - Type of transmitted control or alarm frame for association group 1." +
                   "Available settings:\n" +
				   "0 – Frame ALARM GENERIC\n" +
				   "1 – Frame ALARM SMOKE\n" +
				   "2 – Frame ALARM CO\n" +
				   "3 – Frame ALARM CO2\n" +
				   "4 – Frame ALARM HEAT\n" +
				   "5 – Frame ALARM WATER\n" +
				   "255 – Control frame BASIC_SET\n" +
                   "Default value: 255."

		input name: "param6", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 6 - Type of transmitted control or alarm frame for association group 2." +
                   "Available settings:\n" +
				   "0 – Frame ALARM GENERIC\n" +
				   "1 – Frame ALARM SMOKE\n" +
				   "2 – Frame ALARM CO\n" +
				   "3 – Frame ALARM CO2\n" +
				   "4 – Frame ALARM HEAT\n" +
				   "5 – Frame ALARM WATER\n" +
				   "255 – Control frame BASIC_SET\n" +
                   "Default value: 255."

		input name: "param7", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 7 - Value of the parameter specifying the forced level of dimming / opening sun blinds when " +
            	   "sent a “switch on” / ”open” command from association group no. 1.\n" +
                   "Available settings:\n" +
                   "0-99 - Dimming or Opening Percentage\n" +
                   "255 - Last set percentage\n" +
                   "Default value: 255."

		input name: "param8", type: "number", range: "0..255", required: false, //defaultValue: "255",
            title: "Parameter No. 8 - Value of the parameter specifying the forced level of dimming / opening sun blinds when " +
            	   "sent a “switch on” / ”open” command from association group no. 2.\n" +
                   "Available settings:\n" +
                   "0-99 - Dimming or Opening Percentage\n" +
                   "255 - Last set percentage\n" +
                   "Default value: 255."

		input name: "param9", type: "number", range: "0..3", required: false, //defaultValue: "0",
            title: "Parameter No. 9 - Deactivating transmission of the frame cancelling the alarm or the " +
				   "control frame deactivating the device (Basic). Disable the alarm cancellation function.\n" +
                   "Available settings:\n" +
                   "0 – Cancellation sent for association group 1 and 2\n" +
				   "1 – Cancellation sent for association group 1 only\n" +
				   "2 – Cancellation sent for association group 2 only\n" +
				   "3 - Not sent for association group 1 or 2\n" +
                   "Default value: 0."

		input name: "param10", type: "number", range: "1..255", required: false, //defaultValue: "20",
            title: "Parameter No. 10 - Interval between successive readings of temperature from all " +
				   "sensors connected to the device. (A reading does not result in sending to ST)\n" +
                   "Available settings:\n" +
                   "1-255 - Seconds between readings\n" +
                   "Default value: 20."

		input name: "param11", type: "number", range: "0..255", required: false, //defaultValue: "200",
            title: "Parameter No. 11 - Interval between forcing to send report of the temperature. " +
				   "The forced report is sent immediately after the next temperature reading, " +
				   "irrespective of parameter 12. Advised to be 200 unless rapid temperature changes are expected.\n" +
                   "Available settings:\n" +
                   "0 - Deactivate temperature sending\n" +
                   "1-255 - Seconds between sends\n" +
                   "Default value: 200."

		input name: "param12", type: "number", range: "0..255", required: false, //defaultValue: "8",
            title: "Parameter No. 12 - Insensitiveness to temperature changes. This is the maximum " +
				   "difference between the last reported temperature and the current temperature. " +
				   "If they differ by more than this then a report is sent.\n" +
                   "Available settings:\n" +
                   "0-255 - x/16 = temp diff in C\n" +
                   "x/80*9 = temp diff in F\n" +
                   "Default value: 8 (0.5oC)."

		input name: "param13", type: "number", range: "0..3", required: false, //defaultValue: "0",
            title: "Parameter No. 13 - Transmitting the alarm or control frame in “broadcast” mode (i.e. to " +
				   "all devices within range), this information is not repeated by the mesh network." +
                   "Available settings:\n" +
                   "0 - IN1 and IN2 broadcast inactive,\n" +
                   "1 - IN1 broadcast mode active only,\n" +
                   "2 - IN2 broadcast mode active only,\n" +
                   "3 - INI and IN2 broadcast mode active.\n" +
                   "Default value: 0."

		input name: "param14", type: "number", range: "0..1", required: false, //defaultValue: "0",
            title: "Parameter No. 14 - Scene activation functionality." +
                   "Available settings:\n" +
                   "0 - Deactivated functionality,\n" +
                   "1 - Activated functionality.\n" +
                   "Default value: 0."
	}
}

def installed() {
	log.debug "installed()"
}
def updated() {
	log.debug "updated()"
	createChildDevices()
}
def uninstalled() {
    log.debug "uninstalled()"
    removeChildDevices()
}

def configure() {
	log.debug "configure"
    delayBetween([
	zwave.multiChannelAssociationV2.multiChannelAssociationSet(groupingIdentifier:2, nodeId:[zwaveHubNodeId]).format(),
	zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId]).format(),
	zwave.associationV1.associationRemove(groupingIdentifier:1, nodeId:zwaveHubNodeId).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 1, configurationValue:[param1.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 2, configurationValue:[param2.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 3, configurationValue:[param3.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 4, configurationValue:[param4.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 5, configurationValue:[param5.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 6, configurationValue:[param6.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 7, configurationValue:[param7.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 8, configurationValue:[param8.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 9, configurationValue:[param9.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 10, configurationValue:[param10.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 11, configurationValue:[param11.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 12, configurationValue:[param12.value]).format(),
	zwave.configurationV1.configurationSet(parameterNumber: 13, configurationValue:[param13.value]).format(),
    zwave.configurationV1.configurationSet(parameterNumber: 14, configurationValue:[param14.value]).format(),
    ], 500)
}

private void createChildDevices(){
	log.debug "Adding Child Devices if they are configured"
    if (childcontact1) {
    	log.debug "Creating Contact1 child"
        try {
        	def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (currentchild == null) {
            	addChildDevice("smartthings/testing", "Simulated Contact Sensor", "${device.deviceNetworkId}-contact1", device.hub.id, //cjcharles0 Visonic Contact Zone
                  [completedSetup: true, name: "${device.displayName} (Contact1)", label: "${device.displayName} (Contact1)", isComponent: false])
            }
        } catch (e) {
			log.debug "Error adding Contact1 child: ${e}"
        }
    }
    if (childcontact2) {
    	log.debug "Creating Contact2 child"
        try {
        	def currentchild = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (currentchild == null) {
            	addChildDevice("smartthings/testing", "Simulated Contact Sensor", "${device.deviceNetworkId}-contact2", device.hub.id, //cjcharles0 - Visonic Contact Zone
                  [completedSetup: true, name: "${device.displayName} (Contact2)", label: "${device.displayName} (Contact2)", isComponent: false])
            }
        } catch (e) {
			log.debug "Error adding Contact2 child: ${e}"
        }
    }
}
private removeChildDevices(){
	log.debug "Removing Child Devices"
    try {
        getChildDevices()?.each {
            deleteChildDevice(it.deviceNetworkId)
        }
    } catch (e) {
        log.debug "Error deleting ${it}, either it didn't exist or probably locked into a SmartApps: ${e}"
    }
}

def parse(String description) {
	def result = null
	def cmd = zwave.parse(description, [ 0x60: 3])
	if (cmd) {
		result = zwaveEvent(cmd)
	}
	log.debug "parsed '$description' to result: ${result}"
	return result
}

def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv1.ManufacturerSpecificReport cmd) {
	log.debug("ManufacturerSpecificReport ${cmd.inspect()}")
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
	log.debug("ConfigurationReport ${cmd.inspect()}")
}

def createEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd, Map item1) { 
	log.debug "manufacturerId:   ${cmd.manufacturerId}"
    log.debug "manufacturerName: ${cmd.manufacturerName}"
    log.debug "productId:        ${cmd.productId}"
    log.debug "productTypeId:    ${cmd.productTypeId}"

}

def createEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd, Map item1) {	
    updateDataValue("applicationVersion", "${cmd.applicationVersion}")
    log.debug "applicationVersion:      ${cmd.applicationVersion}"
    log.debug "applicationSubVersion:   ${cmd.applicationSubVersion}"
    log.debug "zWaveLibraryType:        ${cmd.zWaveLibraryType}"
    log.debug "zWaveProtocolVersion:    ${cmd.zWaveProtocolVersion}"
    log.debug "zWaveProtocolSubVersion: ${cmd.zWaveProtocolSubVersion}"
}

def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
	log.debug "BasicSet V1 ${cmd.inspect()}"
    def currentstate
	if (cmd.value) {
		currentstate = "open"
	} else {
    	currentstate = "closed"
	}
    createEvent(name: "contact1", value: currentstate, descriptionText: "${device.displayName} is ${currentstate}")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: currentstate)
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
    }
}

def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap cmd) {
	log.debug "ZWaveEvent V3 ${cmd.inspect()}"
	def result
	if (cmd.commandClass == 32) {
    	def currentcontact
        def currentstate
		if (cmd.parameter == [0]) {
        	currentstate = "closed"
			if (cmd.sourceEndPoint == 1) {
            	currentcontact = "contact1"
				//result = createEvent(name: "contact1", value: "closed", descriptionText: "$device.displayName is closed")
				//log.debug "Contact1 is closed"
			}
			else
			if (cmd.sourceEndPoint == 2) {
            	currentcontact = "contact2"
				//result = createEvent(name: "contact2", value: "closed", descriptionText: "$device.displayName is closed")
				//log.debug "Contact2 is closed"
			}
		}
		if (cmd.parameter == [255]) {
        	currentstate = "open"
			if (cmd.sourceEndPoint == 1) {
				currentcontact = "contact1"
                //result = createEvent(name: "contact1", value: "open", descriptionText: "$device.displayName is open")
				//log.debug "Contact1 is open"
			}
			else
			if (cmd.sourceEndPoint == 2) {
				currentcontact = "contact2"
                //result = createEvent(name: "contact2", value: "open", descriptionText: "$device.displayName is open")
				//log.debug "Contact2 is open"
			}
		}
        log.debug "${currentcontact} is ${currentstate}"
        sendEvent(name: currentcontact, value: currentstate, descriptionText: "$device.displayName - ${currentcontact} is ${currentstate}")
        if (childcontact1 && (currentcontact == "contact1")) {
            try {
                def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-${currentcontact}"}
                if (childDevice)
                    childDevice.sendEvent(name: "contact", value: currentstate)
            } catch (e) {
                log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
            }
    	}
        if (childcontact2 && (currentcontact == "contact2")) {
            try {
                def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-${currentcontact}"}
                if (childDevice)
                    childDevice.sendEvent(name: "contact", value: currentstate)
            } catch (e) {
                log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
            }
    	}
    } else {
		def encapsulatedCommand = cmd.encapsulatedCommand([0x31: 2, 0x60: 3, 0x85: 2, 0x8E: 2, 0x72: 1, 0x70: 1, 0x86: 1, 0x7A: 1, 0xEF: 1, 0x2B: 1]) // can specify command class versions here like in zwave.parse
		log.debug ("Command from endpoint ${cmd.sourceEndPoint}: ${encapsulatedCommand}")
		if (encapsulatedCommand) {
			result = zwaveEvent(encapsulatedCommand)
		}
	}
    return result
}

def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd)
{
	log.debug "Sensor MultiLevel Report - Sensor Type = ${cmd.sensorType}"
	switch (cmd.sensorType) {
		case 1:
			// temperature
			def cmdScale = cmd.scale == 1 ? "F" : "C"
			def tempval = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision).toDouble().round(1)
            sendEvent(name: "temperature1", value: tempval, displayed: false) //unit: getTemperatureScale()
			break;
	}
    log.debug map
	createEvent(map)
}

def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv1.SensorMultilevelReport cmd) {
    log.debug "SensorMultilevelReport $cmd"
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
	// This will capture any commands not handled by other instances of zwaveEvent
	// and is recommended for development so you can see every command the device sends
	log.debug "Catchall reached for cmd: ${cmd.toString()}}"
	return createEvent(descriptionText: "${device.displayName}: ${cmd}")
}

def listCurrentParams() {
	log.debug "Listing of current parameter settings of ${device.displayName}"
    def cmds = []
	cmds << zwave.multiChannelAssociationV2.multiChannelAssociationGet(groupingIdentifier:2).format()
	cmds << zwave.associationV2.associationGet(groupingIdentifier: 3).format()
	cmds << zwave.associationV1.associationGet(groupingIdentifier: 1).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 1).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 2).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 3).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 4).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 5).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 6).format()
    cmds << zwave.configurationV1.configurationGet(parameterNumber: 7).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 8).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 9).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 10).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 11).format()
   	cmds << zwave.configurationV1.configurationGet(parameterNumber: 12).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 13).format()
	cmds << zwave.configurationV1.configurationGet(parameterNumber: 14).format()
	delayBetween(cmds, 500)
}


def open1() {
    sendEvent(name: "contact1", value: "open", descriptionText: "$device.displayName (1) is opened manually")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "open")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def close1() {
    sendEvent(name: "contact1", value: "closed", descriptionText: "$device.displayName (1) is closed manually")
    if (childcontact1) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact1"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "closed")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def open2() {
    sendEvent(name: "contact2", value: "open", descriptionText: "$device.displayName (2) is opened manually")
    if (childcontact2) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "open")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

def close2() {
    sendEvent(name: "contact2", value: "closed", descriptionText: "$device.displayName (2) is closed manually")
    if (childcontact2) {
        try {
            def childDevice = getChildDevices()?.find { it.deviceNetworkId == "${device.deviceNetworkId}-contact2"}
            if (childDevice)
                childDevice.sendEvent(name: "contact", value: "closed")
        } catch (e) {
            log.error "Couldn't find child device, probably doesn't exist...? Error: ${e}"
        }
	}
}

(cjcharles) #34

Making the temperature main is easy (just write temperature1 in the main
section right at the top).

I’ll check out the contact motion option for webcore, and fix that. It is
definitely better to use the child sensors though… I’ve also noticed that
because I left the state flags (to choose if you want child devices) that
everything runs quite slowly so I might turn that feature off…


Fibaro - Universal Binary Sensor - Does it work with Smart Things
(Borristhecat) #35

Havnt noticed this? What do you mean, so then you can’t create the child devices? For me it seemed faster but that’s probably where I messed up the previous code and yours is much neater. So if you think you can improve it even, more brilliant!

Agreed, but some of the uses I have for them they work perfectly without as there only doing basic stuff. But having the option to do both is brilliant :smile: . I tested both the add and remove child device buttons and they work perfectly! So much easier to than manually doing it! Just a shame that ST don’t have a simulated contact sensor that is view only that you could use.

edit: unless its possible to link to my one I changed?

Yep worked this out and also re put in the temperature icon and colour so that it looks good on the app. Al them changes are on the code above. I also did a motion one but need to test that and work out how to create a child for it.


(Martin Leonard) #36

I too am unable to view any temperature readings.
If I have 1 probe I get 3 endpoints, when I have 4 probes I get 6 endpoints, so the UBS must be detecting the probes.
You seemed to need to buy a new UBS to get it to work. Was the old one faulty? We’re you able to return it?

Any suggestions are welcome. (Yes, I exclude and include any time I make changes to the UBS )


(cjcharles) #37

The first two are the inputs and then the subsequent ones are the temperature readings. Our they should be! I’d love to have a look at your logs when I’m home next weekend and can try and understand what is happening


(Anon) #38

Today I do not know why first ubs did not work, I changed it to a new one and it worked.

I’m sorry I can not help you. Can you attach logs ?


(Martin Leonard) #39

I really appreciate your helping me.
How do I access the logs?
Do I have to enable debug?

I was a programmer but I am very new to Smartthings.


(Anon) #40

Hi, don’t worry, I have only one month with smartthings, it’s easy to learn.

See attached screenshoot, “Live Logging” and then select device name.

another interesting point of information is in “Devices” -> Sensor -> List Events.