Skip to content

Commit

Permalink
fix: type adapter for colorname value (#167)
Browse files Browse the repository at this point in the history
* fix: type adapter for colorname value

* fix: type adapter for colorname value

* style: removed needles blank line

* fix: execute on app ready callback in run testing

* style: removes needles blank line

Co-authored-by: Dennis Schröder <[email protected]>
  • Loading branch information
dennisschroeder and Dennis Schröder authored Mar 6, 2021
1 parent 1c0167d commit 22e534b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/khome/Khome.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import khome.values.AppName
import khome.values.Artist
import khome.values.Azimuth
import khome.values.Brightness
import khome.values.ColorName
import khome.values.ColorTemperature
import khome.values.Device
import khome.values.Domain
Expand Down Expand Up @@ -300,11 +301,12 @@ internal fun Khome.registerDefaultTypeAdapter() {
registerTypeAdapter<ObjectId, String>(ObjectId)
registerTypeAdapter<Service, String>(Service)
registerTypeAdapter<Device, String>(Device)
registerTypeAdapter<Brightness, String>(Brightness)
registerTypeAdapter<Brightness, Int>(Brightness)
registerTypeAdapter<RGBColor, Array<Int>>(RGBColor)
registerTypeAdapter<HSColor, Array<Double>>(HSColor)
registerTypeAdapter<XYColor, Array<Double>>(XYColor)
registerTypeAdapter<ColorTemperature, Int>(ColorTemperature)
registerTypeAdapter<ColorName, String>(ColorName)
registerTypeAdapter<PowerConsumption, Double>(PowerConsumption)
registerTypeAdapter<Icon, String>(Icon)
registerTypeAdapter<PresetMode, String>(PresetMode)
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/khome/KhomeApplicationImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ internal class KhomeApplicationImpl : KhomeApplication {
}

override fun runTesting(block: KhomeTestApplication.() -> Unit) {
applicationReadyCallbacks.forEach { it.invoke(this@KhomeApplicationImpl) }
val testApp = KhomeTestApplicationImpl(
sensorsByApiName,
actuatorsByApiName,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/khome/values/Brightness.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class Brightness private constructor(val value: Int) {

companion object : KhomeTypeAdapter<Brightness> {
override fun <P> from(value: P): Brightness {
return Brightness((value as String).toInt())
return Brightness(value as Int)
}

@Suppress("UNCHECKED_CAST")
Expand Down

0 comments on commit 22e534b

Please sign in to comment.