Author Topic: Energy Monitor - How to setup periodic KW/h notifications?  (Read 6314 times)

Offline frankflorida

  • Sr. Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
I have installed the whole house energy meter and can read via  login the KW/h. But instead logging into my account I like to setup that at 2 times a day the KW/h usage is send by email. The notification tab for the meter allows only 'notification by high or low watt usage" and not a periodic sending of the KW/h readings. Can this be done by a code? Any help is very appreciated. I am trying to setup a system for vacation rentals where guests have to pay for their power usage without the need of the property manager to drive out and read the meters.

Offline akbooer

  • Master Member
  • *******
  • Posts: 5958
  • Karma: +258/-69
  • "Less is more"
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #1 on: May 02, 2013, 03:09:10 am »
You can certainly read the meter periodically.  Presumably your meter presents a standard energy metering service within Vera, so the following:

Code: [Select]
local kWh = luup.variable_get( "urn:micasaverde-com:serviceId:EnergyMetering1", "KWH", device)

placed in the Luup tag of a scene which is scheduled to run twice a day should do half of the trick (with "device" set to the appropriate device number for the meter.)

I'm not much into notifications, but there are several mechanisms, including additional plugins, which enable this. HTH.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 10070
  • Karma: +761/-141
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #2 on: May 02, 2013, 08:02:28 am »
Once you step away from the standard Vera Notifications this gets more complicated.

There are two parts to this problem.
  • Automating the collection of the data.
    This can be done with a schedule input for a Scene.
  • Reporting the result via email.
    You will need to decide on a Plugin to forward a notification, Vera Alerts, Push, SMTP ...
    You will need to place the data that you access per @akbooer post into the message you send.
    This will all be done via LUUP code for the Scene. The details of which are dependent on which plugin you use.

This can be done without LUA code if you use the Vera Alerts Plugin. But the Vera Alerts and SMTP have similar, but complicated, email configuration process.


Offline akbooer

  • Master Member
  • *******
  • Posts: 5958
  • Karma: +258/-69
  • "Less is more"
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #3 on: May 03, 2013, 07:13:04 am »
Note also the discussion about this on the following thread:

http://forum.micasaverde.com/index.php/topic,14680.0.html
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline nono240

  • Sr. Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #4 on: May 03, 2013, 07:13:57 am »
See my answer to a previous similar post:

Quote
First of all, please install and setup the SMTP Notification plugin. Then, create a scheduled scene, and insert the following code in the luup section :

Code: [Select]
local powerDeviceId = <your device id>
local smtpDeviceId = <your smtp device id>

local kwatts = luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH", powerDeviceId)
luup.call_action("urn:upnp-org:serviceId:SmtpNotification1", "SendEmail", { Recipient_Name="Rental #42", Recipient_eMail="rental@mybusiness.com", Subject= "Energy from Rental #42", Message="Power Meter="..kwatts }, smtpDeviceId)
return true


Personnaly, I wanted to have a KWH meter device on my UI, but resetted every day. To do so, I manually created a 2nd energy meter (virtual), and two scenes:


Scene #1 "Save daily KWH", running everyday at midnight:
Code: [Select]
local realDeviceID = 63
-- get current KWH
local kw = luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH", realDeviceID )
-- and save it in a user created variable
luup.variable_set(realDeviceID, "KWH24", kw, realDeviceID)
return true

Scene #2 "Update Virtual Power Meter", scheduled every 15min :
Code: [Select]
local realDeviceID = 63
local virtualDeviceID = 65

-- get the current KWH
local kw = luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH", realDeviceID)
-- get the previous KWH value at midnight
local kw24 = luup.variable_get(realDeviceID, "KWH24", realDeviceID)

-- update virtual device
if kw24 == nil then -- may be true the very first time
    luup.variable_set(realDeviceID, "KWH24", kw, realDeviceID)
    kw24 = kw
end

luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1", "Watts", 1000*(kw-kw24), virtualDeviceID)
luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1", "KHW", kw, virtualDeviceID)

return true
« Last Edit: May 03, 2013, 07:42:37 am by nono240 »

Offline NAC

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #5 on: November 03, 2014, 04:14:22 am »
Hi nono240

I'm found very interesting the option of create a virtual energy meter. (I'm uploading watt info into plotwatt and bidgely web sites )

I was trying to do it, but I only found info of virtual switches dimmers, thermostat.... but not energy meters.

Please can you share the xml file  :)

Thanks in advance

Offline icare

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +0/-0
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #6 on: November 06, 2016, 04:26:20 am »
Did you ever got further info to setup a virtual energy meter device. I'm interested in this too such that my data from the French EDF Teleinfo read by Arduino shield can be stored in Vera.
Rgds
Dick

Offline Mike Yeager

  • Hero Member
  • *****
  • Posts: 537
  • Karma: +6/-12
Re: Energy Monitor - How to setup periodic KW/h notifications?
« Reply #7 on: November 06, 2016, 02:51:51 pm »
I haven't installed mine as of yet, but this is interesting and shows promise...