Hoping someone might be able to help me with my script. I've not really done much with LUA before but really need to start learning.
I've been pouring over the forum and I've started getting it working but I'm not quite there.
First the purpose of the script.
I want to read my owl energy meter each time it updates, then transfer the Power and Energy values to a dummy device on Vera.
I've created 3 user variables, "energy1", "PowerF" and "EnergyF"
The script updates the string "energy1" no problem. I have no errors in the log.
I am unsure how to split this string into the two seperate values for Power and KWH.
What I have done below simply does nothing.
I've tried quite a few different things but I'm just not getting it.
I've added in the url's with which I eventually want to send the values over to Vera, but at the moment my main focus is being able to see them in the user variables so I can understand what is going on.
Lastly, the values I read for example are "482.000;764578.875" the split is ;
so 482.000 is the power and 764578.875 is Energy. I would like to divide and round the energy value down to get it to 765 in this example.
Thanks in advance guys.

Code: Select all
commandArray = {}
energyreading = "Energy Monitor"
if (devicechanged[energyreading]) then
print( " ####watt debug: "..devicechanged[energyreading])
commandArray['Variable:energy1']=tostring(devicechanged[energyreading])
watt, kwh = energyreading:match("([^;]+);([^;]+)")
commandArray['Variable:PowerF']=watt
commandArray['Variable:EnergyF']=kwh
--http://192.168.1.12:3480/data_request?id=variableset&DeviceNum=271&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=WATT&Value=..watt
--http://192.168.1.12:3480/data_request?id=variableset&DeviceNum=271&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=KWH&Value=..kwh
end
return commandArray