luup.call_action code for EnergyMetering1 device ?

I’m searching for the folllowing luup-code

luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = 1}, 52)

for a EnergyMetering1 device to set the “Watts” value
something like:

luup.call_action("urn:micasaverde-com:serviceId:EnergyMetering1", "SetUsage", {newActualUsage = 40}, 52)

but that doesn’t work…

Anything that is not referenced at http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions for standard devices cannot be expected to work… for energy meters the only standard action is ResetKWH…

But if you just want to display watts in the UI for a dummy device, then just a luup.variable_set will do

Next to Vera I’m testing another HA system based on Raspberry Pi + Aeon-z stick and Domoticz. What I want to achieve is send the Watt value from a Power sensor within Domoticz to a virtual sensor in Vera. So I created a virtual sensor of the type EnergyMetering1.

What I managed to do is to change a virtual switch in Vera from Domoticz with the following code:

http://192.168.1.202:3480/data_request?id=lu_action&output_format=json&DeviceNum=301&serviceId=urn:upnp-org:serviceId:VSwitch1&action=SetTarget&newTargetValue=0

So now I’m looking for a similar method to do something similar with the Watt value.

So your proposed solution will not work I guess …?

Hi,

I do not think you can set the Watts value like that. Normally the watts and KWH are values populated by the device and you can then read those variables. If you want to create a virtual PowerMeter device you will have the use the luup.variable_set function to put in the watt value.

I attached a simple example I use for my Solar panels. You first need to create the implementation file and upload it to your Vera. Then create a device (Apps, Develop Apps, Create Device) using the following:
Device type urn:schemas-micasaverde-com:device:PowerMeter:1
Upnp Device Filename D_PowerMeter1.xml
Upnp Implementation Filename I_ImplementationFileName.xml

After the reboot you can start debugging. the resulting device will look like any power meter device, even in the Vera and other phone apps.

Have fun, Rene

@Mai Pensato, you may want to have a look at the Domoticz plugin I wrote… See http://forum.micasaverde.com/index.php/topic,39022.0.html
May be it will not fit the bill for you (BTW, it will NOT run on a real Vera), but the code posted on GitHub might help you.

Anyway, you could also try the following:

On the Vera (or openLuup system), manually create a device with the two config files below (no implementation file as we just want a dummy device):
device file = “D_PowerMeter1.xml”
device json = “D_PowerMeter1.json”

from the Domoticz system, you need then to call either or both of the following:

[code]http://192.168.1.202:3480/data_request?id=variableset&DeviceNum=&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&variable=Watts&Value=

http://192.168.1.202:3480/data_request?id=variableset&DeviceNum=&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&variable=KWH&Value=[/code]

[quote=“logread, post:5, topic:194580”]Anyway, you could also try the following:

On the Vera (or openLuup system), manually create a device with the two config files below (no implementation file as we just want a dummy device):
device file = “D_PowerMeter1.xml”
device json = “D_PowerMeter1.json”

from the Domoticz system, you need then to call either or both of the following:

[code]http://192.168.1.202:3480/data_request?id=variableset&DeviceNum=&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&variable=Watts&Value=

http://192.168.1.202:3480/data_request?id=variableset&DeviceNum=&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&variable=KWH&Value=[/code][/quote]

@logread: thanks a lot !!! Now I’ve got it working.
There was a minor mistake in your code: “Variable” in stead of “variable” but I forgive you :smiley: :smiley: :smiley:
This is the correct code:

[code]http://192.168.1.202:3480/data_request?id=variableset&DeviceNum=&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&variable=Watts&Value=

[/code]
Where DeviceNum is the devicenumber of the dummy sensor in Vera (obviously).
Again thanks a lot !

@logread:
Do you have experience scripting in Domoticz ?
Thanks to you I know now how to send a value from Domoticz to a virtual powersensor in my Vera. Next step is to get the Watt value from a wallplug in Domoticz and sent it to the virtual sensor in Vera.

Read the value something like:

 local Wattactual = tonumber(otherdevices_svalues["Greenwave1 Power"]) 

Where "Greenwave1 Powe"is the exact name of the device in Domoticz
But this doesn’t work…

[quote=“Mai Pensato, post:7, topic:194580”]@logread:
Do you have experience scripting in Domoticz ?
Thanks to you I know now how to send a value from Domoticz to a virtual powersensor in my Vera. Next step is to get the Watt value from a wallplug in Domoticz and sent it to the virtual sensor in Vera.

Read the value something like:

 local Wattactual = tonumber(otherdevices_svalues["Greenwave1 Power"]) 

Where "Greenwave1 Powe"is the exact name of the device in Domoticz
But this doesn’t work…[/quote]
This forum is probably not the best one to discuss Domoticz scripting, but I think you should rather try:

 local Wattactual = tonumber(otherdevices["Greenwave1 Power"]) 

I know it’s off topic but anyway thanks, I will try this.