Page 1 of 1

Custom Sensors and Data Push

Posted: Saturday 22 June 2019 7:43
by kevster
I couldn't really find anything about this.

I recently have started exporting sensor data to influxdb so I can do deep analitics over longer periods of time than the native domo store.

I use quite a lot of custom sensors on my deployment (for level checks, percentages etc) and so I would like their values to be logged in Influx.

However data from the custom sensors does not appear to be pushed to Influx. Does anyone know why ?

Questions:
1) On data export what is 'direct' supposed to do ?
2) Should this work ?

Someone recently fixed the custom sensors working with notifications which I am so greatful for. Is this something else that does not work with custom sensors ?

If this is the wrong forum subject can a mod please put in the correct one :)

Thanks

Re: Custom Sensors and Data Push

Posted: Friday 01 May 2020 8:34
by rrozema
According to the wiki on HttpLink sensor values written to a custom sensor using the UpdateDevice method are not forwarded into a DataPush, so in this case not into influxdb. The wiki suggests to change the script setting the sensor's value to use the json API instead of UpdateDevice.

So this appears to be documented behaviour, but this leaves me with 3 questions:
  • Why do custom sensors have to behave differently than standard sensors with regards to DataPush?
  • how do I change this dzVents script into "using the json API"?

    Code: Select all

    local TEMPHUM_DEVICE_NAME = '*: TempHum'
    
    return {
    	on = {
    		devices = {
    			TEMPHUM_DEVICE_NAME
    		}
    	},
    	execute = function(domoticz, device)
    		local device_name = string.sub( device.name, 1, string.len(device.name) - 9) .. ': Humidity'
    		local hum_device = domoticz.devices(device_name)
    
    		if nil ~= hum_device then
        	    local dampDruk
        	    if device.temperature >= 0 then
        	        dampDruk = (6.1078 * math.exp( math.log(10) * ((7.5 * device.temperature) / (237.3 + device.temperature)) ) );
        	    else
        	        dampDruk = (6.1078 * math.exp( math.log(10) * ((7.6 * device.temperature) / (240.7 + device.temperature)) ) );
        	    end
        	    
        		local absolute_humidity = math.floor(1000.0 * math.exp(math.log(10) * 5) * 18.016 / 8314.3 * (device.humidity / 100.0 * dampDruk) / (device.temperature + 273.15) + 0.5) / 1000.0
        		
        		hum_device.updateCustomSensor(tostring(absolute_humidity))
        	end
    	end
    }
  • How do I make my custom sensor values go into influxdb if my cusyom device is not shown in the list of devices available for logging into influxdb?
    influxdb device selection.JPG
    influxdb device selection.JPG (27.97 KiB) Viewed 770 times