Skip to content

Commit

Permalink
Repair listing of timers with letters in state additional information #…
Browse files Browse the repository at this point in the history
  • Loading branch information
klassm committed Nov 25, 2018
1 parent 4c3bd34 commit 2073b39
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\") }"
)
)

}
}
}
2 changes: 1 addition & 1 deletion app/whatsnew-de.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO
* Zeige Timer mit Buchstaben in state-Zusatzinfo
2 changes: 1 addition & 1 deletion app/whatsnew-en.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO
* Show timers with letters in state additional information

0 comments on commit 2073b39

Please sign in to comment.