I am new to luup development, and am trying to build a plugin to collect data from an EW4008 power meter I have. This only returns instantaneous data when you make a request of the port - it doesn’t publish data, you have to request it.
Before I worry about the serial port work, I am doing some testing of a plugin that will run every 5 seconds and do the serial port call.
I have the following function:
[code] function getData(data)
luup.log(“Get Data called: '” … data … “'”);
local randomValue = math.random(300, 6000);
luup.log("Current value: " … randomValue);
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMetering1”, “Watts”, randomValue, lul_device)
luup.call_delay("getData", 5, "data", 0);
end
[/code]
In the startup function for the device, I make the call:
luup.call_delay("getData", 5, "data", 0);
return true;
This update the Watts value for the device, and does so every 5 seconds for a while. However, after a fairly long period (a few hours), it stops. No more calls to getData are made, and the Watts value does not get updated.
Any idea why this is happening?