Page 1 of 1
Dzvent push data to influxdb
Posted: Monday 19 November 2018 14:05
by sexyboy
Hi there,
I'm trying to push some custom metrics to influxdb via domoticz.openURL but I've not managed to succeed so far.
The problem I'm hitting it that the buddy of the request needs to be in binary format.
Please see below:
Code: Select all
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
Influxdb man page:
https://docs.influxdata.com/influxdb/v1 ... ting_data/
Has anyone tried this before?
Thanks in advance.
Re: Dzvent push data to influxdb
Posted: Saturday 24 November 2018 17:25
by mehikr
Hi, I am using corlysis.com
Code: Select all
curl -i -XPOST 'https://corlysis.com:8086/write?db=test_db' -u token:YOUR-SECRET-PASSWORD --data-binary "meas_test,place=garden value=20.64"
Re: Dzvent push data to influxdb
Posted: Sunday 02 December 2018 22:28
by papoo
influxdb request don't work's with space in name, example :
Code: Select all
curl -i -XPOST 'http://127.0.0.1:8086/write?db=domoticz' --data-binary 'Usage,idx=197,name='Compteur Prises' value=35618.144'
don't work
Code: Select all
curl -i -XPOST 'http://127.0.0.1:8086/write?db=domoticz' --data-binary 'Usage,idx=197,name='Compteur-Prises' value=35618.144'
work fine
Re: Dzvent push data to influxdb
Posted: Sunday 02 December 2018 22:34
by papoo
my little script for dummy counters data (this counters don't works with domoticz export data)
Code: Select all
-- v1.00 Auteur papoo
local influxdbUrl = 'http://127.0.0.1'
local influxdbPort = '8086'
local BDD = 'domoticz'
return {
active = true,
on = { devices = { 'Compteur*'}},
logging = { level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut ĂȘtre actif; commenter les autres
-- level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = "Export compteurs influxDB v1.0 : " },
execute = function(domoticz,compteur)
local nom = string.gsub(compteur.name, ' ', '-')
local typeDonnee = 'Usage'
os.execute("curl -i -XPOST '"..influxdbUrl..":"..influxdbPort.."/write?db="..BDD.."' --data-binary '"..typeDonnee..",idx="..compteur.idx..",name='"..nom.."' value="..compteur.counter.."'")
domoticz.log("curl -i -XPOST '"..influxdbUrl..":"..influxdbPort.."/write?db="..BDD.."' --data-binary '"..typeDonnee..",idx="..compteur.idx..",name='"..nom.."' value="..compteur.counter.."'", domoticz.LOG_DEBUG)
domoticz.log(compteur.idx, domoticz.LOG_DEBUG)
domoticz.log(compteur.name, domoticz.LOG_DEBUG)
domoticz.log(compteur.counter, domoticz.LOG_DEBUG)
end
}
Re: Dzvent push data to influxdb
Posted: Monday 10 December 2018 23:41
by xury
Today I just made a script with push data to influxdb in pure dzVent
It's is my first script so in not so nice, but works well:
Code: Select all
return {
on = {
timer = { 'every minute' },
devices = { 14 }
},
execute = function(domoticz, item)
if (item.isTimer) then
if (domoticz.devices(14).nValue == 3) then
domoticz.devices('Stankot').updateCustomSensor(1,1)
-- print (domoticz.devices('Stankot').rawData)
elseif
(domoticz.devices(14).nValue == 1) then
domoticz.devices('Stankot').updateCustomSensor(0,0)
-- print (domoticz.devices('Stankot').rawData)
end
domoticz.openURL({
url = 'http://127.0.0.1:8086/write?db=domoticz&u=domoticz&p=domoticz&precision=ms',
method = 'POST',
headers = 'application/x-www-form-urlencoded',
callback = 'mycallbackstring',
postData = 'stankotla value=' .. domoticz.devices(67).state
})
end
if (item.isDevice) then
if (domoticz.devices(14).nValue == 3) then
domoticz.devices('Stankot').updateCustomSensor(1,1)
-- print (domoticz.devices('Stankot').rawData)
elseif
(domoticz.devices(14).nValue == 1) then
domoticz.devices('Stankot').updateCustomSensor(0,0)
-- print (domoticz.devices('Stankot').rawData)
end
domoticz.openURL({
url = 'http://127.0.0.1:8086/write?db=domoticz&u=domoticz&p=domoticz&precision=ms',
method = 'POST',
callback = 'mycallbackstring',
postData = 'stankotla value=' .. domoticz.devices(67).state
})
end
end
}
Re: Dzvent push data to influxdb
Posted: Monday 24 December 2018 11:00
by Derik
Dear all..
Someone can explain what i can do with this scripts?
Is this perhaps a solution for my problem:
viewtopic.php?f=6&t=26209&e=1&view=unread#unread
Is it perhaps possible to push multiple dummy devices to Grafana...
I need some option to make in grafana my dummy switches visible.
Because domoticz is not pushmy dummy's into influxDB:
I found this in the wiki:
Code: Select all
Note to Virtual / Dummy sensors: If the HTTP link or MQTT is not sending any values to the database, check the update method of your virtual sensors in your scripts. If using the ['UpdateDevice'] method, you will directly write the value to the internal database without triggering an HTTPlink or MQTT update for this sensor. Better is to use the JSON API of Domoticz and update your virtual sensors this way.
https://www.domoticz.com/wiki/HttpLink
Only this part i do not understand...
I use this script, and i cannot get it into influxDB:
Code: Select all
local function DeviceUpdate(idx, value1)
local cmd = string.format("%d|0|%.2f", idx, value1)
--print(cmd)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
Debug = "Yes" -- Debugging aanzetten ("YES") of uitzetten ("NO")
commandArray = {}
local m = os.date('%M')
if (m % 4 == 0) then -- script loopt iedere 4 minuten
-- Variabelen instellen
local temperature_name = 'D.M.: Gemiddeld Buiten D'
local temperature_idx = otherdevices_idx[temperature_name]
local uitlees_name = 'Buiten: Terras'
local uitlees_idx = otherdevices_idx[uitlees_name]
--Temperaturen van afgelopen 24 uur opvragen
local sQuery = 'curl "http://192.168.5.70:8080/json.htm?type=graph&sensor=temp&idx='..tostring(uitlees_idx)..'&range=day"'
local handle=assert(io.popen(sQuery))
local raw = handle:read('*all')
handle:close()
--Ontvangen waarden verwerken
json = assert(loadfile '/home/pi/domoticz/scripts/lua/JSON.lua')()
local jsonData = json:decode(raw)
if Debug=='YES' then
print (jsonData.title)
print (jsonData.status)
print (jsonData.result[1].d)
print (jsonData.result[1].te)
end
--Gemiddelde temperatuur van afgelopen 24 uur bepalen
local sum = 0
local ave = 0
local elements = #jsonData.result
for i = 1, elements do
sum = sum + jsonData.result[i].te
end
ave = sum / elements
if Debug=='YES' then
print('Gemiddeld: '..tostring(ave))
end
--Gemiddelde temperatuur opslaan in virtuele temperatuur sensor
UpdateDevice --DeviceUpdate(temperature_idx,ave)
end
return commandArray
So i hope someone
