How to add category_num to a device?

Some of the devices (plugin…) have no category = Unknown.
How to add category_num to a device?

Try to execute this code, under Apps/Develop Apps/Test luup code

luup.devices[devID].subcategory_num = 11
luup.devices[devID].category_num = 0

Where devID is the device number. 11 is generic I/O.
Categories are here:
http://wiki.micasaverde.com/index.php/Luup_Device_Categories

a couple are new and not yet supported, but it should on FW 7.30, in beta approx at the end of this month.

Hi,
If you are making your own plugin, or the developer, you should add the category_num and subcategory_num in the D_…xml file of your plugin. Just grab one from you Vera to look at the detail.

Cheers Rene

true, but there some very old plugin (house mode, night&day, to name a few) that were created in the UI5 era, and that don’t set this properties. setting them by code is usually enough.

I don’t think setting values is luup.devices is the “proper” way, or recommended. AFAIK, using luup.attr_set() is the (only) official way. I may be wrong, but setting values in luup.devices directly seems like a good way for Luup not to know that user_data has changed and therefore not save correctly.

I used this hours ago with no problems. I’m not sure if this is new or I started years ago, but it works. True that in plugins or more static code you should probably stick with the official way.

We might want to confirm with @edward that this method will correctly mark user_data dirty. If not, there’s a chance changes will be lost by the newer conservative write/save.

Even so, you can update the D…xml file for those as well or set the attribute in the Advanced setting. As always, many ways to skin a cat.

© 2019 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy