Skip to content

Commit

Permalink
Automatically reconnect to MQTT server when connection breaks
Browse files Browse the repository at this point in the history
 Persist state of lights in MQTT
  • Loading branch information
marcselis committed Apr 3, 2023
1 parent 9db7cd2 commit 11bddc6
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 191 deletions.
2 changes: 2 additions & 0 deletions addon/Easywave2MQTT/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
| 0.5 beta | Allow addon to start when no serial ports are found, or when a non-existing port was specified |
| 0.5.2 beta | Fix crash when serialport is throwing IOException for a timeout, instead of a TimeoutException |
| 0.5.3 beta | Fix bug in detection mechanism for button repeats |
| 0.6 | Automatically reconnect to MQTT server when connection breaks<br/>Persist state of lights in MQTT|

100 changes: 49 additions & 51 deletions addon/Easywave2MQTT/app/Easywave2Mqtt.deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"dependencies": {
"InMemoryBus": "1.0.0",
"JetBrains.Annotations": "2022.3.1",
"MQTTnet.Extensions.ManagedClient": "4.1.4.563",
"Microsoft.Extensions.Hosting": "7.0.0",
"MQTTnet": "4.1.4.563",
"Microsoft.Extensions.Hosting": "7.0.1",
"Microsoft.Extensions.Hosting.Systemd": "7.0.0",
"Microsoft.Extensions.Hosting.WindowsServices": "7.0.0",
"Serilog.Extensions.Hosting": "5.0.1",
Expand All @@ -22,7 +22,14 @@
"Easywave2Mqtt.dll": {}
}
},
"JetBrains.Annotations/2022.3.1": {},
"JetBrains.Annotations/2022.3.1": {
"runtime": {
"lib/netstandard2.0/JetBrains.Annotations.dll": {
"assemblyVersion": "4242.42.42.42",
"fileVersion": "2022.3.1.0"
}
}
},
"Microsoft.Extensions.Configuration/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
Expand All @@ -46,14 +53,14 @@
}
}
},
"Microsoft.Extensions.Configuration.Binder/7.0.0": {
"Microsoft.Extensions.Configuration.Binder/7.0.3": {
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0"
},
"runtime": {
"lib/net7.0/Microsoft.Extensions.Configuration.Binder.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
"fileVersion": "7.0.323.6910"
}
}
},
Expand Down Expand Up @@ -176,11 +183,11 @@
}
}
},
"Microsoft.Extensions.Hosting/7.0.0": {
"Microsoft.Extensions.Hosting/7.0.1": {
"dependencies": {
"Microsoft.Extensions.Configuration": "7.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.3",
"Microsoft.Extensions.Configuration.CommandLine": "7.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "7.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "7.0.0",
Expand All @@ -198,12 +205,13 @@
"Microsoft.Extensions.Logging.Debug": "7.0.0",
"Microsoft.Extensions.Logging.EventLog": "7.0.0",
"Microsoft.Extensions.Logging.EventSource": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0"
"Microsoft.Extensions.Options": "7.0.1",
"System.Diagnostics.DiagnosticSource": "7.0.1"
},
"runtime": {
"lib/net7.0/Microsoft.Extensions.Hosting.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
"fileVersion": "7.0.323.6910"
}
}
},
Expand All @@ -222,7 +230,7 @@
},
"Microsoft.Extensions.Hosting.Systemd/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Hosting": "7.0.0"
"Microsoft.Extensions.Hosting": "7.0.1"
},
"runtime": {
"lib/net7.0/Microsoft.Extensions.Hosting.Systemd.dll": {
Expand All @@ -233,7 +241,7 @@
},
"Microsoft.Extensions.Hosting.WindowsServices/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Hosting": "7.0.0",
"Microsoft.Extensions.Hosting": "7.0.1",
"Microsoft.Extensions.Logging.EventLog": "7.0.0",
"System.ServiceProcess.ServiceController": "7.0.0"
},
Expand All @@ -249,7 +257,7 @@
"Microsoft.Extensions.DependencyInjection": "7.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0"
"Microsoft.Extensions.Options": "7.0.1"
},
"runtime": {
"lib/net7.0/Microsoft.Extensions.Logging.dll": {
Expand All @@ -270,11 +278,11 @@
"dependencies": {
"Microsoft.Extensions.Configuration": "7.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.3",
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0",
"Microsoft.Extensions.Options": "7.0.1",
"Microsoft.Extensions.Options.ConfigurationExtensions": "7.0.0"
},
"runtime": {
Expand All @@ -290,7 +298,7 @@
"Microsoft.Extensions.Logging": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging.Configuration": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0",
"Microsoft.Extensions.Options": "7.0.1",
"System.Text.Json": "7.0.0"
},
"runtime": {
Expand Down Expand Up @@ -318,7 +326,7 @@
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0",
"Microsoft.Extensions.Options": "7.0.1",
"System.Diagnostics.EventLog": "7.0.0"
},
"runtime": {
Expand All @@ -333,7 +341,7 @@
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Logging": "7.0.0",
"Microsoft.Extensions.Logging.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0",
"Microsoft.Extensions.Options": "7.0.1",
"Microsoft.Extensions.Primitives": "7.0.0",
"System.Text.Json": "7.0.0"
},
Expand All @@ -344,24 +352,24 @@
}
}
},
"Microsoft.Extensions.Options/7.0.0": {
"Microsoft.Extensions.Options/7.0.1": {
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net7.0/Microsoft.Extensions.Options.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
"fileVersion": "7.0.323.6910"
}
}
},
"Microsoft.Extensions.Options.ConfigurationExtensions/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.3",
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0",
"Microsoft.Extensions.Options": "7.0.1",
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
Expand All @@ -387,17 +395,6 @@
}
}
},
"MQTTnet.Extensions.ManagedClient/4.1.4.563": {
"dependencies": {
"MQTTnet": "4.1.4.563"
},
"runtime": {
"lib/net6.0/MQTTnet.Extensions.ManagedClient.dll": {
"assemblyVersion": "4.1.4.563",
"fileVersion": "4.1.4.563"
}
}
},
"runtime.linux-arm.runtime.native.System.IO.Ports/7.0.0": {
"runtimeTargets": {
"runtimes/linux-arm/native/libSystem.IO.Ports.Native.so": {
Expand Down Expand Up @@ -498,6 +495,7 @@
}
}
},
"System.Diagnostics.DiagnosticSource/7.0.1": {},
"System.Diagnostics.EventLog/7.0.0": {
"runtime": {
"lib/net7.0/System.Diagnostics.EventLog.dll": {
Expand Down Expand Up @@ -604,12 +602,12 @@
"path": "microsoft.extensions.configuration.abstractions/7.0.0",
"hashPath": "microsoft.extensions.configuration.abstractions.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.Binder/7.0.0": {
"Microsoft.Extensions.Configuration.Binder/7.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-tgU4u7bZsoS9MKVRiotVMAwHtbREHr5/5zSEV+JPhg46+ox47Au84E3D2IacAaB0bk5ePNaNieTlPrfjbbRJkg==",
"path": "microsoft.extensions.configuration.binder/7.0.0",
"hashPath": "microsoft.extensions.configuration.binder.7.0.0.nupkg.sha512"
"sha512": "sha512-1eRFwJBrkkncTpvh6mivB8zg4uBVm6+Y6stEJERrVEqZZc8Hvf+N1iIgj2ySYDUQko4J1Gw1rLf1M8bG83F0eA==",
"path": "microsoft.extensions.configuration.binder/7.0.3",
"hashPath": "microsoft.extensions.configuration.binder.7.0.3.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.CommandLine/7.0.0": {
"type": "package",
Expand Down Expand Up @@ -681,12 +679,12 @@
"path": "microsoft.extensions.filesystemglobbing/7.0.0",
"hashPath": "microsoft.extensions.filesystemglobbing.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Hosting/7.0.0": {
"Microsoft.Extensions.Hosting/7.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-4nFc8xCfK26G524ioreZvz/IeIKN/gY1LApoGpaIThKqBdTwauUo4ETCf12lQcoefijqe3Imnfvnk31IezFatg==",
"path": "microsoft.extensions.hosting/7.0.0",
"hashPath": "microsoft.extensions.hosting.7.0.0.nupkg.sha512"
"sha512": "sha512-aoeMou6XSW84wiqd895OdaGyO9PfH6nohQJ0XBcshRDafbdIU6PQIVl8TpOCssPYq3ciRseP5064hbFyCR9J9w==",
"path": "microsoft.extensions.hosting/7.0.1",
"hashPath": "microsoft.extensions.hosting.7.0.1.nupkg.sha512"
},
"Microsoft.Extensions.Hosting.Abstractions/7.0.0": {
"type": "package",
Expand Down Expand Up @@ -758,12 +756,12 @@
"path": "microsoft.extensions.logging.eventsource/7.0.0",
"hashPath": "microsoft.extensions.logging.eventsource.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Options/7.0.0": {
"Microsoft.Extensions.Options/7.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==",
"path": "microsoft.extensions.options/7.0.0",
"hashPath": "microsoft.extensions.options.7.0.0.nupkg.sha512"
"sha512": "sha512-pZRDYdN1FpepOIfHU62QoBQ6zdAoTvnjxFfqAzEd9Jhb2dfhA5i6jeTdgGgcgTWFRC7oT0+3XrbQu4LjvgX1Nw==",
"path": "microsoft.extensions.options/7.0.1",
"hashPath": "microsoft.extensions.options.7.0.1.nupkg.sha512"
},
"Microsoft.Extensions.Options.ConfigurationExtensions/7.0.0": {
"type": "package",
Expand All @@ -786,13 +784,6 @@
"path": "mqttnet/4.1.4.563",
"hashPath": "mqttnet.4.1.4.563.nupkg.sha512"
},
"MQTTnet.Extensions.ManagedClient/4.1.4.563": {
"type": "package",
"serviceable": true,
"sha512": "sha512-QgrSDz12YnVUdbV5Wu1tP9sgTRUJbN4jZUsHC2Bh93tAPf+6vPaeq2WAEPoyJ7MjCadyGSW0n4QFyCjgNG8Odg==",
"path": "mqttnet.extensions.managedclient/4.1.4.563",
"hashPath": "mqttnet.extensions.managedclient.4.1.4.563.nupkg.sha512"
},
"runtime.linux-arm.runtime.native.System.IO.Ports/7.0.0": {
"type": "package",
"serviceable": true,
Expand Down Expand Up @@ -863,6 +854,13 @@
"path": "serilog.sinks.console/4.1.0",
"hashPath": "serilog.sinks.console.4.1.0.nupkg.sha512"
},
"System.Diagnostics.DiagnosticSource/7.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-T9SLFxzDp0SreCffRDXSAS5G+lq6E8qP4knHS2IBjwCdx2KEvGnGZsq7gFpselYOda7l6gXsJMD93TQsFj/URA==",
"path": "system.diagnostics.diagnosticsource/7.0.1",
"hashPath": "system.diagnostics.diagnosticsource.7.0.1.nupkg.sha512"
},
"System.Diagnostics.EventLog/7.0.0": {
"type": "package",
"serviceable": true,
Expand Down
Binary file modified addon/Easywave2MQTT/app/Easywave2Mqtt.dll
Binary file not shown.
Binary file modified addon/Easywave2MQTT/app/Easywave2Mqtt.exe
Binary file not shown.
Binary file modified addon/Easywave2MQTT/app/InMemoryBus.dll
Binary file not shown.
Binary file added addon/Easywave2MQTT/app/JetBrains.Annotations.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified addon/Easywave2MQTT/app/Microsoft.Extensions.Hosting.dll
Binary file not shown.
Binary file modified addon/Easywave2MQTT/app/Microsoft.Extensions.Options.dll
Binary file not shown.
52 changes: 1 addition & 51 deletions addon/Easywave2MQTT/app/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"SerialPort": "/dev/ttyUSB0",
"EasywaveActionTimeout": "500",
"EasywaveRepeatTimeout": "80",
"MQTTServer": "192.168.0.12",
"MQTTServer": "192.168.0.13",
"MQTTPort": "1883",
"MQTTUser": "mqtt",
"MQTTPassword": "mqtt",
Expand Down Expand Up @@ -159,56 +159,6 @@
}
]
},
{
"Id": "nachth",
"Type": "Light",
"Name": "Nachthal",
"Area": "Hal",
"Subscriptions": [
{
"Address": "000040",
"KeyCode": "A",
"CanSend": "true"
},
{
"Address": "227e60",
"KeyCode": "C"
},
{
"Address": "229630",
"KeyCode": "A"
},
{
"Address": "22963e",
"KeyCode": "A"
},
{
"Address": "229964",
"KeyCode": "A"
}
]
},
{
"Id": "slk1_1",
"Type": "Light",
"Name": "Slaapkamer Ouders",
"Area": "Slaapkamer Ouders",
"Subscriptions": [
{
"Address": "000041",
"KeyCode": "A",
"CanSend": "true"
},
{
"Address": "229589",
"KeyCode": "A"
},
{
"Address": "22759c",
"KeyCode": "A"
}
]
},
{
"Id": "slk1_2",
"Type": "Light",
Expand Down
2 changes: 1 addition & 1 deletion addon/Easywave2MQTT/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Easywave2MQTT"
description: "Support Easywave devices in Home Assistant using MQTT"
version: "0.5.3"
version: "0.6"
url: "https://github.com/marcselis/Easywave2MQTT"
slug: "easywave2mqtt"
init: false
Expand Down
8 changes: 5 additions & 3 deletions src/Easywave2Mqtt/Easywave2Mqtt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1">
<PrivateAssets>all</PrivateAssets>
<PrivateAssets>All</PrivateAssets>
<IncludeAssets></IncludeAssets>
<ExcludeAssets></ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="4.1.4.563" />
<PackageReference Include="MQTTnet" Version="4.1.4.563" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
Expand Down
Loading

0 comments on commit 11bddc6

Please sign in to comment.