I have been thinking about many of my custom devices. I really should not need to recreate something as basic as a dimmer, or RGB light, or switch. I think it should be possible to add a built-in Virtual Switch as a child device to any of my custom devices. And then, to have a simple wrapper for the commands and events so that if parent != null then, call an associate parent function.
Example: Virtual Switch
capability "Switch"
capability "Actuator"
capability "Refresh"
on() {
sendEvent(name: "switch", value: "on")
if (parent) parent.childOn(this)
}
off() {
sendEvent(name: "switch", value: "off")
if (parent) parent.childOff(this)
}
refresh() {
if (parent) parent.childRefresh(this)
}
I understand, refresh is not a capability for many virtual devices, but with these being used as possible child devices, it would make sense to make it possible. Plus, this is just an example. Doing something like this could eliminate a lot of custom child devices where the built-in devices could suffice.
@bravenel Do you think this is a possibility? Maybe there are limitation in the system I am not aware of, or not thinking through?