Component Children (buttons and scenes vs switches)

I have a driver I'm working on which has component switch children which when toggled can receive the 'on' or 'off' command via componentOn() and component(Off) commands.

Now, if I instead use a componenent switch scene controller or componenent button controller, if the button(s) are toggled on the component, I can see no way to 'receive' these to the parent device. I have tried componenentPress() and componenentPressed() and variants.

What am I missing? Surely this is possible...

Thanks

There were a discussion that seem to be related to your case Generic Component Central Scene Switch and Generic Component Button -- how to use - :bellhop_bell: Get Help - Hubitat

In short: scene controller component devices seem to not follow parent.componentACTION() pattern when UI controls used.

What driver is your child device using? That ultimately determines what command (if any) it calls on the parent, but componentPush(number), componentHold(number), etc. would follow the convention.

If it's calling something that doesn't exist, you'll see an error in Logs, which is something else you can use to help.

The buttons (pushed, hold, etc..) presented as commands are basically just there to simulate actual button presses on the device. They just post an event to the device entry and typically do not perform any other actions. Unlike on/off which would need a command sent to the physical device.

So I suspect the child driver is handling the virtual button press internally and just posting it to that child device as a button event. What else do you want it to do?

Or... what are you trying to do exactly? I have a driver where I use "Generic Component Central Scene Switch" as a child device and send button events from the device to the childs.

The parent driver creates 'control' devices as children. These are of the component type.

If I create the child device with either "Generic Component Central Scene Switch" or "Generic Component Switch" ( @bertabcd1234 ), and use either the devide page (or add to a dashboard) I can turn the switch on or off, and receive a command on the parent driver through componentOn() or componenentOff() which I can then 'do' something with, like send a command to the network devide which the driver is for. I can also reciprocate, and set the status of the switches to show the status of the network device.

However, instead of sending a command to the network device by switching the child device on and then issuing the command (and subsequently changing the child back to 'off''), I was hoping the be able to instead use a button controller, which can be easilly added to a dashboard.

I won't need to update the status of the button from the master driver, but I just want to be able to take an action on the parent driver if the child button is pushed (or released, held, etc).

I have tried componentPush() and componenentPushed() too, and still getting nowhere. Surely this is not an oversight? What would be the point of having a child that I can only update to say 'pushed' rather than actually do something when 'pushed'? I can see it creates events, but how would I receive these events?

@dmitry.rozovik I have read this, but they just switched to talking about receiving on/off commands which I can lareayd do without issue.

@jtp10181 Does this explain what I am trying to do? I can do it with switches, but I just think it would be tidier to use buttons instead?

Thanks,

I just tested this and it looks like the "Generic Component Central Scene" driver does indeed not push these up to the parent with things like componentPush(). The "Generic Component Button Controller" driver does if you only need button events (e.g., not on/off). This seems inconsistent to me, and I imagine it may have been an oversight on the others. If the current behavior is not depended on anywhere by anything built-in (or this wasn't at a specific community request), perhaps this could be changed.

In the meantime, if the above doesn't work, it's certainly possible to also write your own "component"/child driver that works in whatever way you need.

Because button events do not typically cause action on the physical device. You push a physical button, the device reports it to the hub. The device itself does not "do" anything. So if you have a virtual "button" on the dashboard it typically only needs to create the "pushed" event on that device entry and nothing more. There is nothing the physical device would normally do if the button is pushed so there is nothing to send to it.

You would receive the events by having a rule that sees a button was pushed and then you do action on other devices. This is how button devices are typically used.

Still not understanding what sort of command you are going to send to the device when a virtual button is pressed? Alluding to your example, maybe it is a switch but you want to control it with child devices as buttons. Sounds like something that would normally be solved with virtual button devices and a rule to tie them to the switch.

Not saying your approach is wrong by any means, it is just unconventional which I would guess is why the built in driver does not support it this way.

I would just create your own child driver, it is very easy to do relative to actual device drivers. Here is a Hubitat example: HubitatPublic/examples/drivers/componentSwitch.groovy at master ยท hubitat/HubitatPublic ยท GitHub

1 Like

wasn't there previously some issue with homekit etc if you used non built in child devices / virtual devices, or has that been resolved?

It's not a "problem" per se, just the way it has to work (see: HomeKit Integration | Hubitat Documentation for more). But, yes, virtual user drivers, child or not, will not work as-is.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.