DataYours - monitoring energy usage

Hi akbooer,

I’ve investigated the two options you suggested but in my case peharps the better solution for me is to write a lua code in the local VeraEdge to run periodically that read wsp file containing the power values (with a retention of one minute in a day) and calculate the energy (kwh) .

Have you a sample code to read a wsp file (I think in JSON format) and the single “datapoints” ? Can I use in lua (VeraEdge) a DY http call to render the wsp file in JSON ?

tnks

donato

This post addresses both those questions,but ask again if you need more…
http://forum.micasaverde.com/index.php/topic,35619.msg275072.html#msg275072

This post addresses both those questions,but ask again if you need more…
http://forum.micasaverde.com/index.php/topic,35619.msg275072.html#msg275072[/quote]

tnks akbooer ,

I’ll try to understand something from your precious post.

tnks again

donato

Hi akbooer,

if I access the whisper file directly and I want to get the value from the start of the day until the time of run, is it correct if I use in the fetch call the time as os.time{hour=00, min=00} ?

tnks

No, that’s not a valid specification for time. If you’re talking about the current day, then you have to get the table for today, and modify the HH:MM:SS to zero, like this:

local t = os.date "*t"
print (pretty(t))

print (os.date "%c")
t.hour = 0
t.min = 0
t.sec = 0

print (pretty(os.date ("*t", os.time(t))))
print (os.date ("%c", os.time (t)))

Which gives, as output:

{
  day = 3,
  hour = 18,
  isdst = true,
  min = 14,
  month = 6,
  sec = 32,
  wday = 6,
  yday = 155,
  year = 2016
}
Fri Jun  3 18:14:32 2016
{
  day = 3,
  hour = 0,
  isdst = true,
  min = 0,
  month = 6,
  sec = 0,
  wday = 6,
  yday = 155,
  year = 2016
}
Fri Jun  3 00:00:00 2016

THANKS !!

Hi akbooer,

do you think is possible to have, for the same metric (for example Power-Watt), two different archive files with different storage schemas and aggregations.

At the moment I’ve defined two variables with the same value (Watt) in the Vera Controller and I’ve defined two storage schemas-aggregation in DY.

tnks

donato

There’s several ways to do this:

[ol][li]have multiple DataCache daemons running on different machines writing to different databases (perhaps not what you want)[/li]
[li]use the user-defined processing in DataWatcher (described here http://forum.micasaverde.com/index.php/topic,37119.msg278081.html#msg278081, and in the latest documentation) to generate multiple metric names for the given input[/li][/ol]

(2) is probably what you’re needing.

So yes, out-of-the-box you can do it today.

There’s several ways to do this:

[ol][li]have multiple DataCache daemons running on different machines writing to different databases (perhaps not what you want)[/li]
[li]use the user-defined processing in DataWatcher (described here http://forum.micasaverde.com/index.php/topic,37119.msg278081.html#msg278081, and in the latest documentation) to generate multiple metric names for the given input[/li][/ol]

(2) is probably what you’re needing.

So yes, out-of-the-box you can do it today.[/quote]

Hi akbooer,

I’ve remote Veras with DataWatcher that send data to a centralized Rpi-Luup-DY via DataCache. Can I use L_DataUser on centralized Luup-DY or do I have to use it on remote Veras ?
In last case is it possible ?

tnks

donato

[quote=“d55m14, post:49, topic:186813”]I’ve remote Veras with DataWatcher that send data to a centralized Rpi-Luup-DY via DataCache. Can I use L_DataUser on centralized Luup-DY or do I have to use it on remote Veras ?
In last case is it possible ?[/quote]

The user-defined processing works in DataWatcher, so the easiest approach is to have all the Veras doing the job. HOWEVER… as of a recent update, DataWatcher also acts as a proper relay for Whisper plaintext messages, so a possible configuration would be to run DataWatcher on your central RPi with your user-defined processing and have all the remote DataWatcher send their data to that, rather than directly to DataCache.

I’ve never set up this configuration myself, but then DataYours is so modular that there are lots of configurations I’ve never tried. Your have to set up this parameter on the central DataYours device variables:

LINE_RECEIVER_PORT = 2013

(2013 is the traditional value for this port.) You have to change the DESTINATIONS parameter in your remote device to include that port too.

I wonder if you’re able to try this out before setting it loose on your whole installation? Ask again if this is not clear. Maybe a picture will help?

Hi akbooer

May i have on the centralized luup DY either DataCache and DataWatcher active as receivers of the remote veras ? This is essential for testing purpose .
A picture will help surely.
Tnks

Donato

Yes, you can have both running together. I’ll try and make a picture.

See attached…

See attached…[/quote]

Hi akbooer,

thank you very much. It’s very clear.

I suppose I may need your help again to check the lua Datauser routine.

tnks

donato

Hi akbooer,

I’m trying to define L_Datauser.lua for my scope.

I want to write every metric like “Vera-45103914.012.urn^upnp-org^serviceId^VContainer1.Variable3” and the same value/timestamp to the wsp file "Vera-45103914.012.urn^upnp-org^serviceId^VContainer1.kwdaily3 associated to another schemas/aggregation rule.

So I’ve to modify the L_Datauser.lua module but I’m not sure.

The code I’ve to add is :

if string.match(metric, “Variable”) then
string.gsub(metric, “Variable”, “kwdaily”)
end

is it correct ?

tnks donato

Not quite.

If I understand correctly, you want to change any incoming metric containing “Variable” in the variable name to “kwdaily”.

If so, then you need to replace the entire contents of the L_DataUser.lua “run” routine with this:

function run (metric, value, time)  
  
  local x,n = metric: gsub ("Variable", "kwdaily")
  
  local i = 0
  local metrics = {metric, n>0 and x or nil}
 
  return function ()
    i = i + 1
    return metrics[i], value, time
  end
end

If you mean to do something different, then the code will be different!

Hi akbooer,

not quite, I want to write any metric containing “Variable” in the name, and another metric with the same value/time having in the name the word “Variable” substituted with “kwdaily”. Simply I wanto to duplicated the metric with a different name so I can apply a different schemas/aggregation.

Ask if not clear.

tnks

Yes, that’s what I think this code does.

Fine, I’ll try as soon as possible.

tnks and have a nice we.

Hi akbooer,

excuse me but must the follwing instruction :

module ("L_DataUser", package.seeall)

remain in the L_Datauser.lua module ?

tnks

donato