Why can't I find a wall switch with motion sensor?

Take a look at my GE Motion Dimmer component driver. Maybe it will help giving you a real world example of a multifunction device using component children.

1 Like

So I see the addChildDevice() function call that creates the child device but I don't see any description of this function call in any documentation. How do I give the child device capabilities?

The capabilities of the child device are defined in the child device driver.

Can you show an example of a child device driver? What calls/instantiates the child driver? I assume the addChildDevice() function but I don't see how the addChildDevice specifies a driver.

The typeName parameter

addChildDevice

Creates a new child device and returns that device from the method call.

Signature

ChildDeviceWrapper addChildDevice(String namespace, String typeName, String deviceNetworkId, Map properties = [:])

ChildDeviceWrapper addChildDevice(String typeName, String deviceNetworkId, Map properties = [:])

Parameters

namespace - The namespace of the child driver to add as a child device (optional, if not specified it will default the the namespace of the parent)

typeName - The name of the child driver to add as a child device

deviceNetworkId - unique identifier for this device

properties - optional parameters for this child device. Possible values listed below

Properties

boolean isComponent - true or false, if true, device will still show up in device list but will not be able to be deleted or edited in the UI. If false, device can be modified/deleted on the UI.

String name - name of child device, if not specified, driver name is used.

String label - label of child device, if not specified it is left blank.

Returns
ChildDeviceWrapper

2 Likes

There are a few on Hubitat's GitHub.

https://raw.githubusercontent.com/hubitat/HubitatPublic/master/examples/drivers/genericComponentDimmer.groovy