From 2073b3916062615d4998b0c5c818a6c4310066e0 Mon Sep 17 00:00:00 2001 From: Matthias Klass Date: Sun, 25 Nov 2018 15:17:26 +0100 Subject: [PATCH] Repair listing of timers with letters in state additional information #1299 --- .../fhem/devices/backend/at/AtDefinitionParser.kt | 11 +++++------ .../klass/fhem/devices/at/AtDefinitionParserTest.kt | 13 ++++++++++++- app/whatsnew-de.md | 2 +- app/whatsnew-en.md | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/li/klass/fhem/devices/backend/at/AtDefinitionParser.kt b/app/src/main/java/li/klass/fhem/devices/backend/at/AtDefinitionParser.kt index 3b77a1c2a..49ba99419 100644 --- a/app/src/main/java/li/klass/fhem/devices/backend/at/AtDefinitionParser.kt +++ b/app/src/main/java/li/klass/fhem/devices/backend/at/AtDefinitionParser.kt @@ -62,9 +62,8 @@ class AtDefinitionParser @Inject constructor() { } private fun parseDateContent(switchTime: String): LocalTime? { - val validatedTime = if (switchTime.length < "00:00:00".length) { - switchTime + ":00" - } else switchTime + val validatedTime = if (switchTime.length < "00:00:00".length) "$switchTime:00" else switchTime + return try { val date = DATE_TIME_FORMAT.parseDateTime(validatedTime) LocalTime(date.hourOfDay, date.minuteOfHour, date.secondOfMinute) @@ -104,9 +103,9 @@ class AtDefinitionParser @Inject constructor() { val targetDevice = trimToNull(matcher.group(1)) val targetState = trimToNull(matcher.group(2)) - val targetStateAddtionalInformation = trimToNull(matcher.group(3)) + val targetStateAdditionalInformation = trimToNull(matcher.group(3)) - return ParsedSwitchContent(targetDevice, targetState, targetStateAddtionalInformation, null) + return ParsedSwitchContent(targetDevice, targetState, targetStateAdditionalInformation, null) } } @@ -179,7 +178,7 @@ class AtDefinitionParser @Inject constructor() { ) companion object { - private val FHEM_PATTERN = Pattern.compile("fhem\\(\"set ([\\w\\-,\\\\.]+) ([\\w%-]+)(?: ([0-9.:]+))?\"\\)(.*)") + private val FHEM_PATTERN = Pattern.compile("fhem\\(\"set ([\\w\\-,\\\\.]+) ([\\w%-]+)(?: ([0-9\\w.:]+))?\"\\)(.*)") private val PREFIX_PATTERN = Pattern.compile("([+*]{0,2})([0-9:]+)(.*)") private val DEFAULT_PATTERN = Pattern.compile("set ([\\w-]+) ([\\w\\-,%]+)(?: ([0-9:]+))?") private val DATE_TIME_FORMAT = DateTimeFormat.forPattern("HH:mm:ss") diff --git a/app/src/test/java/li/klass/fhem/devices/at/AtDefinitionParserTest.kt b/app/src/test/java/li/klass/fhem/devices/at/AtDefinitionParserTest.kt index 131e805f2..ded1ecb45 100644 --- a/app/src/test/java/li/klass/fhem/devices/at/AtDefinitionParserTest.kt +++ b/app/src/test/java/li/klass/fhem/devices/at/AtDefinitionParserTest.kt @@ -178,9 +178,20 @@ class AtDefinitionParserTest { timerType = ABSOLUTE, definition = "2016-10-16T17:00:00 { fhem(\"set d on\") }", assembledDefinition = "17:00:00 { fhem(\"set d on\") }" + ), + TestCase( + hours = 17, + minutes = 0, + seconds = 0, + targetState = "scene", + targetDevice = "weihnachtsbeleuchtung", + additionalInformation = "on", + repetition = ONCE, + timerType = ABSOLUTE, + definition = "2016-10-16T17:00:00 { fhem(\"set weihnachtsbeleuchtung scene on\") }", + assembledDefinition = "17:00:00 { fhem(\"set weihnachtsbeleuchtung scene on\") }" ) ) - } } } diff --git a/app/whatsnew-de.md b/app/whatsnew-de.md index 30404ce4c..ffb02d170 100644 --- a/app/whatsnew-de.md +++ b/app/whatsnew-de.md @@ -1 +1 @@ -TODO \ No newline at end of file +* Zeige Timer mit Buchstaben in state-Zusatzinfo \ No newline at end of file diff --git a/app/whatsnew-en.md b/app/whatsnew-en.md index 30404ce4c..841daeaa7 100644 --- a/app/whatsnew-en.md +++ b/app/whatsnew-en.md @@ -1 +1 @@ -TODO \ No newline at end of file +* Show timers with letters in state additional information \ No newline at end of file