variable name required for a power device

I have a Rfxtrx device which monitors my OWL intuition. The current power is being displayed, that works fine. Below is a field for KWH which is blank. I would like to use PLEG to calculate the right value (I’ve got that), but to display it in that device I need to know what the variable name would be for KWH. Then I can try to get PLEG to write the right value into that variable, which should then display on that device… or that’s the idea at least

device_type urn:schemas-micasaverde-com:device:PowerMeter:1
device_file D_PowerMeter1.xml

On my other power meter device I have KHW in advanced, and it is updating.

If you have another similar device that is working and has the correct variable under the advanced tab you could hower you mouse over the variable to get the seviceId.

Ok that is exactly what comes up when I hover over the KWH in my other power device.
Now I just need to set that variable but one for that one device, not for the one where its working with PLEG.

not sure exactly how to get a value from something calculated in PLEG but writing the a value to the variable should be as simple as:

local Value =
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMetering1”, “KWH”,Value,)

where is the id number of your device without the <> of course.

Yes I did some research on the forum and found something similar. What I am not clear about is the local value.
my KWH which I want to set the variable to is in PLEG in KWh, so I would do this in the luup secion of my action:

local Value = {(KWh)}
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMeter1”, “KWH”,{(KWh)},379)

not sure about all the {} and () but I guess that would be right ?

well I tried that, its not working so something in the above is wrong

Did not Rex already provide all you need here? Is this not working?,31754.msg230300.html#msg230300

That is just the calculation, which I have got working (with great help from RexBeckett) although I did not use the Lua code as it is working with the last revision of the PLEG code. What I am trying to achieve now is to display the KHh value in my Power device. I have tried a few variations of the above version with and without brackets, no success so far. I am quite sure its something fairly trivial. I am still looking through the forum to see if I can find a solution.
The variable I want to display is KWh, the device id 379.
I have also tried :
local Value = KWh
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMeter1”, “KWh”,379)
as I have seen some examples similar, but that’s not working either

I am looking again at Rex’s Lua code, I think the answer is in there somehow.

I cannot work out how to change Rex’s code to just display the KWH value. I tried quite a few things, but its not happening.

Please check mine and Rexes example again you should have both “KWH” with the " and the other one ,kWh, or how ever you defined the local variable.

One of them is the variable you created under the powermeter device and the other one is a local variable used only in your lua code. ( Im sure someone with programing experience can explain it better.)

I am not really sure what you mean. I think I probably have tried all possibilities with and without “”, nothing is working. I have posted in the original thread with @RexBeckett. I start thinking that it might not be possible to display a value in that device.

Try this:
local CalculatedVal = formulaforcalculations
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMeter1”, “KWH”,CalculatedVal,379)

I have to try it like this:

local CalculatedVal = KWh
luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMeter1”, “KWH”,CalculatedVal,379)

the calculations are done in a couple of PLEG conditions, so its not that straight forward putting that in 1 formula. But I’ll have a look tonight when I get back from work and see if I could do that. In the meantime I am trying the above version…

the above version did not work

Yes, if the KWh variable contains the value you want displayed, but then it might allso work if you use just:

luup.variable_set(“urn:micasaverde-com:serviceId:EnergyMeter1”, “KWH”,KWh,379)

379 is the correct id of the device where you want to display the value right?

I found the problem. Well I didn’t, RTS did… I had EnergyMeter1, it is EnegryMetering1 for the service id… silly me didn’t see that

I did not see it either so that makes 2 of us :-\ glad you got it working though…

So am I, thanks for your help !

kWh is normally provided by the RFXtrx and considered by the plugin for OWL CM119/160/180/180i.
I don’t know if OWL Intuition is another model.
Can you tell me what is the value for altid in advanced ?

The altid is PM/ELEC4/11008/2. With the help of the forum I have found a way to calculate the value in PLEG, the display it in the device. I can check tonight what model it is if you want to know. The device was created without having KHW in the advanced section, it was being displayed in the device, but without a value. I have another power device (not OWL) which displays Watt and KWH.

Normally, you should have another device with altid PM/ELEC4/11008. This one should have a value for kWh.

CM180i is a 3 channels device. You should have one device for each channel (PM/ELEC4/11008/1, PM/ELEC4/11008/2 and PM/ELEC4/11008/3) and one global device PM/ELEC4/11008 that should display the sum of the 3 channels for watts + the kWh.

Ok that could be a device which I have deleted. I had quite a few power devices created, some of which where the values did not make a lot of sense. but I have a few different power metering devices, so I thought it might be interference or something. Ideally I want it in 1 device, so I think I’ll leave it as is with the calculated value, that way I have 1 device less on my UI. But it explains why I did not have the value displayed.

Just keep the global device in this case and discard devices per channel