04.02.2021, 23:12
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
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