Values are not sent to influxdb [Solved]
Moderator: leecollings
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Values are not sent to influxdb
Hello,
I just discovered, maybe I'm overlooking something, that dummy sensors values that are set by a dzvents scripts are not send to influxdb whereas the corresponding sensor is activated in influxdb. If same device value is set with the straight http json command, it is sent to influxdb.
I'm currently running domoticz v3.9139, yes a rather old version. I'm waiting summertime to upgrade my system which is rather complex.
Any ideas on ths matter?
Thank you
I just discovered, maybe I'm overlooking something, that dummy sensors values that are set by a dzvents scripts are not send to influxdb whereas the corresponding sensor is activated in influxdb. If same device value is set with the straight http json command, it is sent to influxdb.
I'm currently running domoticz v3.9139, yes a rather old version. I'm waiting summertime to upgrade my system which is rather complex.
Any ideas on ths matter?
Thank you
Debian buster on NUC and three RPi with buster.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Values are not sent to influxdb
In this this wiki topic you can see why it is not working as you expected.
For most devices dzVents use the ['UpdateDevice'] method as this give advantages. (speed, silent(), checkFirst() to name a few).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.
If you want I can help you with a function to also use the JSON API if a virtual sensor update also need to be pushed to influxdb. I would share it here but the function is different for every sensor type. Maybe it's worthwhile to build a generic one if more forum members and many different sensor types encounter this issue.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
Thanks for quick reply. In other works I falled into the trap! I think I can manage to write the JSON equivalent. Would be great to have it native, but in the meantime I'll do it.
Debian buster on NUC and three RPi with buster.
-
- Posts: 7
- Joined: Monday 15 January 2018 14:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11474
- Location: Woerden, Netherlands
- Contact:
Re: Values are not sent to influxdb
I am facing the same problem for a number of virtual (dummy) devices and I am not familiar with writing JSON script. I noticed for the humidity of a temperature device, the status (wet, dry, etc) is not being send to the influxdb too. Can someone help me.
Cees
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
I have not yet wrote my own scripts. I don't have time to do it now.
Documentation is here: https://www.domoticz.com/wiki/DzVents:_ ... P_requests
It is pretty straightforward though.
Documentation is here: https://www.domoticz.com/wiki/DzVents:_ ... P_requests
It is pretty straightforward though.
Debian buster on NUC and three RPi with buster.
-
- Posts: 7
- Joined: Monday 15 January 2018 14:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11474
- Location: Woerden, Netherlands
- Contact:
Re: Values are not sent to influxdb
Thanks for your advice. I was not able to code a push of the data using the domoticz.openUrl statement. This was causing a error statement in the log file. I have now replaced the statement using os.execute and the curl command to peform the data to be pushed to influxdb on another raspberryPI.
I am using the
local function DumpIn (pVar, pValue, pFormat)
local Prefix = "curl -i -XPOST 'http://000.000.000.00:8086/write?db=huis&precision=m' --data-binary "
local PostFix = "'" .. "Calculation,name=" .. pVar .. string.format (" value=" .. pFormat .."'", pValue)
os.execute(Prefix .. PostFix)
domoticz.log(Prefix .. PostFix, domoticz.LOG_INFO)
return 0
end
I am using the
local function DumpIn (pVar, pValue, pFormat)
local Prefix = "curl -i -XPOST 'http://000.000.000.00:8086/write?db=huis&precision=m' --data-binary "
local PostFix = "'" .. "Calculation,name=" .. pVar .. string.format (" value=" .. pFormat .."'", pValue)
os.execute(Prefix .. PostFix)
domoticz.log(Prefix .. PostFix, domoticz.LOG_INFO)
return 0
end
Cees
-
- Posts: 7
- Joined: Monday 15 January 2018 14:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11474
- Location: Woerden, Netherlands
- Contact:
Re: Values are not sent to influxdb
Is it possile to query the InFluxDB transfer definition table for virtual devices? Using this query to develop a generic dzventz script to send the data (on a minute) from the virtual devices using a OpenUrl/JSON statement?
Advantage: users (like me) with little knowlegde can send data too from virtual device by adding them in the INFluxDB transfer definition table without any coding.
Advantage: users (like me) with little knowlegde can send data too from virtual device by adding them in the INFluxDB transfer definition table without any coding.
Cees
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
This instruction worked out of the box. Replace IDX by your own
Code: Select all
domoticz.openURL('http://ipaddress:port/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=90;W;0;0;30;30')
Debian buster on NUC and three RPi with buster.
-
- Posts: 7
- Joined: Monday 15 January 2018 14:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11474
- Location: Woerden, Netherlands
- Contact:
Re: Values are not sent to influxdb
Command reports an error:
2019-06-17 16:24:02.385 Error: Error opening url: http://000.000.000.00:8086/json.htm?typ ... ;0;0;30;30
2019-06-17 16:24:02.385 Error: Error opening url: http://000.000.000.00:8086/json.htm?typ ... ;0;0;30;30
Cees
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
On my side I have no issues. What is the exact instruction used?
Do you confirm that your port is 8086, default is 8080?
Do you confirm that your port is 8086, default is 8080?
Debian buster on NUC and three RPi with buster.
-
- Posts: 58
- Joined: Saturday 27 January 2018 20:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Values are not sent to influxdb
With thanks to Waaren,
Put this is your global data
Use examples:
Put this is your global data
Code: Select all
pushToInfluxdb = function (domoticz, nValue, Device, ...)
local args = {...}
local sValue = ""
for _,value in ipairs(args) do
sValue = sValue .. tostring(value) .. ';'
end
if #sValue > 1 then
sValue = sValue:sub(1,-2)
end
local tempUrl = "http://192.xxx.x.xxx:8080/json.htm?type=command¶m=udevice&idx=" .. Device .. '&nvalue=' .. (nValue or 0) ..
'&svalue=' .. sValue
domoticz.openURL({
url = tempUrl,
method = 'GET',
})
end
},
Use examples:
Code: Select all
domoticz.helpers.pushToInfluxdb(domoticz, nValue, 3617, tostring(winddirection), winddirectionstr, tostring(Speed*10), tostring(Gust*10), tostring(Temperature), tostring(gevoelsTemp))
domoticz.helpers.pushToInfluxdb(domoticz, nValue, 3665, tostring(Rain),tostring(Rain24h))
domoticz.helpers.pushToInfluxdb(domoticz, nValue, 3749, tostring(sunpower))
domoticz.helpers.pushToInfluxdb(domoticz, nValue, 3750, tostring(Zicht))
domoticz.helpers.pushToInfluxdb(domoticz, tostring(Humidity), 3751)
-
- Posts: 7
- Joined: Monday 15 January 2018 14:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11474
- Location: Woerden, Netherlands
- Contact:
Re: Values are not sent to influxdb
Many thanks for your quick response and your help. However I am getting a little lost in your advice. As I mention before the command:
local function DumpIn (pVar, pValue, pFormat)
local Prefix = "curl -i -XPOST 'http://000.000.000.00:8086/write?db=huis&precision=m' --data-binary "
local PostFix = "'" .. "Calculation,name=" .. pVar .. string.format (" value=" .. pFormat .."'", pValue)
os.execute(Prefix .. PostFix)
return 0
With the example:
a = DumpIn ("Graaddagen", domoticz.devices('GraadDagen').counter, "%.1f")
works fine.
Question: In your statements I do not see to which database the data needs to be send. In my case the database is “huis”. How does the system know this in your statement?
I push the data via port 8086 from Domoticz to the InfluxDB (not retrieving data!!!).
However I want to program it neatly and remove de old fashioned way using de os.execute command.
Question: Why should I use the method=“GET” in the openURL statement, while I want to push the data (method=”POST”)???
local function DumpIn (pVar, pValue, pFormat)
local Prefix = "curl -i -XPOST 'http://000.000.000.00:8086/write?db=huis&precision=m' --data-binary "
local PostFix = "'" .. "Calculation,name=" .. pVar .. string.format (" value=" .. pFormat .."'", pValue)
os.execute(Prefix .. PostFix)
return 0
With the example:
a = DumpIn ("Graaddagen", domoticz.devices('GraadDagen').counter, "%.1f")
works fine.
Question: In your statements I do not see to which database the data needs to be send. In my case the database is “huis”. How does the system know this in your statement?
I push the data via port 8086 from Domoticz to the InfluxDB (not retrieving data!!!).
However I want to program it neatly and remove de old fashioned way using de os.execute command.
Question: Why should I use the method=“GET” in the openURL statement, while I want to push the data (method=”POST”)???
Cees
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Values are not sent to influxdb
There seems to be a misunderstanding here. Your curl command pushes the data directly to the influxDB while the example from Maxx forces the update in such a way to domoticz that it will be seen by the domoticz push mechanism. From there on domoticz will handle the transfer to influxdb.
The example from Maxx for the global_data helper part can also be simplified to
Code: Select all
pushToInfluxdb =
function (dz, nValue, idx, ...)
local url = dz.settings['Domoticz url'] .. '/json.htm?type=command¶m=udevice&idx=" ..idx ..
'&nvalue=' .. (nValue or 0) ..
'&svalue=' .. table.concat({...},";")
dz.openURL(url)
end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
From the architecture standpoint, IMHO the worst solution is to write directly to influxdb. It is far better to let domoticz do all it can do. Warren function is the most elegant approach, so I will change, again;) my code. Anyhow the solution I implemented is currently running without a glitch.
Performance wise what would be the best one?
Performance wise what would be the best one?
Debian buster on NUC and three RPi with buster.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Values are not sent to influxdb
The direct approach you used will be the quickest but in comparable situations I have never measured a difference. So less then 0.001 seconds per call. Given that this code is without loops and without calls to other systems, I would not really think about performance twice.Number8 wrote: ↑Tuesday 18 June 2019 17:37 From the architecture standpoint, IMHO the worst solution is to write directly to influxdb. It is far better to let domoticz do all it can do. Warren function is the most elegant approach, so I will change, again;) my code. Anyhow the solution I implemented is currently running without a glitch.
Performance wise what would be the best one?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Values are not sent to influxdb
Fair enough, thanks waaren
Debian buster on NUC and three RPi with buster.
-
- Posts: 7
- Joined: Friday 26 July 2019 11:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10
- Location: Italia
- Contact:
Re: Values are not sent to influxdb
I created this script in lua, and it does not send me data on influxdb running on a NAS, I would like to use the Maxx script to trigger Push on Domoticz, but I can't figure out how to use the function.waaren wrote: ↑Tuesday 18 June 2019 17:08 There seems to be a misunderstanding here. Your curl command pushes the data directly to the influxDB while the example from Maxx forces the update in such a way to domoticz that it will be seen by the domoticz push mechanism. From there on domoticz will handle the transfer to influxdb.
The example from Maxx for the global_data helper part can also be simplified to
Code: Select all
pushToInfluxdb = function (dz, nValue, idx, ...) local url = dz.settings['Domoticz url'] .. '/json.htm?type=command¶m=udevice&idx=" ..idx .. '&nvalue=' .. (nValue or 0) .. '&svalue=' .. table.concat({...},";") dz.openURL(url) end
Thank you
Code: Select all
local dev_pzem1 ="PZEM" -- Nome device
local words = {}
local function updatenum(dev, value1)
local cmd = string.format("%d|0|%f", otherdevices_idx[dev], value1)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
commandArray = {}
local pzem_power = tostring(otherdevices_svalues[dev_pzem1])..';'
for w in string.gmatch(pzem_power, "([^;]*);") do
table.insert(words, w)
end
if (words[1] ~= '-1.00') then
updatenum('PZEM_Voltage', words[1])
--commandArray['UpdateDevice'] = '67|0|'..words[1]
end
return commandArray
[/quote]
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Values are not sent to influxdb
your script is classic domoticz Lua while the function you want to use is dzVents Lua. These two does mix very well as they use different data and functions in the background.
So you need to switch to dzVents or look elsewhere on the forum to see if you can implement a similar openURL in your script.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 7
- Joined: Friday 26 July 2019 11:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10
- Location: Italia
- Contact:
Re: Values are not sent to influxdb
Have patience, I'm rewriting in DzVents, but I didn't understand much ...
Code: Select all
return {
on = {
devices = {
'PZEM'
}
},
execute = function(domoticz, device)
local Domoticz_url ='192.168.2.10'
print('1 tensione: '..device.rawData[1])
print('2 corrente: '..device.rawData[2])
print('3 potenza: '..device.rawData[3])
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
domoticz.helpers.pushToInfluxdb(domoticz, 0, 67, device.rawData[1])
pushToInfluxdb = function (dz, nValue, idx, ...)
local url = dz.settings[Domoticz_url] .. '/json.htm?type=command¶m=udevice&idx=' .. idx ..
'&nvalue=' .. (nValue or 0) ..
'&svalue=' .. table.concat({...},";")
dz.openURL(url)
end
end
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Values are not sent to influxdb
Can you try this ?
I added something to prevent an endless loop if you want the script to be triggered by the same device as you want to have pushed to influx.
Code: Select all
return {
on = {
devices = {
'PZEM'
}
},
data = { lastExecutionTime = { initial = 0 }},
execute = function(dz, item)
dz.log('Device ' .. item.name .. ' was changed', dz.LOG_INFO)
local function pushToInfluxdb(idx , nValue, rawData )
local sValue = table.concat(rawData,';')
local nValue = nValue or 0
dz.log('idx: ' .. idx, dz.LOG_DEBUG)
dz.log('nValue: ' .. nValue, dz.LOG_DEBUG)
dz.log('sValue: ' .. sValue, dz.LOG_DEBUG)
local url = dz.settings['Domoticz url'] .. '/json.htm?type=command¶m=udevice&idx=' .. idx ..
'&nvalue=' .. nValue ..
'&svalue=' .. sValue
dz.openURL(url)
end
if dz.data.lastExecutionTime < ( dz.time.dDate - 5 ) then
pushToInfluxdb( item.idx, 0, item.rawData )
dz.data.lastExecutionTime = dz.time.dDate
else
dz.log('Too soon after last update; we don\'t want an endless loop', dz.LOG_DEBUG)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest