This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

API Actual Power Efergy Engage Meter
#1
Hello everybody,
  
I have installed an Efergy Engage energy meter. By using the ‘getCurrentValuesSummary-url’ it returns:
 
[{"cid":"PWER","data":[{"1612478705000":2101}],"sid":"841163","units":"W","age":10}]
 
The 'sid' is the same every time. The number 2101 is the actual Power Consumption and changes. The big number in front of 2101 is also changing at every update (seems to be time related).
 
I would like to store the actual Power Consumption in a Virtual Object. Can you help me? Thank you very much!
 
This is my complete script:
 
json = require('json')
http = require('socket.http')
escape = require('socket.url').escape
require("user.telegram")
 
token = 'xxx'
url = 'https://private-anon-f58c0b5ab4-energyhiveapi.apiary-proxy.com/mobile_proxy/getCurrentValuesSummary?token=' .. escape(token)
 
CurrentValues = http.request(url)
--log(CurrentValues)
 
if CurrentValues then
 
  efergydatatable = json.pdecode(CurrentValues)
  --[[
  log (efergydatatable)
  
  cid= efergydatatable[1].cid
  log(cid)
  
  units= efergydatatable[1].units
  log(units)
  
  sid= efergydatatable[1].sid
  log(sid)
  
  age = efergydatatable[1].age
  log(age)
  
  data = efergydatatable[1].data
  log(data)
  ]]--
  
 
else
 
message("API Efergy Engage Hub met energiemeting Silverspas mislukt. Controleer de instellingen.")
 
end
Reply
#2
Try this:
Code:
if CurrentValues then
  efergydatatable = json.pdecode(CurrentValues)
  data = efergydatatable[1].data[1]
  key = next(data)
  consumption = data[ key ]
  grp.checkupdate('32/1/1', consumption)
end
Reply
#3
Wow! Solved. Thank you very much!!!
Reply


Forum Jump: