Skip to content

Commit

Permalink
Updated build config and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
i8beef committed Apr 1, 2020
1 parent 6f1e854 commit d66775c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
28 changes: 28 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 1.0.2.{build}
branches:
only:
- master
skip_tags: true
image: Visual Studio 2019
configuration: Release
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
version_prefix: '{version}'
package_version: '{version}'
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
build_script:
- ps: >-
dotnet restore src/HomeAutio.Mqtt.UnifiVideo.sln
dotnet publish -c Release src/HomeAutio.Mqtt.UnifiVideo.sln
artifacts:
- path: src\HomeAutio.Mqtt.UniFiVideo\bin\$(configuration)\netcoreapp3.1\publish
name: HomeAutio.Mqtt.UnifiVideo-$(appveyor_build_version)
deploy:
- provider: GitHub
auth_token: $(GITHUB_API_KEY)
artifact: src\HomeAutio.Mqtt.UniFiVideo\bin\$(configuration)\netcoreapp3.1\HomeAutio.Mqtt.UnifiVideo-$(appveyor_build_version).zip
18 changes: 9 additions & 9 deletions src/HomeAutio.Mqtt.UnifiVideo/HomeAutio.Mqtt.UnifiVideo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>HomeAutio.Mqtt.UnifiVideo</PackageId>
<Version>1.0.0.0</Version>
<Authors>Michael Hallock</Authors>
Expand All @@ -15,11 +15,11 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.1\HomeAutio.Mqtt.UnifiVideo.xml</DocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.1\HomeAutio.Mqtt.UnifiVideo.xml</DocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,12 +32,12 @@
<PackageReference Include="I8Beef.CodeAnalysis.RuleSet" Version="1.0.15">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.51" />
<PackageReference Include="I8Beef.UniFi.Video" Version="1.1.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.6.1" />
<PackageReference Include="HomeAutio.Mqtt.Core" Version="3.0.0.57" />
<PackageReference Include="I8Beef.UniFi.Video" Version="1.1.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
</ItemGroup>
Expand Down
12 changes: 1 addition & 11 deletions src/HomeAutio.Mqtt.UnifiVideo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@ public class Program
/// <summary>
/// Main program entry point.
/// </summary>
/// <param name="args">Arguments.</param>
public static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}

/// <summary>
/// Main program entry point.
/// </summary>
/// <param name="args">Arguments.</param>
/// <returns>Awaitable <see cref="Task" />.</returns>
public static async Task MainAsync(string[] args)
public static async Task Main()
{
var environmentName = Environment.GetEnvironmentVariable("ENVIRONMENT");
if (string.IsNullOrEmpty(environmentName))
Expand Down
21 changes: 10 additions & 11 deletions src/HomeAutio.Mqtt.UnifiVideo/UniFiVideoMqttService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using I8Beef.UniFi.Video.Protocol.Recording;
using Microsoft.Extensions.Logging;
using MQTTnet;
using MQTTnet.Extensions.ManagedClient;

namespace HomeAutio.Mqtt.UnifiVideo
{
Expand All @@ -22,16 +23,16 @@ public class UniFiVideoMqttService : ServiceBase
private readonly ILogger<UniFiVideoMqttService> _log;

private readonly IClient _client;
private readonly string _nvrName;
private readonly int _refreshInterval;
private readonly int _detectMotionRefreshInterval;

private readonly IDictionary<string, string> _currentMotionStates = new Dictionary<string, string>();
private IDictionary<string, Camera> _cameraInfo = new Dictionary<string, Camera>();

private bool _disposed = false;
private System.Timers.Timer _refresh;
private System.Timers.Timer _detectMotionRefresh;
private int _refreshInterval;
private int _detectMotionRefreshInterval;

private IDictionary<string, Camera> _cameraInfo = new Dictionary<string, Camera>();

/// <summary>
/// Initializes a new instance of the <see cref="UniFiVideoMqttService"/> class.
Expand All @@ -57,13 +58,12 @@ public UniFiVideoMqttService(
SubscribedTopics.Add(TopicRoot + "/camera/+/+/set");

_client = nvrClient;
_nvrName = nvrName;
}

#region Service implementation

/// <inheritdoc />
protected override async Task StartServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
protected override async Task StartServiceAsync(CancellationToken cancellationToken = default)
{
await GetInitialStatusAsync(cancellationToken)
.ConfigureAwait(false);
Expand Down Expand Up @@ -92,7 +92,7 @@ await GetInitialStatusAsync(cancellationToken)
}

/// <inheritdoc />
protected override Task StopServiceAsync(CancellationToken cancellationToken = default(CancellationToken))
protected override Task StopServiceAsync(CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
Expand All @@ -104,9 +104,8 @@ await GetInitialStatusAsync(cancellationToken)
/// <summary>
/// Handles commands for the UniFi Video published to MQTT.
/// </summary>
/// <param name="sender">Event sender.</param>
/// <param name="e">Event args.</param>
protected override async void Mqtt_MqttMsgPublishReceived(object sender, MqttApplicationMessageReceivedEventArgs e)
protected override async void Mqtt_MqttMsgPublishReceived(MqttApplicationMessageReceivedEventArgs e)
{
var message = e.ApplicationMessage.ConvertPayloadToString();
_log.LogInformation("MQTT message received for topic " + e.ApplicationMessage.Topic + ": " + message);
Expand Down Expand Up @@ -137,7 +136,7 @@ await HandleRecordModeCommandAsync(cameraId, message)
/// <returns>An awaitable <see cref="Task"/>.</returns>
private async Task HandleRecordModeCommandAsync(string cameraId, string value)
{
var recordMode = RecordingMode.None;
RecordingMode recordMode;
switch (value)
{
case "always":
Expand Down Expand Up @@ -245,7 +244,7 @@ await MqttClient.PublishAsync(new MqttApplicationMessageBuilder()
/// </summary>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>An awaitable <see cref="Task"/>.</returns>
private async Task GetInitialStatusAsync(CancellationToken cancellationToken = default(CancellationToken))
private async Task GetInitialStatusAsync(CancellationToken cancellationToken = default)
{
_cameraInfo = (await _client.CameraAsync(null, cancellationToken).ConfigureAwait(false)).ToDictionary(k => k.Id, v => v);
}
Expand Down

0 comments on commit d66775c

Please sign in to comment.