Add Attribute(s) to Component Device

Is there a way to add attributes to Generic Component Devices at execution time?

I have a driver that uses component devices (such as Generic Component Dimmer and others).

I'd like the device to list attribute values in its States column when an event message is received (e.g., a message for an event like

[name:"OffTransitionTime", value: 3.1, units:"seconds",  isStateChange:false]  

Now, normally, if the component device had the attribute added in its metadata section, it would display and update an "OffTransitionTime" attribute when it receives this event message. However, the Component devices don't have this attribute (and many others) pre-defined.

I could, of course, write a custom component device, and could also store data using updateDataValue, but in the ideal, I'd re-use the existing components so that a user doesn't have to install custom ones. With that as the goal, I'm wondering if there is an "add"-like function for child devices along the lines of:

childDevice.addAttribute(attributeName)

No I have asked this before about the ability to dynamically add attributes (I think you have as well).
This would basically be the same as what I asked about before and was told its not possible.

You can post things to any attribute name though, it will show on the device page while it is open but if you refresh the page it goes away.

1 Like

Thanks. I think I had asked about Capabilities at one point and knew you couldn't do that -- but those render controls on the webUI and so are more complex - I was hoping that attributes alone might still be a possibility since it would be simpler. But I got my answer, so thank you! I'll find another way.

Good point, I think I also asked about capabilities before not specifically attributes. But that being said I have never seen anything indicating that they can be changed anywhere else in the code.

The only thing I have found that can be dynamic is the settings.

If it is truly a child device you may be able to set and read a state variable.