A little more involved to install, but useful for pretty graphs in Grafana. (Pretty graph below)
https://github.com/smurfless1/indigo-influxdb
def variableUpdated(self, origDev, newDev):
# call base implementation
indigo.PluginBase.variableUpdated(self, origDev, newDev)
# custom add to influx work
# tag by folder if present
tagnames = 'name folderId'.split()
newjson = self.adaptor.diff_to_json(newDev)
newtags = {}
for tag in tagnames:
newtags[tag] = unicode(getattr(newDev, tag))
# add a folder name tag
if hasattr(newDev, 'folderId') and newDev.folderId != 0:
newtags['folder'] = indigo.variables.folders[newDev.folderId].name
if self.pluginPrefs.get('debug', False):
indigo.server.log(json.dumps(newjson).encode('utf-8'))
self.sendVariable(newtags, newjson)
def sendVariable(self, tags, what):
json_body=[
{
'measurement': 'variable_changes',
'tags' : tags,
'fields': what
}
]
try:
self.connection.write_points(json_body)
except Exception as e:
indigo.server.log("InfluxDB write error:")
indigo.server.log(unicode(e))
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.Pi_4_Distance" on measurement "device_changes" is type int64, already exists as type float
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.TxPowerSet" on measurement "device_changes" is type float64, already exists as type integer
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.Pi_7_Distance" on measurement "device_changes" is type int64, already exists as type float
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.TxPowerSet" on measurement "device_changes" is type float64, already exists as type integer
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.PosX" on measurement "device_changes" is type float64, already exists as type integer
piBeacon filling empty state lastStatusChange of dev:beacon-72:47:3A:E2:8C:43 with current date: 2017-07-24 20:54:30
InfluxDB Plugin InfluxDB write error:
InfluxDB Plugin 400: write failed: field type conflict: input field "state.PosX" on measurement "device_changes" is type float64, already exists as type integer
Users browsing this forum: No registered users and 0 guests