How to create/suppress a device in luup

I know how to manage the child devices of a parent device, but I don’t know :

  • how to add a new device without attaching it to a parent device
  • how to delete a device (not attached to a parent device)
  • how to change the parent of a device

Can I have some help ?

[quote=“lolodomo, post:1, topic:174555”]I know how to manage the child devices of a parent device, but I don’t know :

  • how to add a new device without attaching it to a parent device[/quote]

I’ve only ever seen parentless devices created on plugin installation, or by hand. But there might an answer below…

I found this in my logs when I manually deleted a device:

JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: DeleteDevice

So maybe it’s legal to call luup.call_action with the above service ID and action, device ID 0, and parameters { DeviceNum=45 } (or your target device to delete)?

Maybe luup.attr_set on the “device_num_parent” attr?

These are all guesses, and I’m sure you would prefer an official answer…

watou

in Luup delete device :

http://< Vera-IP>:3480/data_request?id=device&action=delete&device=<device_ID>

changing the parent/child on device i dont know if possible

Any idea how to set the ip variable when creating device(s) with luup.chdev.append ?
I tried to use the parameter in which you can provide a list of variable+value, but I have no idea what service id is attached to this variable “ip”. So I tried without providing the service id and the variable was not set.

[quote=“lolodomo, post:4, topic:174555”]Any idea how to set the ip variable when creating device(s) with luup.chdev.append ?
I tried to use the parameter in which you can provide a list of variable+value, but I have no idea what service id is attached to this variable “ip”. So I tried without providing the service id and the variable was not set.[/quote]

Do you mean the attribute as opposed to variable? Attributes like model, ip, mac, etc., are different from variables, and you have to use the attr_get and attr_set for those. In my code I check/set them after luup.chdev.* calls are done, but I would like to be able to set them on device creation, but don’t know if that’s possible.

watou

[quote=“watou, post:5, topic:174555”][quote=“lolodomo, post:4, topic:174555”]Any idea how to set the ip variable when creating device(s) with luup.chdev.append ?
I tried to use the parameter in which you can provide a list of variable+value, but I have no idea what service id is attached to this variable “ip”. So I tried without providing the service id and the variable was not set.[/quote]

Do you mean the attribute as opposed to variable? Attributes like model, ip, mac, etc., are different from variables, and you have to use the attr_get and attr_set for those. In my code I check/set them after luup.chdev.* calls are done, but I would like to be able to set them on device creation, but don’t know if that’s possible.

watou[/quote]

Ok, thank you, so we have to first create the devices and only in a second timle (after sync - reload) set the attributes.
Do you know if attr_set triggers a reload ?

In the plugin I’m working on, it doesn’t appear to trigger a reload when I make calls like this (after the child devices were created and it reloaded):

if luup.attr_get("category_num", child) ~= "5" then luup.attr_set("category_num", "5", child) end if luup.attr_get("model", child) ~= modelNumber then luup.attr_set("model", modelNumber, child) end

it does automaticly after you press the save button , but it does not when set in luup code. you have to trigger it by luup also then.
http://ip_address:3480/data_request?id=reload
but i think when u set device parameters, the device needs to be reconfigured. it is not doing that when reload.
for variable a reload will do.
maybe this is usefull http://wiki.micasaverde.com/index.php/Luup_Lua_extensions

Yes, it is what I noticed.

. you have to trigger it by luup also then. [url=http://ip_address:3480/data_request?id=reload]http://ip_address:3480/data_request?id=reload[/url]

It is HTTP request, not luup code.
I don’t know if there is a clean luup call to trigger the restart ?

By the way, I updated my code to make it work even without a reload.

For completeness.

luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "Reload", {}, 0)

Thank you, that’s good to know.