The Vera Community forums have moved!

Advanced => Programming => General => Topic started by: connormacleod on January 24, 2019, 10:38:21 am

Title: set subcategory_num for a preconfigured device to change icon
Post by: connormacleod on January 24, 2019, 10:38:21 am
Hi Everyone,

I have a Aeotec ZW116 device that controls a light bulb. Ideally, I'd like the icon to show as a light bulb.  (right now it shows as a receptacle)

I've learned I can change this by manually setting the subcategory_num to a "0" instead of it's default value of "3"

Problem is, every time luup reloads, it resets to "3".  Vera tech support told me pre-configured devices always have their default values resent every time luup reloads.

I know the serviceid for this device is  "urn:schemas-upnp-org:device:BinaryLight:1"
and the deviceId is 21

How can I setup some luup code that would automatically set the sub_category of this device to a "0" every time luup reloads.?  Anyone done something like this?

Title: Re: set subcategory_num for a preconfigured device to change icon
Post by: akbooer on January 24, 2019, 10:53:24 am
Try placing this line in Lua Startup...

Code: [Select]
luup.attr_set ("subcategory_num", 3, 21)
Title: Re: set subcategory_num for a preconfigured device to change icon
Post by: connormacleod on January 24, 2019, 11:20:26 am
Try placing this line in Lua Startup...

Code: [Select]
luup.attr_set ("subcategory_num", 3, 21)

Nice!!!

I love the way you masters can super simplify stuff for a newbie ;D.  I put this into the "Edit Startup Lua" section and now the device shows a light bulb,  and seems to be surviving luup reloads as intended.

Code: [Select]
luup.attr_set ("subcategory_num", 0, 21)

Thanks akbooer!

Title: Re: set subcategory_num for a preconfigured device to change icon
Post by: akbooer on January 24, 2019, 11:25:39 am
I put this into the "Edit Startup Lua" section and now the device shows a light bulb,  and seems to be surviving luup reloads as intended.

It does so, because it is, of course, run after every restart!

Quote
Thanks akbooer!

You're welcome.