Code: Select all
otherdevices_svalues['Gas Meter']
Moderator: leecollings
Code: Select all
otherdevices_svalues['Gas Meter']
Looked into that but this works with JSON. Is there anyway to do this with using LUA only without using a curl command?stlaha2007 wrote:When i do a jsonnrequest in my browser i'll get a replay with counter and countertoday...
It looks like the ''default'' lua command replies with the counter. Maybe (i don't have it at the moment) you need to form an alternative command...
Take a look at the wiki scripts/examples. There are some that doing simular things [Mindergas or Daily Notification Energy Usage]
Code: Select all
-- LUA to get GASMETER usage
--###############################
-- Load necessary Lua libraries
--###############################
http = require "socket.http";
socket = require "socket";
https = require "ssl.https";
JSON = require "JSON";
--Get values of previous 8 days
local t, jresponse, status, decoded_response,idx
idx=376 -- IDX of the GASMETER
t = "http://192.168.0.xx:8080/json.htm?type=graph&sensor=counter&range=week&idx="..tostring(idx)
jresponse, status = http.request(t)
decoded_response = JSON:decode(jresponse)
result = decoded_response["result"]
--
-- List all data
--
for i = 1, #result do
record = result[i]
if type(record) == "table" then
day = record["d"]
value = record["v"]
print(os.date("%X").." "..i.." Gebruik dag="..day.." gebruik="..value)
end
end
--
-- Todays data
--
print(os.date("%X").." vandaag="..result[8]["d"].." gebruik="..result[8]["v"])
Jos, Thanks for pointing at this...jvdz wrote: json library
Jos
Any device that generates a set of graphs should work.dutchdevil83 wrote:On other hand with this script i can also get history values from other sensors right?
I would like to do the same and I have seen this degrees days in the settings, but have no idea where Domoticz outputs that.edraket wrote:Hi Jos,
Excellent piece of code, thanks for sharing.
...
I assume that it works as well with the degree days calculation of Domoticz, because that's what I want to do: create a LUA scripts that calculate the daily gas consumption based on the degree days and put that in a counter![]()
Thanks, Ed
Users browsing this forum: No registered users and 1 guest