From b85016ace62796a1fce181a053f06e953bda7606 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 24 Dec 2023 11:25:00 +0100 Subject: [PATCH] update to .net 8 --- README.md | 35 ++++++++++++++----- arm64-build.sh | 2 +- src/Tests/Tests.csproj | 8 ++--- src/Ve.Direct.InfluxDB.Collector/Program.cs | 2 +- .../Ve.Direct.InfluxDB.Collector.csproj | 6 ++-- win-build.ps1 | 2 +- x64-build.sh | 2 +- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 478bc84..ec28798 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Project Overview + Ve.Direct.InfluxDB.Collector is a dedicated data collector that bridges the gap between Victron SmartSolar MPPT devices and InfluxDB. The primary aim of this project is to collect, process, and store data from Victron SmartSolar MPPT devices using the Ve.Direct protocol into an InfluxDB database. The resulting dataset can then be visualized using a Grafana dashboard, providing users with a detailed, real-time overview of their solar energy system's performance. [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DocBrown101_Ve.Direct.InfluxDB.Collector&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DocBrown101_Ve.Direct.InfluxDB.Collector) @@ -10,30 +11,48 @@ Ve.Direct.InfluxDB.Collector is a dedicated data collector that bridges the gap ![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/image2.jpg) ## Requirements + To run the Ve.Direct.InfluxDB.Collector, you will need: -* Grafana and InfluxDB docker images -* [The matching Grafana Dashboard](https://grafana.com/grafana/dashboards/14597) -* [A Victron SmartSolar charge controller](https://www.victronenergy.com/solar-charge-controllers) -* A Raspberry Pi or a 24/7 running PC with .NET or MONO and a serial port -* A Ve.Direct cable for connecting the Victron device to the Raspberry Pi or PC -If there are only a few centimeters between the MPPT and the Raspberry Pi, no USB adapter from Victron is needed! +- [Grafana](https://hub.docker.com/r/grafana/grafana/tags?page=1&ordering=last_updated) and [InfluxDB](https://hub.docker.com/_/influxdb/tags?page=1&name=2) docker images +- [The matching Grafana Dashboard](https://grafana.com/grafana/dashboards/14597) +- [A Victron SmartSolar charge controller](https://www.victronenergy.com/solar-charge-controllers) +- A Raspberry Pi or a 24/7 running PC with [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and a serial port + - Important! As of version 3, [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) is required and mono is no longer supported! +- A Ve.Direct cable for connecting the Victron device to the Raspberry Pi or PC + - If there are only a few centimeters between the MPPT and the Raspberry Pi, no USB adapter from Victron is needed! ![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/No-VEDirect-USB.jpg) ![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/Connect-VEDirect-To-RPi.jpg) ## Example Usage + ``` /path/to/Ve.Direct.InfluxDB.Collector.exe -o Influx ``` -You can alternatively run this as a crontab. +## Systemd service example + ``` -@reboot /usr/bin/mono -- /path/to/Ve.Direct.InfluxDB.Collector.exe -o Influx >> /var/log/cron.log 2>&1 +[Unit] +Description=SolarMetrics +After=network.target + +[Service] +User=currentUser +Environment=DOTNET_ROOT=/home/currentUser/dotnet +Environment=PATH=$PATH:/home/currentUser/dotnet +ExecStart=/home/currentUser/git/Ve.Direct.InfluxDB.Collector/build/Ve.Direct.InfluxDB.Collector -i 10 -p /dev/ttyUSB0 --influxDbBucket solar -o Influx +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target ``` ## Future Plans + I am always working on improving Ve.Direct.InfluxDB.Collector and adding more features, so I welcome contributions and suggestions from the community to improve the functionality of this tool and make it even more useful for all users. Inspired by https://github.com/oyebayo/vedirect diff --git a/arm64-build.sh b/arm64-build.sh index b927714..ae60f2e 100644 --- a/arm64-build.sh +++ b/arm64-build.sh @@ -4,7 +4,7 @@ dotnet publish ./src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.c --self-contained false \ -c Release \ -v minimal \ - -f net7.0 \ + -f net8.0 \ -o ./build \ -p:PublishReadyToRun=false \ -p:PublishSingleFile=true \ diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 1f446aa..8b86662 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,15 +1,15 @@  - net472 + net8.0 false true - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Ve.Direct.InfluxDB.Collector/Program.cs b/src/Ve.Direct.InfluxDB.Collector/Program.cs index a1ed6fc..d847662 100644 --- a/src/Ve.Direct.InfluxDB.Collector/Program.cs +++ b/src/Ve.Direct.InfluxDB.Collector/Program.cs @@ -16,7 +16,7 @@ public static int Main(string[] args) app.HelpOption(); app.OnExecuteAsync(async cancellationToken => { - ConsoleLogger.Init(config.DebugOutput, "2.3.6"); + ConsoleLogger.Init(config.DebugOutput, "3.0.0"); ConsoleLogger.Debug($"Current output setting: {config.Output}"); try diff --git a/src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.csproj b/src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.csproj index ab40775..28ce532 100644 --- a/src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.csproj +++ b/src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.csproj @@ -2,14 +2,14 @@ Exe - net472;net6.0;net7.0 + net8.0 latest - + - + \ No newline at end of file diff --git a/win-build.ps1 b/win-build.ps1 index 5082d92..06e7a64 100644 --- a/win-build.ps1 +++ b/win-build.ps1 @@ -8,7 +8,7 @@ dotnet publish "$PSScriptRoot\src\Ve.Direct.InfluxDB.Collector\Ve.Direct.InfluxD -c Release ` -v minimal ` -o ./build ` - -f net7.0 ` + -f net8.0 ` -p:PublishReadyToRun=false ` -p:PublishSingleFile=true ` -p:CopyOutputSymbolsToPublishDirectory=false ` diff --git a/x64-build.sh b/x64-build.sh index 86f7e41..2eabe52 100644 --- a/x64-build.sh +++ b/x64-build.sh @@ -4,7 +4,7 @@ dotnet publish ./src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.c --self-contained false \ -c Release \ -v minimal \ - -f net7.0 \ + -f net8.0 \ -o ./build \ -p:PublishReadyToRun=false \ -p:PublishSingleFile=true \