{"id":50841051,"url":"https://github.com/tetherto/miningos-tpl-wrk-powermeter","last_synced_at":"2026-06-14T06:35:22.895Z","repository":{"id":344018406,"uuid":"1129676396","full_name":"tetherto/miningos-tpl-wrk-powermeter","owner":"tetherto","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-02T10:01:19.000Z","size":339,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-02T12:06:25.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tetherto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-07T12:28:55.000Z","updated_at":"2026-05-02T10:01:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tetherto/miningos-tpl-wrk-powermeter","commit_stats":null,"previous_names":["tetherto/miningos-tpl-wrk-powermeter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tetherto/miningos-tpl-wrk-powermeter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-powermeter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-powermeter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-powermeter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-powermeter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tetherto","download_url":"https://codeload.github.com/tetherto/miningos-tpl-wrk-powermeter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fminingos-tpl-wrk-powermeter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34312072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-14T06:35:22.047Z","updated_at":"2026-06-14T06:35:22.881Z","avatar_url":"https://github.com/tetherto.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# miningos-tpl-wrk-powermeter\n\n## Table of Contents\n\n1. [Overview](#overview)\n    1. [Purpose](#purpose)\n    2. [Supported Power Meter Types](#supported-power-meter-types)\n    3. [Simplified Layer View](#simplified-layer-view)\n    4. [Detailed Component Architecture](#detailed-component-architecture)\n2. [Architecture](#architecture)\n    1. [Object Model](#object-model)\n    2. [Worker Types](#worker-types)\n    3. [Worker Lifecycle](#worker-lifecycle)\n3. [Core Features](#core-features)\n    1. [Real-Time Data (RTD) Collection](#real-time-data-rtd-collection)\n    2. [Device Type Management](#device-type-management)\n    3. [Tag System Integration](#tag-system-integration)\n\n## Overview\n\nThe PowerMeter Worker Template (`WrkPowerMeterRack`) is a specialized abstract class that extends the base [Thing Worker framework](https://github.com/tetherto/miningos-tpl-wrk-thing) for managing power monitoring equipment in Bitcoin mining operations. It provides a foundation for implementing brand-specific power meter integrations while standardizing common functionality across different hardware models.\n\n### Purpose\n\nPower monitoring is critical in mining operations for:\n- **Energy Efficiency**: Track power consumption per mining unit\n- **Cost Management**: Monitor electricity costs in real-time\n- **Preventive Maintenance**: Detect anomalies in power draw\n- **Load Balancing**: Optimize power distribution across facilities\n\n### Supported Power Meter Types\n\nThe template supports various industrial power meters commonly used in mining facilities, including, but not limited to:\n- [**DKCYON**](https://github.com/tetherto/miningos-wrk-powermeter-dkcyon): Industrial power analyzers\n- [**Satec PM180**](https://github.com/tetherto/miningos-wrk-powermeter-satec/): Multi-circuit power meters\n- [**Schneider P3U30 and PM5340**](https://github.com/tetherto/miningos-wrk-powermeter-schneider/): Three-phase power monitors and advanced power quality meter respectively\n- [**Various devics from Abb**](https://github.com/tetherto/miningos-wrk-powermeter-abb/).\n\n### System Components\n\n**Simplified Layer View:**\n```\n┌─────────────────────┐\n│   RPC Interface     │\n├─────────────────────┤\n│ PowerMeter Worker   │\n│ (WrkPowerMeterRack) │\n├─────────────────────┤\n│   Facilities Layer  │\n│     Modbus/SNMP     │\n├─────────────────────┤\n│   Memory Cache      │\n│     RTD Buffer      │\n├─────────────────────┤\n│   Storage Layer     │\n│   (Hyperbee)        │\n├─────────────────────┤\n│   Replication       │\n│   (Master/Slave)    │\n└─────────────────────┘\n```\n\nThe simplified view shows how the PowerMeter template extends the [base Thing Worker](https://github.com/tetherto/miningos-tpl-wrk-thing) architecture. The key additions, highlighed with leading \"+\" sign, are protocol facilities (Modbus/SNMP) in the Facilities Layer and RTD buffering in the Memory Cache. All other layers maintain their standard Thing Worker functionality, ensuring compatibility with the broader mining infrastructure management system.\n\n**Detailed Component Architecture:**\n\n\n```mermaid\ngraph TB\n    subgraph \"PowerMeter Worker Process\"\n        RPC[RPC Interface\u003cbr/\u003enet_r0.rpcServer]\n        Worker[WrkPowerMeterRack\u003cbr/\u003eWorker Instance]\n        \n        subgraph \"Facilities Layer\"\n            Interval[Interval Facility\u003cbr/\u003e- collectSnaps\u003cbr/\u003e- rotateLogs\u003cbr/\u003e- refreshReplica]\n            Scheduler[Scheduler Facility\u003cbr/\u003e- buildStats\u003cbr/\u003e- stat timeframes\u003cbr/\u003e- RTD scheduling]\n            HTTP[HTTP Facility\u003cbr/\u003e- API clients]\n            Store[Store Facilities\u003cbr/\u003e- store_s0: metadata\u003cbr/\u003e- store_s1: data]\n            Net[Network Facility\u003cbr/\u003e- RPC/DHT]\n            Modbus[Modbus Facility\u003cbr/\u003e- TCP clients\u003cbr/\u003e- RTU clients\u003cbr/\u003e- Connection pool]\n        end\n        \n        subgraph \"Data Layer\"\n            Memory[Memory Cache\u003cbr/\u003e- things\u003cbr/\u003e- log_cache\u003cbr/\u003e- collectingThingSnap\u003cbr/\u003e- rtd_buffer\u003cbr/\u003e- modbus_connections]\n            \n            subgraph \"Hyperbee Storage\"\n                MainDB[(Main DB)]\n                Things[(things)]\n                MetaLogs[(meta_logs)]\n                Settings[(settings)]\n                TimeLogs[(Time-series Logs\u003cbr/\u003e- thing-5m-id\u003cbr/\u003e- thing-alerts\u003cbr/\u003e- thing-history-log\u003cbr/\u003e- stat-timeframe\u003cbr/\u003e- rtd-t-powermeter)]\n            end\n        end\n        \n        RPC --\u003e|handles requests| Worker\n        Worker --\u003e|initializes| Interval\n        Worker --\u003e|initializes| Scheduler\n        Worker --\u003e|initializes| HTTP\n        Worker --\u003e|initializes| Store\n        Worker --\u003e|initializes| Net\n        Worker --\u003e|initializes| Modbus\n        \n        Worker --\u003e|reads/writes| Memory\n        Store --\u003e|manages| MainDB\n        MainDB --\u003e Things\n        MainDB --\u003e MetaLogs  \n        MainDB --\u003e Settings\n        Store --\u003e|manages| TimeLogs\n        \n        Memory -.-\u003e|syncs with| Things\n        Worker --\u003e|collects data| Memory\n        Memory -.-\u003e|buffers RTD| TimeLogs\n    end\n    \n    subgraph \"External Connections\"\n        Devices[Power Meters\u003cbr/\u003e- DKCYON\u003cbr/\u003e- Satec PM180\u003cbr/\u003e- P3U30\u003cbr/\u003e- PM5340]\n        Protocols[Protocols\u003cbr/\u003e- Modbus TCP\u003cbr/\u003e- Modbus RTU\u003cbr/\u003e- SNMP]\n        \n        Worker --\u003e|collectThingSnap| Devices\n        Modbus --\u003e|communicates via| Protocols\n        Protocols --\u003e|connects to| Devices\n    end\n    \n    subgraph \"Replication System\"\n        Master[Master Node\u003cbr/\u003eFull read/write]\n        Slave[Slave Node\u003cbr/\u003eRead-only]\n        Discovery[DHT Discovery\u003cbr/\u003ereplicaDiscoveryKey]\n        \n        Master --\u003e|hypercore replication| Slave\n        Discovery --\u003e|enables| Master\n        Discovery --\u003e|enables| Slave\n        Store -.-\u003e|hypercore protocol| Master\n    end\n    \n    subgraph \"PowerMeter Extensions\"\n        RTDConfig[RTD Configuration\u003cbr/\u003e5-second intervals]\n        TypeSystem[Type System\u003cbr/\u003egetThingType\u003cbr/\u003egetThingBaseType]\n        TagSystem[Tag Extensions\u003cbr/\u003egetSpecTags]\n        \n        Worker --\u003e RTDConfig\n        Worker --\u003e TypeSystem\n        Worker --\u003e TagSystem\n        RTDConfig --\u003e|configures| Scheduler\n    end\n    \n    style RPC fill:#1976d2,stroke:#0d47a1,color:#fff\n    style Worker fill:#388e3c,stroke:#1b5e20,color:#fff\n    style Memory fill:#f57c00,stroke:#e65100,color:#fff\n    style MainDB fill:#7b1fa2,stroke:#4a148c,color:#fff\n    style Things fill:#7b1fa2,stroke:#4a148c,color:#fff\n    style MetaLogs fill:#7b1fa2,stroke:#4a148c,color:#fff\n    style Settings fill:#7b1fa2,stroke:#4a148c,color:#fff\n    style TimeLogs fill:#7b1fa2,stroke:#4a148c,color:#fff\n    style Devices fill:#00796b,stroke:#004d40,color:#fff\n    style Protocols fill:#5d4037,stroke:#3e2723,color:#fff\n    style Interval fill:#303f9f,stroke:#1a237e,color:#fff\n    style Scheduler fill:#303f9f,stroke:#1a237e,color:#fff\n    style HTTP fill:#303f9f,stroke:#1a237e,color:#fff\n    style Store fill:#303f9f,stroke:#1a237e,color:#fff\n    style Net fill:#303f9f,stroke:#1a237e,color:#fff\n    style Modbus fill:#303f9f,stroke:#1a237e,color:#fff\n    style Master fill:#b71c1c,stroke:#7f0000,color:#fff\n    style Slave fill:#bf360c,stroke:#870000,color:#fff\n    style Discovery fill:#880e4f,stroke:#560027,color:#fff\n    style RTDConfig fill:#d32f2f,stroke:#b71c1c,color:#fff\n    style TypeSystem fill:#d32f2f,stroke:#b71c1c,color:#fff\n    style TagSystem fill:#d32f2f,stroke:#b71c1c,color:#fff\n```\n\nThis comprehensive architecture diagram illustrates how the PowerMeter template extends the [base Thing Worker](https://github.com/tetherto/miningos-tpl-wrk-thing). The PowerMeter Extensions section (3 red component in the top left) shows the key additions: **RTD configuration for 5-second data collection**, override parent class **type** for power meter categorization, and extended **tagging**.\n\n## Architecture\n\n### Object Model\n\nThe following is a fragment of [MiningOS object model](https://docs.mos.tether.io/) that contains the abstract class representing \"Power Meter\" (highlighted in blue). The rounded nodes reprsent abstract classes and the one square node represents a concrete class:\n\n```mermaid\n---\ntitle: Object Model of MiningOS\n---\nflowchart RL\n    bfx-wrk-base@{ shape: stadium, label: \"*bfx-wrk-base*\" }\n\n\n    tether-wrk-base@{ shape: stadium, label: \"*tether-wrk-base*\" }\n    tether-wrk-base---\u003ebfx-wrk-base\n\n\n    miningos-tlp-wrk-thing@{ shape: stadium, label: \"*miningos-tlp-wrk-thing*\" }\n    miningos-tlp-wrk-thing---\u003etether-wrk-base\n\n\n    miningos-tlp-wrk-powermeter@{ shape: stadium, label: \"*miningos-tlp-wrk-powermeter*\" }\n    miningos-tlp-wrk-powermeter---\u003eminingos-tlp-wrk-thing\n\n\n    miningos-wrk-powermeter-abb[\"miningos-wrk-powermeter-abb\"]\n    miningos-wrk-powermeter-abb---\u003eminingos-tlp-wrk-powermeter\n\n    miningos-wrk-powermeter-schneider[\"miningos-wrk-powermeter-schneider\"]\n    miningos-wrk-powermeter-schneider---\u003eminingos-tlp-wrk-powermeter\n\n\n    style miningos-tlp-wrk-powermeter fill:#005,stroke-width:4px,color:white;\n```\n\u003e Accordign to UML notation, abstract classes have their names in Italic. 'Stadium shape' applied for abstract class nodes for better visualization.\n\n\u003e Horizontal display was chosen over more conventional vertical one merely for purposes of better layout.\n\n### Worker Types\nThe **PowerMeter** template fits in third level of the following standard inheritance hierarchy:\n\n#### Inheritance Levels\n\n```\nLevel 1: bfx-wrk-base (Foundation)\n    ↓\nLevel 2: tether-wrk-base (Foundation)\n    ↓\nLevel 3: miningos-tlp-wrk-thing/WrkProcVar (Thing Management Base)\n    ↓\nLevel 4: miningos-tlp-wrk-powermeter (PowerMeter Template)\n    ↓\nLevel 5: Brand Specific Implementations (in some cases model too)\n    ↓\nLevel 6: Model Specific Implementations\n```\n\n#### Implementation Pattern\n\nEach level provides increasing specialization:\n- [**Level 1**](https://github.com/bitfinexcom/bfx-svc-boot-js): Provides worker infrastructure (lifecycle, facilities, configuration)\n- [**Level 2**](https://github.com/tetherto/tether-wrk-base): Implements RPC server/client capabilities and allowlisting for incoming connections\n- [**Level 3**](https://github.com/tetherto/miningos-tpl-wrk-thing/): Defines abstract methods like `connectThing()`, `collectThingSnap()`\n- **Level 4**: (Current) Adds RTD configuration and type system for power meters\n- **Level 5**: Implements brand-specific communication protocols\n- **Level 6**: Implements model-specific communication protocols\n\n#### Level 1: [Foundation](https://github.com/bitfinexcom/bfx-wrk-base)\n- **bfx-wrk-base**: Core worker functionality (configuration, facilities, lifecycle)\n\n#### Level 2: [Foundation](https://github.com/tetherto/tether-wrk-base)\n- **tether-wrk-base**: Core worker functionality (configuration, facilities, lifecycle)\n\n#### Level 3: [Thing Management Base](https://github.com/tetherto/miningos-tpl-wrk-thing)\n- **miningos-tlp-wrk-thing (WrkProcVar)**: Abstract base implementing:\n  - Thing CRUD operations\n  - RPC interface\n  - Storage management\n  - Replication logic\n  - Abstract methods for device interaction\n\n#### Level 4: PowerMeter Template\n- **miningos-tlp-wrk-powermeter (WrkPowerMeterRack)**: Power monitoring specialization:\n  - RTD scheduling configuration\n  - PowerMeter type definition\n  - Tag system for power meters\n  - Base methods remain abstract for brand implementation\n\n\n#### Key Observations\n\n1. **RTD Enhancement**: The 5-second RTD collection is seamlessly integrated into the standard statistics framework\n2. **Protocol Integration**: Modbus facility is added during brand implementation initialization\n3. **Dual Collection**: Maintains 60-second full snapshots while adding 5-second RTD\n4. **Graceful Degradation**: If RTD fails, full snapshots continue unaffected\n\n### Common Implementation Patterns\n\n1. **Modbus TCP**: Most industrial power meters use Modbus\n2. **Error Handling**: Graceful degradation on communication failures\n3. **Configuration**: Device-specific settings passed via `thg.opts`\n4. **Event-Driven**: Use EventEmitter for async error reporting\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-powermeter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-powermeter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fminingos-tpl-wrk-powermeter/lists"}