Send a notification for every event

Hi all,

I have written my own API and an App that controls all my devices. (Z-wave and IR)

The problem is when I control f.e. light modules via a wall switch, my App (the state of the device) has to be updated.

How can I setup Vera to send a notification for every event to my API (device id/state) ?

Thx in advance,

Cédric

You can subscribe to specific data change Events, on specific Devices, using the [tt]luup.variable_watch[/tt]. This is not a blanket subscription to all events produced in the system as that would be a LOT of events.

You can see samples of this in the code:
L_EnergyMonitor_j.lua in energy monitor plugin – Energy Reporting framework

Can someone help me with this snippet of code?

It doesn’t work and I don’t know why…

[code]luup.variable_watch (‘fncReportEngine’, ‘urn:upnp-org:serviceId:SwitchPower1’, ‘LoadLevelStatus’, 1)

function fncReportEngine (lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)

local strReportEngine = ('http://xxx.xxx.xxx/api/report.php?device='):format (luup.ra_server)

strReportEngine = string.format("%s,%s,%s,%s,%s", strReportEngine, lul_device, lul_service, lul_variable, lul_value_new)

local status, rss = luup.inet.wget(strReportEngine, 10)

end[/code]

Is it also possible to get the local_udn (f.e. uuid:4d494342-5342-5645-0005-… ) of the device?

Are you trying to watch a dimmer or an on/off switch? The variable associated with SwitchPower1 is “Status” instead of “LoadLevelStatus.” The …SwitchPower1 urn can be used with dimmers or switches to determine if the device is on or off. To watch for a change in brightness watch the …Dimming1 urn and the variable “LoadLevelStatus.”

See http://forum.mios.com/index.php?topic=5300.msg30179#msg30179 for a snippet of code for watching a dimmer.

To get the local udn try this:

local_udn = luup.devices[12].udn

where 12 is the device id of the device for which you want the udn.