We have moved at community.getvera.com

Author Topic: Device id variable  (Read 269 times)

Offline Tarkus

  • Sr. Newbie
  • *
  • Posts: 31
  • Karma: +6/-0
Device id variable
« on: January 20, 2019, 10:20:06 am »
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.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Device id variable
« Reply #1 on: January 20, 2019, 11:28:38 am »
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
« Last Edit: January 20, 2019, 11:40:41 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Tarkus

  • Sr. Newbie
  • *
  • Posts: 31
  • Karma: +6/-0
Re: Device id variable
« Reply #2 on: January 20, 2019, 11:39:50 am »
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.

Offline tinman

  • Full Member
  • ***
  • Posts: 215
  • Karma: +16/-0
Re: Device id variable
« Reply #3 on: January 21, 2019, 09:16:10 am »
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.

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Device id variable
« Reply #4 on: January 21, 2019, 09:31:17 am »
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.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Device id variable
« Reply #5 on: January 21, 2019, 09:37:47 am »
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.
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.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: Device id variable
« Reply #6 on: January 21, 2019, 09:38:51 am »
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.

This is a great idea and honestly one of the standout features of Luup.
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.