Sorry to keep spamming the forum with questions. New user, trying to get the main motion detectors in my house linked into Hubitat, so that Rooms Manager lights work again. Thanks @bangali
I'm attempting to create child devices (an alarm system, that has 8 motion detectors). There is communication between the alarm system and Hubitat, as I can arm the alarm through Hubitat and all 8 child devices are listed on the device page, but there is something wrong with the coding about adding a child device. The child devices are not added, or there is another step I'm not sure how to do. (How to add a child device?? )
Log errors There are 8 of each of these, one for each Motion detector.
Couldnt add device, probably already exists: groovy.lang.MissingMethodException: No signature of method: dev15385275343371522413665.addChildDevice() is applicable for argument types: (java.lang.String, java.lang.String, org.codehaus.groovy.runtime.GStringImpl, java.lang.Long, java.util.LinkedHashMap) values: [Hubitat, Open/Closed Sensor, alarmchildzone1, 1, [name:MD - Front Door]]
[dev:33](IP Address/logs#dev33)2018-10-03 10:46:11.443:debugTrying to add child with name: MD - Front Door, ID: alarmchildzone1 to 1
Here is the appropriate spot in the Device Code (there is more, this is just the appropriate code). Full Code here: https://1drv.ms/t/s!AnXEg8RBC3NHld5BgaBlQm7uynBkgw (although that is still with the SmartThings language).
def ZoneCreateZoneDevices()
{
// This will create child devices
// The child devices are created in the handler for the /getzonenames response
log.debug "Requesting List of Alarm Zones"
getAction("/getzonenames")
}
def ZoneRemoveZoneDevices()
{
// This will remove all child devices
log.debug "Removing Child Zone Devices"
try
{
getChildDevices()?.each
{
try
{
deleteChildDevice(it.deviceNetworkId)
}
catch (e)
{
log.debug "Error deleting ${it.deviceNetworkId}, probably locked into a SmartApp: ${e}"
}
}
}
catch (err)
{
log.debug "Either no child devices exist or there was an error finding child devices: ${err}"
}
}
def ZoneTestFunction()
{
// This function creates a test device, which may be needed due to some random problems that exist when creating child devices
// due to issues in the SmartThings API
// log.debug "Got here inside the test function"
log.debug prename
if (device.currentValue("createzonedevices") == "cancreatezonedevices")
{
log.debug "state correct"
}
try
{
def curdevice = getChildDevices()?.find { it.deviceNetworkId == "alarmchildzonetest"}
if (curdevice)
{
//Do nothing as we already have a test device
}
else
{
addChildDevice("hubitat", "Motion Detector", "alarmchildzonetest", device.hub.id, [name: "alarm zone test device", label: "Alarm Zone Test Device", completedSetup: true])
}
}
catch (e)
{
log.error "Couldnt find device, probably doesn't exist so safe to add a new one: ${e}"
addChildDevice("hubitat", "Motion Detector", "alarmchildzonetest", device.hub.id, [name: "alarm zone test device", label: "Alarm Zone Test Device", completedSetup: true])
}
}
// This will configure the device to talk to SmartThings
def configure()
{
def cmds = []
log.debug "Configuring Alarm (getting zones+types, configuring IP/port/timeout)"
cmds << getAction("/status")
def requeststring = "/config?ip_for_st=${device.hub.getDataValue("localIP")}&port_for_st=${device.hub.getDataValue("localSrvPortTCP")}"
if (inactivityseconds?.isInteger())
{
// Inactivityseconds is both populated and an integer, so lets send it to the Wemos
requeststring = requeststring + "&inactivity_seconds=${settings.inactivityseconds}"
}
// log.debug requeststring
// Send the details to SmartThings
cmds << getAction(requeststring)
return cmds
}
def refresh()
{
log.debug "refresh()"
// SendEvents should be before any getAction, otherwise getAction does nothing
sendEvent(name: "ip", value: device.hub.getDataValue("localIP")+"\r\nPort: "+device.hub.getDataValue("localSrvPortTCP"), displayed: false)
// Now refresh Alarm status
getAction("/refresh")
// getAction("/getzonenames")
}
def installed()
{
log.debug "installed()"
//configure()
}
def updated()
{
log.debug "updated()"
configure()
}
def ping()
{
log.debug "ping()"
getAction("/ping")
}