{ "meta": { "version": "1", "type": "task", "name": "Downsample Modbus SolarEdge-Template", "description": "template created from task: Downsample Modbus SolarEdge" }, "content": { "data": { "type": "task", "attributes": { "status": "active", "name": "Downsample Modbus SolarEdge", "flux": "option task = {name: \"Downsample Modbus SolarEdge\", cron: \"0 * * * *\", offset: 1m}\n\nsource_bucket = \"solaredge\"\ndestination_bucket = \"solaredge_15m\"\ndestination_org = \"piserver1\"\naggregateField = (data=<-, name) => {\n\tfilteredData = data\n\t\t|> filter(fn: (r) =>\n\t\t\t(r[\"_field\"] == name))\n\tmedian = filteredData\n\t\t|> median()\n\t\t|> drop(columns: [\"_start\"])\n\t\t|> rename(columns: {_stop: \"_time\"})\n\t\t|> set(key: \"aggType\", value: \"median\")\n\tmax = filteredData\n\t\t|> max()\n\t\t|> drop(columns: [\"_start\", \"_time\"])\n\t\t|> rename(columns: {_stop: \"_time\"})\n\t\t|> set(key: \"aggType\", value: \"max\")\n\tmin = filteredData\n\t\t|> min()\n\t\t|> drop(columns: [\"_start\", \"_time\"])\n\t\t|> rename(columns: {_stop: \"_time\"})\n\t\t|> set(key: \"aggType\", value: \"min\")\n\n\tunion(tables: [min, max, median])\n\t\t|> to(bucket: destination_bucket, org: destination_org)\n\n\treturn data\n}\ndata = from(bucket: source_bucket)\n\t|> range(start: -1h)\n\t|> filter(fn: (r) =>\n\t\t(r[\"_measurement\"] == \"inverter\"))\n\t|> window(every: 15m)\n\t|> aggregateField(name: \"I_AC_Current\")\n\t|> aggregateField(name: \"I_AC_CurrentA\")\n\t|> aggregateField(name: \"I_AC_CurrentB\")\n\t|> aggregateField(name: \"I_AC_CurrentC\")\n\t|> aggregateField(name: \"I_AC_VoltageAB\")\n\t|> aggregateField(name: \"I_AC_VoltageBC\")\n\t|> aggregateField(name: \"I_AC_VoltageCA\")\n\t|> aggregateField(name: \"I_AC_VoltageAN\")\n\t|> aggregateField(name: \"I_AC_VoltageBN\")\n\t|> aggregateField(name: \"I_AC_VoltageCN\")\n\t|> aggregateField(name: \"I_AC_Power\")\n\t|> aggregateField(name: \"I_AC_Frequency\")\n\t|> aggregateField(name: \"I_AC_VA\")\n\t|> aggregateField(name: \"I_AC_VAR\")\n\t|> aggregateField(name: \"I_AC_PF\")\n\t|> aggregateField(name: \"I_DC_Current\")\n\t|> aggregateField(name: \"I_DC_Voltage\")\n\t|> aggregateField(name: \"I_DC_Power\")\n\t|> aggregateField(name: \"I_Temp\")\n\ndata\n\t|> filter(fn: (r) =>\n\t\t(r[\"_field\"] == \"I_AC_Energy_WH\"))\n\t|> last()\n\t|> drop(columns: [\"_start\", \"_time\"])\n\t|> rename(columns: {_stop: \"_time\"})\n\t|> to(bucket: destination_bucket, org: destination_org)", "cron": "0 * * * *", "offset": "1m" }, "relationships": { "label": { "data": [] } } }, "included": [] }, "labels": [] }