Device id variable

Is there a way to change the device id from a number to a a name, for example.

If the device is of my bedroom light switch is 100.

100= bedroom light.

In a word, no. The device already has a text description that is used in the UI. How were you thinking of wanting to use your chosen name?

If you’re planning to do this from Lua code, a simple look-up table is easily generated…

http://forum.micasaverde.com/index.php/topic,14743.msg111814.html#msg111814

I am using a Google assistant ifttt applet along with webhooks to control home lighting. My vera hub uses numbers as id’s for devices i.e. 236 = bedroom light.
The webhook url I would use to turn on the bedroom light is as follows.

http://ip_address:0000/data_request?id=action&output_format=xml&DeviceNum=236&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

I could replace the 236 with a number ingredient variable but then I would need to give the voice command “turn on 236 light” for the bedroom, “turn on 20 light” for the living room, etc. I would much rather say turn on bedroom light, etc…

So I am wondering if there is a way to assign a plain text variable to the device id. For example.

Bedroom=236
Living room=20

The advantage to this is I would be able to use one applet for all my lights vs one for each light.

Thanks in advance.

You might consider using the altid param (device advanced → params tab). I’m not sure how Vera uses this but I think it can be almost anything.

In the /data_request HTTP you are stuck with using the actual device number.

However, it is really quite simple to add a request callback handler in the Lua Startup code which could respond to a custom request which included a device name, and could then be mapped to an actual device ID using the lookup-up table I mentioned earlier.

Note on the altid:

On Z-Wave devices it’s the Z-Wave node ID (very important). I don’t have any BT or ZigBee devices, but I would imagine they use it in a similar fashion for those. It is otherwise used as an ID for child devices of a parent device, and must be unique within the parent’s children or hilarity ensues. So a device like a Z-wave multisensor will have the altid=node ID on the parent device, and for the child devices it will be an identifier that has meaning to the parent (e.g. when it wants to update the light sensor child value, it could find which device that is by looking in its children for the reliable identifier it assigned, perhaps not the Vera device number).

If you are writing a plugin that has child devices, you can use it any way you want (observing the uniqueness requirement). But it should be considered a reserved field for any device type you do not create yourself.

[quote=“akbooer, post:5, topic:200468”]In the /data_request HTTP you are stuck with using the actual device number.

However, it is really quite simple to add a request callback handler in the Lua Startup code which could respond to a custom request which included a device name, and could then be mapped to an actual device ID using the lookup-up table I mentioned earlier.[/quote]

This is a great idea and honestly one of the standout features of Luup.