This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [[processors.starlark]] | |
| namepass = ["opcua_plc1", "opcua_mplc"] | |
| order = 1 | |
| source = ''' | |
| def apply(metric): | |
| new_fields = {} | |
| for field_key in list(metric.fields.keys()): | |
| if field_key != "Quality": | |
| tag_value = field_key | |
| metric.tags['tag_name'] = tag_value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- TimeScaleDB | |
| SELECT | |
| time_bucket('180 seconds', bucket) AS agtime, | |
| AVG(avg) as "lab_indoor_temp" | |
| FROM | |
| timeseries_60s | |
| WHERE | |
| $__timeFilter("bucket") AND | |
| tagname = 'lab_indoor_temp' | |
| GROUP BY agtime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def WriteInfluxDB(timestamp: datetime, points_data: list) -> None: | |
| try: | |
| # Create a list of Point objects | |
| points = [] | |
| for point_data in points_data: | |
| tag_name = point_data["tag_name"] | |
| tag_value = point_data["tag_value"] | |
| point = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def WriteSQLToDB(timestamp: datetime, data_points: list) -> None: | |
| try: | |
| sqlEngine = create_engine( | |
| db_conn, | |
| pool_recycle=300, | |
| pool_pre_ping=True, | |
| connect_args={"connect_timeout": 20}, | |
| ) | |
| # Build a single SQL statement with multiple VALUES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let payload = msg.payload; | |
| let timestamp = new Date(payload.timestamp); | |
| timestamp = Math.floor(timestamp.getTime() / 1000); | |
| let lp_msg = { | |
| "payload": "homedb,sensor=lab_indoor_temp value=" + payload.value + " " + timestamp | |
| } | |
| return lp_msg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # import libraries | |
| import os | |
| import sys | |
| import time | |
| import pika | |
| def main(): | |
| # set up connection to RabbitMQ | |
| connection = pika.BlockingConnection(pika.ConnectionParameters(host="localhost")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import requests | |
| from datetime import datetime | |
| # URL to read the data from Geyserwala | |
| URL = "http://192.168.2.20/api/value?f=status,tank-temp,collector-temp,element-demand,pump-status,element-seconds,element-cycles,pump-seconds,pump-cycles" | |
| # Connect to Geyserwala and read the parameters | |
| while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from datetime import datetime | |
| from deye_controller import HoldingRegisters | |
| from pysolarmanv5 import PySolarmanV5 | |
| # Parameters to read from the inverter | |
| # [register, name, unit, multiplier] | |
| parameters = [ | |
| [172, "grid_ct_power_W", "W", 1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from sqlalchemy import create_engine, text | |
| # Database connection string | |
| db_conn = "postgresql://username:password@192.168.2.10:5432/tsdb" | |
| # Write the data to the database | |
| def WriteSQLToDB(timestamp: datetime, tag_name: str, tag_value: float) -> None: | |
| try: | |
| sqlEngine = create_engine(db_conn, pool_recycle=300, pool_pre_ping=True, connect_args={"connect_timeout": 20}) |
NewerOlder