Skip to content

Commit

Permalink
Fix repeat detection not working anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
marcselis committed Jan 26, 2023
1 parent 9a45c04 commit 9db7cd2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
1 change: 1 addition & 0 deletions addon/Easywave2MQTT/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
| 0.4 beta | Simplified addon building & startup: <br/>- addon binaries & config file are directly editable in app subfolder, making it easier for non-developers to alter the configuration and to deploy the addon in Home Assistant.<br/>- options are directly read from data subfolder (if available).<br/>Lowered logging level for a few `MessagingService` messages that were logged twice, but in a different way. |
| 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 |
Binary file modified addon/Easywave2MQTT/app/Easywave2Mqtt.dll
Binary file not shown.
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.2"
version: "0.5.3"
url: "https://github.com/marcselis/Easywave2MQTT"
slug: "easywave2mqtt"
init: false
Expand Down
29 changes: 12 additions & 17 deletions src/Easywave2Mqtt/Easywave/EldatRx09Transceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,22 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested && _port!.IsOpen)
{
if (_port.BytesToRead > 0)
try
{
try
{
var line = _port.ReadLine();
LogReceivedLine(line);
EasywaveTelegram telegram = Parse(line);
if (!telegram.Equals(EasywaveTelegram.Empty))
{
//Only wait if timeout has occurred, otherwise the double- & triple-press detection mechanism doesn't work.
await _bus.PublishAsync(telegram).ConfigureAwait(false);
}
}
catch (TimeoutException)
{
}
catch (IOException ex) when (ex.HResult == TimeoutResult)
var line = _port.ReadLine();
LogReceivedLine(line);
EasywaveTelegram telegram = Parse(line);
if (!telegram.Equals(EasywaveTelegram.Empty))
{
//Only wait if timeout has occurred, otherwise the double- & triple-press detection mechanism doesn't work.
await _bus.PublishAsync(telegram).ConfigureAwait(false);
}
}
else
catch (TimeoutException)
{
await Task.Delay(PauseTime, stoppingToken).ConfigureAwait(false);
}
catch (IOException ex) when (ex.HResult == TimeoutResult)
{
await Task.Delay(PauseTime, stoppingToken).ConfigureAwait(false);
}
Expand Down

0 comments on commit 9db7cd2

Please sign in to comment.