emoncms link to vera edge ui7

Hi to all,

As i need a perfect visual handling of my energy ( solar pv production and general energy monitoring ), i choosed emoncms as visualisation mode.
I’m not familiar with lua programming, but i have some code running for a vera 3 ui5, and i try to tranpose, for the moment with no sucsess.
I have two owl cm160 plugs mesuring my pv and genral power thrue a rfxtrx, and this is running fine.
Here is the code i use for a scene wich is posting my data to emoncms every minute :

local id = 25
local type = “urn:schemas-micasaverde-com:device:PowerMeter:1”
local fields = {“Watts”, “KWH”}
local apikey = “95fe5bdb8f6f28cefdbdbbddd6c1315c”
local voltage = 225

for i,field in ipairs(fields) do
local value = luup.variable_get(type, field, id)
value = tostring(value)

luup.inet.wget(“http://emoncms/input/post.json?node=0&json={“..field..”:“..value..”}&apikey=”…apikey)

if field == “Watts” then
local iinst = tostring(luup.variable_get(type, field, id) / voltage)
luup.inet.wget(“http://emoncms/input/post.json?node=0&json={IINST:“..iinst..”}&apikey=”…apikey)
end
end

I have no error message, the scene is running fine, but i have no value stored in my emoncms acount…

Is it possible to have some help to find what is wrong in my code, or at least a debug feature ?

If someone can send me code for at least one variable, i could accomodate by running two scenes, one for watts and one for kwh, but for now, i’m in the fog ! ;D

I think emoncms is a very good solution to value energy data, so i will swap for another system if it is not possible to link with vera, but i think vera is also a good system, so i want best of both worlds. 8)

Thanks on advance for any help !

I took a quick look at the documentation for posting data… and it appears that they use a “json like” data format and not true json…

Try changing your wget command to:

luup.inet.wget("http://emoncms/input/post.json?node=0&json="..field..":"..value.."&apikey="..apikey)

and

luup.inet.wget("http://emoncms/input/post.json?node=0&json=IINST:"..iinst.."&apikey="..apikey)

Hi, Cybrmage

Thanks a lot for this aproach . Unfortunately, this no more work, i have still no error, but no data on emonscms input… ??? ::slight_smile:

I sent a request to Brian from support, and i’ve sent “personal mail” to a senior menber of this forum who developped a pluigin for ui5.

I’m so crossing the fingers now !

[quote=“Velectris, post:3, topic:189213”]Hi, Cybrmage

Thanks a lot for this aproach . Unfortunately, this no more work, i have still no error, but no data on emonscms input… ??? ::)[/quote]

You MIGHT want to put in the correct URL…

instead of http://emoncms/, use http://emoncms.org/

With the correct URL it DOES work.

;D I agree with you my friend that with the correct url, this is way far better !!!

Now i have a Watt input on emoncms page, but the KWH is not created, and the value for watt is each time zero, so i guess i have still two troubles, one on the data input, and on the creation of the value “KWH” .

But, there is very big step passed !

You can view the inputs with the apikey wich is in the software .
Here are the resulting line codes :

local id = 25
local type = “urn:schemas-micasaverde-com:device:PowerMeter:1”
local fields = {“Watts”, “KWH”}
local apikey = “95fe5bdb8f6f28cefdbdbbddd6c1315c”
local voltage = 225

for i,field in ipairs(fields) do
local value = luup.variable_get(type, field, id)
value = tostring(value)

luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=“..field..”:“..value..”&apikey=”…apikey)

if field == “Watts” then
local iinst = tostring(luup.variable_get(type, field, id) / voltage)
luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=IINST:“..iinst..”&apikey=”…apikey)
end
end

I’m sure with one or two steps, you can help me to fix this feature. Of course, everibody will have this capability also, there will just a need to adjust the device ID ( clamp meter ) and device URN .
So, i guess we are also working for the hole vera community ! :smiley:

That would be due to you “type” parameter…

You are using the device urn instead of the service id…

try using “urn:micasaverde-com:serviceId:EnergyMetering1” instead.

