Data not in InfluxDB  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Data not in InfluxDB

Post by MeAlbert »

Hello.
From other post I understood that virtual device will not be pushed to Inlux even if you set this up in settings - push data - influx.
I found a program that I modified and put in dzVents. After start I do not get any error message but it is not shown in the influx database.

Code: Select all

return {
    on = {
        devices = {
            'WP Opgewekt'
        }
    },
        
    logging = { level = domoticz.LOG_DEBUG,
                marker = 'Push to Influx',
              },

    execute = function(dz, item)

        dz.log('Device ' .. item.name .. ' was changed ' .. item.rawData[1], dz.LOG_DEBUG)
        
        local function pushToInfluxdb(idx , nValue, myData )
            local nValue = nValue or 0
            dz.log('idx: ' .. idx, dz.LOG_DEBUG)
            dz.log('nValue: ' .. nValue, dz.LOG_DEBUG)
            dz.log('sValue: ' .. myData, dz.LOG_DEBUG)
            
            local url = dz.settings['Domoticz url'] ..  '/json.htm?type=command&param=udevice&idx=' .. idx  ..
                        '&nvalue=' .. nValue ..
                        '&svalue=' .. myData 
            dz.openURL(url)
        end
        
        pushToInfluxdb(64, 0, tostring(dz.devices(64).rawData[1]))
        
    end
}
In the log file I get this series of messges.

Code: Select all

2020-03-13 17:08:06.157 Status: dzVents: Debug: Push to Influx: Device WP Opgewekt was changed 1564
2020-03-13 17:08:06.157 Status: dzVents: Debug: Push to Influx: idx: 64
2020-03-13 17:08:06.157 Status: dzVents: Debug: Push to Influx: nValue: 0
2020-03-13 17:08:06.158 Status: dzVents: Debug: Push to Influx: sValue: 1564
2020-03-13 17:08:06.158 Status: dzVents: Debug: Push to Influx: OpenURL: url = http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=64&nvalue=0&svalue=1564
2020-03-13 17:08:06.158 Status: dzVents: Debug: Push to Influx: OpenURL: method = GET
2020-03-13 17:08:06.159 Status: dzVents: Debug: Push to Influx: OpenURL: post data = nil
2020-03-13 17:08:06.159 Status: dzVents: Debug: Push to Influx: OpenURL: headers = nil
2020-03-13 17:08:06.159 Status: dzVents: Debug: Push to Influx: OpenURL: callback = nil
What do I do wrong??
Edit
I now see that the setting in Domoticz ( at settings - push data - influxdb.) is 8086 while it posts the data to 8080. But I see nowhere in the script where I can adapt that.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Data not in InfluxDB

Post by waaren »

MeAlbert wrote: Friday 13 March 2020 17:21 I now see that the setting in Domoticz ( at settings - push data - influxdb.) is 8086 while it posts the data to 8080. But I see nowhere in the script where I can adapt that.
If you look in the thread where this was initially posted you will read that the pushToInfluxdb() function does not send anything directly to influx but it updates the device in domoticz in such a way that domoticz will push it to influxdb.
Portnumber 8080 is your domoticz port and that is what the function will use to update the device.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Data not in InfluxDB

Post by MeAlbert »

OK. But how do I get the data in influx then?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Data not in InfluxDB

Post by waaren »

MeAlbert wrote: Friday 13 March 2020 18:28 OK. But how do I get the data in influx then?
domoticz push mechanism will do this.
please read this topic Maybe that will help you to understand what this function is for and how domoticz will take care of the push to influx.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Data not in InfluxDB

Post by MeAlbert »

@Waaren
Sorry but from this topic I used the code. Reading the wiki links dont help me at all. I get more confused.
I understand that I should not use update dives as I learned but what to use instead?? I am totally lost.
I cant find anywhere an example where update devices is replaced by a json example.

I also do not understand that if you use a dummy device it will not send data to influx although everything looks ok. I put several devices there. Did not work, removed everything, put it in again etc. Very frustrating. A simple note that dummy devices don't work there would help a lot of people. Or a good example in the wiki although good examples in the wiki are rare. (for starters that is even if they have some programming knowledge)
Sorry but are frustrated.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Data not in InfluxDB

Post by waaren »

MeAlbert wrote: Friday 13 March 2020 19:20 Or a good example in the wiki although good examples in the wiki are rare. (for starters that is even if they have some programming knowledge)
Sorry but i can not make it more clear than what I already explained in the referred topic.

About the lack of good examples in the wiki: The wiki if for us but also by us. Everyone can contribute !
There are over 20K members of this forum and on average 6 -7 time more guests then members visiting this forum. So 140K people benefiting from this forum and if I look at the contributions made to the wiki I see 5 different names in the last 6 months. That is 5 ! Not 50 or 500 but 5
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MeAlbert
Posts: 65
Joined: Friday 06 December 2019 14:23
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Contact:

Re: Data not in InfluxDB  [Solved]

Post by MeAlbert »

@Waaren
What I get out the link you send is that the problem is different for different devices. I have read the link and all links in that link. What I see is examples of getting json data from a http request. And that I understand and even use in a script.
But I see nowhere a clue on how to replace "update Device" by a json command.
I want to use it in this script/

Code: Select all

return {
	on = 
	{
		timer = { 'every minute' }
	},
	logging = 
	{
        level = domoticz.LOG_DEBUG, -- for debugging
        level = domoticz.LOG_INFO,
        marker = "WP vermogen per uur"
    },
	data = 
	{ 
	    KwH = { initial = 0}
    },
    execute = function (domoticz, timer)
        domoticz.log ('KwH = '  ..  domoticz.data.KwH)
            local WpPower = domoticz.devices(70).WhActual / 60
            domoticz.log ('WpPower = '  ..  WpPower)
            domoticz.log ('Huidige vermogen in Wh (WhaActual)  ' .. domoticz.devices(70).WhActual)
            domoticz.data.KwH = domoticz.data.KwH + WpPower
            domoticz.log (' Nieuwe kWh waarde  ' .. domoticz.data.KwH)
            domoticz.devices(64).updateElectricity (  domoticz.devices(70).WhActual , domoticz.data.KwH)
    end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest