Repository navigation
Core improvements and new features - #19
Merged
Merged
Conversation
…d other Pylint errors
…d other Pylint errors
… in settings repository
…Edge Mining application - Implemented configurations for home load, miner, notification, and performance tracking adapters. - Created mapping files for energy, external services, forecast, home load, miner, notification, and performance tracker adapters. - Introduced common objects, entities, exceptions, and ports for external services. - Refactored settings to streamline adapter configuration and added MQTT support (to be completed). - Updated requirements to include loguru and paho-mqtt for enhanced logging and MQTT capabilities.
…rvice integration
code readability
…ality (replaced with loguru)
…nd update references with a ServiceContainer
…f and removed other unused dev dependencies
…rity and consistency
GitGab19
approved these changes
Aug 28, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Edge Mining system now has his (basic) Rule Engine that allows users to define custom automation rules to control when mining should start or stop, based on the system's energy status. Additionally, support for storing optimization policies as YAML files instead of SQLite database records has been added. This provides a more readable and intuitive way to manage mining policies. Finally, the Edge Mining project is now fully configured with all the development tools needed to maintain high code quality.
Main changes include:
Edge Mining Rule Engine and YAML Policy System
Condition Types
The rule engine supports various condition types to create complex logical rules for mining control. Single Conditions can be used for simple checks, while Multiple Logical Conditions allow for more sophisticated rules. Multiple conditions support logical operators AND, OR, and NOT to combine conditions in flexible ways.
Single Condition
The simplest form of a condition checks a single field against a value. It must be true for the rule to apply.
Multiple Logical Conditions
A more complex rule can combine multiple conditions using logical operators. This allows for sophisticated decision-making based on the system's state.
AND: All the conditions must be true for the rule to apply.
OR: At least one condition must be true for the rule to apply.
NOT: This negates a condition, meaning the rule applies if the condition is false.
We can also combine multiple conditions using logical operators:
Complex Combinations:
Supported Operators
It's a basic rule engine, but it has some great superpowers. It supports all the basic logical operators and more.
eqvalue: 50nevalue: "ERROR"gtvalue: 80gtevalue: 90ltvalue: 20ltevalue: 10invalue: [5, 6, 0]not_invalue: [1, 2, 3]containsvalue: "solar"starts_withvalue: "HIGH"ends_withvalue: "_LEVEL"regexvalue: "^[0-9]+$"Available Fields in DecisionalContext
All the entities in the
DecisionalContextcan be used as fields in conditions with the dot notation. This includes:energy_state.battery.state_of_chargeenergy_state.battery.current_powerforecast.next_hour_powerenergy_state.grid.exporting_powerDirectory Structure
Policies are now stored in the
optimization_policies/directory in the application root. In therule_examples/directory, you can find example rules that demonstrate the rule engine capabilities (this directory is not used by the system, but it is useful only as examples).Be curious! You can explore the
rules_examples/directory to see how the rule engine works and how to create your own rules 😊.Policy File Format
Each policy is stored as a separate YAML file named with the policy ID. The format includes:
Best Practices
Hybrid Persistence
The YAML adapter uses a hybrid approach:
Development Tools
The Edge Mining project is now fully configured with all the necessary development tools to maintain high code quality. Most of them are included as pre-commit hooks, so they run automatically before each commit. (It is recommended to install pre-hooks before committing. 😉).
Configured Tools
Code Formatting
Quality Control
Testing
Pre-commit Hooks
.pre-commit-config.yamlwith all updated versions.Configuration Files
Main
.pre-commit-config.yaml: Pre-commit hooks.pyproject.toml: Ruff, mypy and Bandit configuration.requirements-dev.txt: Development dependencies.Makefile: Automation commands.VS Code
.vscode/settings.json: Recommended settings..vscode/extensions.json: Recommended extensions..vscode/launch.json: Debug configurations.Documentation
DEVELOPMENT_WORKFLOW.md: Development workflow guide.DEV_TOOLS.md: Development tools documentation.Useful Scripts
Makefile: Automation with make (recommended).Quick Commands
Initial Setup
Daily Use
Automation
Pre-commit hooks run automatically on every
git commit.Special Features
Benefits Achieved
Additional Features
python3 -m edge_mining cli interactive.Sunentity has been added to the Energy Forecast domain, which provides the data about the time and position of the sun in the sky that can be used in the rules (eg: sunrise, sunset, azimuth, elevation, etc.).And that's it! The Edge Mining project is now ready for development with all quality tools configured and working, a tiny rule engine to control the miners and a lot of stranded energy to mine! 😄
If you're a renewable energy plant owner, I hope you mine your energy. If you're a developer, I hope you contribute to the project. But... if you're both, you hold the keys to the future.
Happy coding! 🚀
Marco