You are a magician !
more seriously, you have a very good knowledge of these “details”, congratulations !

This works now like a charme, many thanks !

I publish here the running code if any other guy want to try this solution :

local id = 25
local type = “urn:micasaverde-com:serviceId:EnergyMetering1”
local fields = {“Watts”, “KWH”}
local apikey = “95fe5bdb8f6f28cefdbdbbddd6c1315c”
local voltage = 225

for i,field in ipairs(fields) do
local value = luup.variable_get(type, field, id)
value = tostring(value)

luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=“..field..”:“..value..”&apikey=”…apikey)

if field == “Watts” then
local iinst = tostring(luup.variable_get(type, field, id) / voltage)
luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=IINST:“..iinst..”&apikey=”…apikey)
end
end

You need just to edit the id of the mesuring device, and his type , and of course, your apikey for emoncms .

I have now some job to do for displaying the data correctly, i will follow an url when finished .

Cheers ! ;D

Hi

I am new to Vera - I have a Vera Edge.

Sorry for the newie question:

Where do I find the type of my device - to replace EnergyMetering1 ?

Hi, JanneSjo,

You just go to you device in vera, and click on settings, then “advanced”, and you have the device type in front of you, you just have to copy the end of the sentence in the code.
Don’t forget to change the device ID also.

Good experimentation, here is my result page on emoncms with 5mn tuning :
http://emoncms.org/app?apikey=95fe5bdb8f6f28cefdbdbbddd6c1315c#mysolarpv

Cheers ! ;D

So many magicians here :slight_smile:

I’m trying to finishing my “Mysensors” powermeter and send values from vera to emoncms right now.
but i can’t understand what is the wget adress??? i already change the other values second my sensor

[code]local id = 49
local type = “urn:micasaverde-com:serviceId:EnergyMetering1”
local fields = {“Watts”, “KWH”}
local apikey = “b2492222b5************5dd9f775”
local voltage = 230

for i,field in ipairs(fields) do
local value = luup.variable_get(type, field, id)
value = tostring(value)

luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=“..field..”:“..value..”&apikey=”…apikey) < WHATS THAT?AND CHANGE BY WHAT???

if field == “Watts” then
local iinst = tostring(luup.variable_get(type, field, id) / voltage)
luup.inet.wget(“http://emoncms.org/input/post.json?node=0&json=IINST:“..iinst..”&apikey=”…apikey) < WHATS THAT?
end
end[/code]

EDIT:
ITS WORKInG ALREADY. was supose leave it as it is :slight_smile:

there are any problem if i decrease the vera scene update from 1 min to less time? will that overcharge vera lite powerfull cpu? :stuck_out_tongue:

Hi, happy to know that it works also for you !
The 1mn latence is there to avoid too much traffic on emoncms server : this is free, and we need to be fair with the open source world, isn’t it ?

But, unfortunately, i have another experimentation on ? esp8266 posting to emon cms, and this is ok with 10 seconds.

You just need to respect this minimum delay.

Good tuning ! 8)

ye,you are right, even on sensor , i will put 1 min interval for not overload my gateway.

good work 8)

I like this approach and I have been testing it out for a little while. I am only wanting to log my watts usage from my fibaro wall plugs to EmonCMS and I don?t need any calculation in the lua, but what I was wondering is if I could have one Scene that pulls all of my plugs instead of a seperate scene for each but of course it should post each plug seperately.

I am not a programmer, so I can unfortunately not figure this out by myself.

I was initially going to use the built-in Ergy, which to me looks a lot like EmonCMS, but unfortunately this is not working well at the moment.

Hi Kulfsson,

You describe a good solution when you have many watt values to feed to emoncms.
I’m sure this is possible, and not too hard to code.
Unfortunately, i have a bad knowledge of “how to read and describe the variable names in vera”, and in this case, this is a requirement.

I’m sure a lot of people here can help you to write the running code.
Emoncms can accept a lot of variable in one shot, any node number, so you can just create nodes according to your requirements, and send all the data on one line / http json transaction .

Chuss ! 8)