From af3b9c89133492261eddc0a8e6300b885372f651 Mon Sep 17 00:00:00 2001 From: Stephan Knull Date: Sun, 21 Apr 2024 15:21:31 +0200 Subject: [PATCH] Replacing ConfigHolder by ApplicationPreferences populated from application.yml instead of propreitary JSON --- .../hardware/shelly/model/ShellyColor.kt | 14 ++-- .../hardware/shelly/model/ShellyDevice.kt | 50 +------------ .../yamaha/model/AbstractMenuProvider.kt | 2 +- .../klanglicht/hardware/yamaha/model/Cmd.kt | 2 +- .../hardware/yamaha/model/CmdList.kt | 2 +- .../hardware/yamaha/model/Define.kt | 2 +- .../hardware/yamaha/model/Direct.kt | 2 +- .../klanglicht/hardware/yamaha/model/F.kt | 2 +- .../klanglicht/hardware/yamaha/model/FKey.kt | 2 +- .../klanglicht/hardware/yamaha/model/Get.kt | 2 +- .../hardware/yamaha/model/Indirect.kt | 2 +- .../hardware/yamaha/model/Language.kt | 2 +- .../hardware/yamaha/model/Locator.kt | 2 +- .../klanglicht/hardware/yamaha/model/Param.kt | 2 +- .../klanglicht/hardware/yamaha/model/Path.kt | 2 +- .../klanglicht/hardware/yamaha/model/Put1.kt | 2 +- .../klanglicht/hardware/yamaha/model/Put2.kt | 2 +- .../klanglicht/hardware/yamaha/model/Range.kt | 2 +- .../klanglicht/hardware/yamaha/model/SKey.kt | 2 +- .../klanglicht/hardware/yamaha/model/Text.kt | 2 +- .../hardware/yamaha/model/XmlEntity.kt | 2 +- .../yamahaadvantage/model/SoundProgramList.kt | 2 +- .../model/deviceinfo/AnalyticsInfo.kt | 2 +- .../model/deviceinfo/DeviceInfo.kt | 2 +- .../model/features/Bluetooth.kt | 2 +- .../yamahaadvantage/model/features/Ccs.kt | 2 +- .../model/features/Distribution.kt | 2 +- .../model/features/Features.kt | 2 +- .../yamahaadvantage/model/features/Input.kt | 2 +- .../model/features/MasterRole.kt | 2 +- .../model/features/McPlaylist.kt | 2 +- .../model/features/McSurround.kt | 2 +- .../yamahaadvantage/model/features/Netusb.kt | 2 +- .../model/features/PlayQueue.kt | 2 +- .../yamahaadvantage/model/features/Preset.kt | 2 +- .../yamahaadvantage/model/features/PresetX.kt | 2 +- .../yamahaadvantage/model/features/Qobuz.kt | 2 +- .../model/features/RangeStep.kt | 2 +- .../model/features/RangeStepX.kt | 2 +- .../model/features/RecentInfo.kt | 2 +- .../model/features/SlaveRole.kt | 2 +- .../yamahaadvantage/model/features/System.kt | 2 +- .../yamahaadvantage/model/features/Tidal.kt | 2 +- .../yamahaadvantage/model/features/Tuner.kt | 2 +- .../yamahaadvantage/model/features/Zone.kt | 2 +- .../model/dmx/fixture/Calibration.kt | 2 +- .../klanglicht/model/dmx/fixture/Channel.kt | 2 +- .../klanglicht/model/dmx/fixture/Fixture.kt | 2 +- .../klanglicht/model/dmx/fixture/Range.kt | 2 +- .../kotlin/klanglicht/model/dmx/model/Dmx.kt | 2 +- .../klanglicht/model/dmx/model/DmxDevice.kt | 2 +- .../model/preferences/Preferences.kt | 58 ++++++++------- .../klanglicht/model/preferences/Service.kt | 2 +- .../model/preferences/ShellyDeviceTest.kt | 8 ++- .../de/visualdigits/kotlin/Application.kt | 2 +- .../klanglicht/rest/ResourceController.kt | 7 +- .../configuration/ApplicationPreferences.kt | 68 ++++++++++++++++-- .../rest/configuration/ConfigHolder.kt | 70 ------------------- .../RequestLoggingFilterConfig.kt | 4 +- .../SimpleRequestLoggingFilter.kt | 2 +- .../rest/configuration/WebConfig.kt | 15 ++-- .../controller/HybridStageWebController.kt | 10 ++- .../rest/hybrid/service/HybridStageService.kt | 30 ++++---- .../controller/LightmanagerWebController.kt | 10 ++- .../lightmanager/model/html/ColorWheel.kt | 21 +++--- .../model/html/ColorWheelOddEven.kt | 3 +- .../lightmanager/model/html/HtmlRenderable.kt | 3 +- .../lightmanager/model/html/LMHtmlActor.kt | 11 ++- .../lightmanager/model/html/LMHtmlScene.kt | 9 ++- .../lightmanager/model/html/LMHtmlScenes.kt | 11 ++- .../lightmanager/model/html/LMHtmlZone.kt | 5 +- .../lightmanager/model/html/LMHtmlZones.kt | 5 +- .../service/LightmanagerService.kt | 8 +-- .../webclient}/LightmanagerClient.kt | 10 +-- .../rest/scenes/service/ScenesService.kt | 10 +-- .../shelly/controller/ShellyWebController.kt | 4 +- .../rest/shelly/model/html/ShellyStatus.kt | 3 +- .../rest/shelly/service/ShellyService.kt | 14 ++-- .../rest/shelly/webclient}/ShellyClient.kt | 2 +- .../twinkly/controller/XledArrayController.kt | 32 ++++----- .../controller/XledDeviceController.kt | 22 +++--- .../rest/yamaha/service/YamahaService.kt | 8 +-- .../yamaha/webclient}/YamahaReceiverClient.kt | 2 +- .../service/YamahaAvantageService.kt | 8 +-- .../YamahaAvantageReceiverClient.kt | 2 +- .../src/main/resources/application.yml | 5 ++ .../webclient}/LightmanagerClientTest.kt | 7 +- .../shelly/webclient}/ShellyClientTest.kt | 2 +- .../YamahaAvantageReceiverClientTest.kt | 2 +- 89 files changed, 288 insertions(+), 369 deletions(-) delete mode 100644 klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt rename {klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/lightmanager/client => klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/webclient}/LightmanagerClient.kt (82%) rename {klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/client => klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/shelly/webclient}/ShellyClient.kt (96%) rename {klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/client => klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/yamaha/webclient}/YamahaReceiverClient.kt (94%) rename {klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/client => klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/yamahaavantage/webclient}/YamahaAvantageReceiverClient.kt (97%) rename {klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/hardware/lightmanager/client => klanglicht-rest/src/test/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/webclient}/LightmanagerClientTest.kt (82%) rename {klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/client => klanglicht-rest/src/test/kotlin/de/visualdigits/kotlin/klanglicht/rest/shelly/webclient}/ShellyClientTest.kt (88%) rename {klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/client => klanglicht-rest/src/test/kotlin/de/visualdigits/kotlin/klanglicht/rest/yamahaavantage/webclient}/YamahaAvantageReceiverClientTest.kt (95%) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyColor.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyColor.kt index cb7bb11..7b394e6 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyColor.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyColor.kt @@ -1,11 +1,13 @@ package de.visualdigits.kotlin.klanglicht.hardware.shelly.model -import de.visualdigits.kotlin.klanglicht.hardware.shelly.client.ShellyClient +import de.visualdigits.kotlin.klanglicht.hardware.shelly.model.status.Light import de.visualdigits.kotlin.klanglicht.model.color.RGBColor import de.visualdigits.kotlin.klanglicht.model.dmx.parameter.Fadeable import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences +import de.visualdigits.kotlin.util.get import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.net.URL import kotlin.math.min class ShellyColor( @@ -51,13 +53,9 @@ class ShellyColor( override fun write(preferences: Preferences?, write: Boolean, transitionDuration: Long) { if (write) { log.debug("Set shelly color {}", color.ansiColor()) - ShellyClient.setColor( - ipAddress = ipAddress, - rgbColor = color, - gain = deviceGain, - transitionDuration = transitionDuration, - turnOn = getTurnOn() - ) + log.debug("setColor: $ipAddress = ${color.ansiColor()} [$deviceGain]") + URL("http://$ipAddress/color/0?turn=${if (getTurnOn() == true) "on" else "off"}&red=${color.red}&green=${color.green}&blue=${color.blue}&white=0&gain=${(100 * deviceGain).toInt()}&transition=$transitionDuration&") + .get() } } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyDevice.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyDevice.kt index 2c175e5..08d85af 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyDevice.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/shelly/model/ShellyDevice.kt @@ -1,12 +1,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.shelly.model -import de.visualdigits.kotlin.klanglicht.hardware.shelly.client.ShellyClient -import de.visualdigits.kotlin.klanglicht.hardware.shelly.model.status.Light -import de.visualdigits.kotlin.klanglicht.hardware.shelly.model.status.Status -import de.visualdigits.kotlin.klanglicht.model.color.RGBColor - -data class ShellyDevice( +class ShellyDevice( val name: String = "", val model: String = "", val command: String = "", @@ -17,47 +12,4 @@ data class ShellyDevice( override fun toString(): String { return "Shelly $name [$ipAddress] $model" } - - fun setPower( - command: String, - turnOn: Boolean, - transitionDuration: Long - ): String? { - return ShellyClient.setPower( - ipAddress = ipAddress, - command = command, - turnOn = turnOn, - transitionDuration = transitionDuration - ) - } - - fun setGain( - gain: Int, - transitionDuration: Long - ): String? { - return ShellyClient.setGain( - ipAddress = ipAddress, - gain = gain, - transitionDuration = transitionDuration - ) - } - - fun getStatus(): Status? { - return ShellyClient.getStatus(ipAddress) - } - - fun setColor( - rgbColor: RGBColor, - gain: Double = 1.0, - transitionDuration: Long = 0, - turnOn: Boolean = true, - ): Light? { - return ShellyClient.setColor( - ipAddress = ipAddress, - rgbColor = rgbColor, - gain = gain, - transitionDuration = transitionDuration, - turnOn = turnOn - ) - } } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/AbstractMenuProvider.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/AbstractMenuProvider.kt index 160cb70..4d9ff83 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/AbstractMenuProvider.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/AbstractMenuProvider.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty -abstract class AbstractMenuProvider : XmlEntity() { +abstract class AbstractMenuProvider : XmlEntity { @JacksonXmlProperty(localName = "Menu") @JacksonXmlElementWrapper(localName = "Menu", useWrapping = false) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Cmd.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Cmd.kt index ff21b1b..b0681a8 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Cmd.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Cmd.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Cmd") -class Cmd : XmlEntity() { +class Cmd : XmlEntity { @JacksonXmlProperty(localName = "ID", isAttribute = true) val id: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/CmdList.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/CmdList.kt index 6235b94..2a16fc0 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/CmdList.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/CmdList.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "Cmd_List") -class CmdList : XmlEntity() { +class CmdList : XmlEntity { @JacksonXmlProperty(localName = "Define") @JacksonXmlElementWrapper(localName = "Define", useWrapping = false) val define: List = listOf() diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Define.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Define.kt index 65837c6..9a6c661 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Define.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Define.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Define") -class Define : XmlEntity() { +class Define : XmlEntity { @JacksonXmlProperty(localName = "ID", isAttribute = true) val id: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Direct.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Direct.kt index b2a64fb..8817cc0 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Direct.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Direct.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Direct") -class Direct : XmlEntity() { +class Direct : XmlEntity { @JacksonXmlProperty(localName = "Title_1", isAttribute = true) val title1: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/F.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/F.kt index bcae971..34eb56f 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/F.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/F.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText -class F : XmlEntity() { +class F : XmlEntity { @JacksonXmlProperty(localName = "Title_1", isAttribute = true) val title: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/FKey.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/FKey.kt index c31b7a0..0d28a96 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/FKey.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/FKey.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "FKey") -class FKey : XmlEntity() { +class FKey : XmlEntity { @JacksonXmlProperty(localName = "Title", isAttribute = true) val title: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Get.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Get.kt index 1a3aa3e..e1bd360 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Get.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Get.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "Get") -class Get : XmlEntity() { +class Get : XmlEntity { @JacksonXmlProperty(localName = "Cmd") val command: Cmd? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Indirect.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Indirect.kt index 7f015b0..c7ba932 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Indirect.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Indirect.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "Indirect") -class Indirect : XmlEntity() { +class Indirect : XmlEntity { @JacksonXmlProperty(localName = "ID", isAttribute = true) val id: String? = null } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Language.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Language.kt index ee4ff37..0d07401 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Language.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Language.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Language") -class Language : XmlEntity() { +class Language : XmlEntity { @JacksonXmlProperty(localName = "Code", isAttribute = true) val code: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Locator.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Locator.kt index 9f88eba..68db45e 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Locator.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Locator.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText -class Locator : XmlEntity() { +class Locator : XmlEntity { @JacksonXmlProperty(localName = "ID", isAttribute = true) val id: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Param.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Param.kt index 69fbde5..9696a26 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Param.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Param.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty -class Param : XmlEntity() { +class Param : XmlEntity { @JacksonXmlProperty(localName = "Func") var function: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Path.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Path.kt index 1c5454d..f501a51 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Path.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Path.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Path") -class Path : XmlEntity() { +class Path : XmlEntity { @JacksonXmlText val value: String? = null } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put1.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put1.kt index 4b29954..1d803ed 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put1.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put1.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Put_1") -class Put1 : XmlEntity() { +class Put1 : XmlEntity { @JacksonXmlProperty(localName = "Title_1", isAttribute = true) val title1: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put2.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put2.kt index 046c07b..4ea06d7 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put2.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Put2.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "Put_2") -class Put2 : XmlEntity() { +class Put2 : XmlEntity { @JacksonXmlProperty(localName = "Cmd") val command: Cmd? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Range.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Range.kt index 18489ac..5dc334a 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Range.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Range.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText @JacksonXmlRootElement(localName = "Range") -class Range : XmlEntity() { +class Range : XmlEntity { @JacksonXmlText val value: String? = null } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/SKey.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/SKey.kt index 4ad64bc..2d0c3df 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/SKey.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/SKey.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement @JacksonXmlRootElement(localName = "SKey") -class SKey : XmlEntity() { +class SKey : XmlEntity { @JacksonXmlProperty(localName = "Title", isAttribute = true) val title: String? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Text.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Text.kt index 1a362b0..f5e4c3d 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Text.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/Text.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamaha.model import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText -class Text : XmlEntity() { +class Text : XmlEntity { @JacksonXmlText val value: String? = null } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/XmlEntity.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/XmlEntity.kt index 6514982..1d46a49 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/XmlEntity.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamaha/model/XmlEntity.kt @@ -1,3 +1,3 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamaha.model -open class XmlEntity +interface XmlEntity diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/SoundProgramList.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/SoundProgramList.kt index 7068798..c54c1bc 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/SoundProgramList.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/SoundProgramList.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model import com.fasterxml.jackson.annotation.JsonProperty -data class SoundProgramList( +class SoundProgramList( @JsonProperty("response_code") val responseCode: Int = 0, @JsonProperty("sound_program_list") val soundProgramList: List = listOf() ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/AnalyticsInfo.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/AnalyticsInfo.kt index 3850688..731a786 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/AnalyticsInfo.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/AnalyticsInfo.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.deviceinfo -data class AnalyticsInfo( +class AnalyticsInfo( val uuid: String = "" ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/DeviceInfo.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/DeviceInfo.kt index 7715471..8c263a7 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/DeviceInfo.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/deviceinfo/DeviceInfo.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.devicei import com.fasterxml.jackson.annotation.JsonProperty -data class DeviceInfo( +class DeviceInfo( @JsonProperty("response_code") val responseCode: Int = 0, @JsonProperty("model_name") val modelName: String = "", val destination: String = "", diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Bluetooth.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Bluetooth.kt index 0b6dd53..bd33204 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Bluetooth.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Bluetooth.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Bluetooth( +class Bluetooth( @JsonProperty("update_cancelable") val updateCancelable: Boolean = false, @JsonProperty("tx_connectivity_type_max") val txConnectivityTypeMax: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Ccs.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Ccs.kt index 8d7053b..fb00746 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Ccs.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Ccs.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class Ccs( +class Ccs( val supported: Boolean = false ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Distribution.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Distribution.kt index b0db964..5130cb1 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Distribution.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Distribution.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Distribution( +class Distribution( val version: Double = 0.0, @JsonProperty("compatible_client") val compatibleClient: List = listOf(), @JsonProperty("client_max") val clientMax: Int = 0, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Features.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Features.kt index fab2afe..275e748 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Features.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Features.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Features( +class Features( @JsonProperty("response_code") val responseCode: Int = 0, val system: System = System(), val zone: List = listOf(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Input.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Input.kt index 73693c2..a03d46b 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Input.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Input.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Input( +class Input( val id: String = "", @JsonProperty("distribution_enable") val distributionEnable: Boolean = false, @JsonProperty("rename_enable") val renameEnable: Boolean = false, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/MasterRole.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/MasterRole.kt index 58f03b5..3d37da9 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/MasterRole.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/MasterRole.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class MasterRole( +class MasterRole( @JsonProperty("surround_pair") val surroundPair: Boolean = false, @JsonProperty("stereo_pair") val stereoPair: Boolean = false, @JsonProperty("subwoofer_pair") val subwooferPair: Boolean = false diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McPlaylist.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McPlaylist.kt index 0d38a91..4cca21d 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McPlaylist.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McPlaylist.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class McPlaylist( +class McPlaylist( val size: Int = 0, val num: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McSurround.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McSurround.kt index ecfd77e..53edf8e 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McSurround.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/McSurround.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class McSurround( +class McSurround( val version: Double = 0.0, @JsonProperty("func_list") val funcList: List = listOf(), @JsonProperty("master_role") val masterRole: MasterRole = MasterRole(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Netusb.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Netusb.kt index 1bd3007..8883a8c 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Netusb.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Netusb.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Netusb( +class Netusb( @JsonProperty("func_list") val funcList: List = listOf(), val preset: PresetX = PresetX(), @JsonProperty("recent_info") val recentInfo: RecentInfo = RecentInfo(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PlayQueue.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PlayQueue.kt index 62a527f..12d29eb 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PlayQueue.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PlayQueue.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class PlayQueue( +class PlayQueue( val size: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Preset.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Preset.kt index 88323f0..87e9b6a 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Preset.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Preset.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class Preset( +class Preset( val type: String = "", val num: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PresetX.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PresetX.kt index 0b8f982..6ed1852 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PresetX.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/PresetX.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class PresetX( +class PresetX( val num: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Qobuz.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Qobuz.kt index ce570c1..0bb01ea 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Qobuz.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Qobuz.kt @@ -3,6 +3,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Qobuz( +class Qobuz( @JsonProperty("login_type") val loginType: String = "" ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStep.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStep.kt index 8eac3d5..ea75902 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStep.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStep.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class RangeStep( +class RangeStep( val id: String = "", val min: Double = 0.0, val max: Double = 0.0, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStepX.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStepX.kt index 50200b6..ff805a6 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStepX.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RangeStepX.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class RangeStepX( +class RangeStepX( val id: String = "", val min: Int = 0, val max: Int = 0, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RecentInfo.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RecentInfo.kt index 97efef7..67858b5 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RecentInfo.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/RecentInfo.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class RecentInfo( +class RecentInfo( val num: Int = 0 ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/SlaveRole.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/SlaveRole.kt index f313d06..ce3a44d 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/SlaveRole.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/SlaveRole.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class SlaveRole( +class SlaveRole( @JsonProperty("surround_pair_l_or_r") val surroundPairLOrR: Boolean = false, @JsonProperty("surround_pair_lr") val surroundPairLr: Boolean = false, @JsonProperty("subwoofer_pair") val subwooferPair: Boolean = false diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/System.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/System.kt index f57c2c6..ad703f0 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/System.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/System.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class System( +class System( @JsonProperty("func_list") val funcList: List = listOf(), @JsonProperty("zone_num") val zoneNum: Int = 0, @JsonProperty("input_list") val inputList: List = listOf(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tidal.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tidal.kt index 703dcc1..6297421 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tidal.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tidal.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features -data class Tidal( +class Tidal( val mode: String = "" ) diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tuner.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tuner.kt index d658a31..7713ee5 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tuner.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Tuner.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Tuner( +class Tuner( @JsonProperty("func_list") val funcList: List = listOf(), @JsonProperty("range_step") val rangeStep: List = listOf(), val preset: Preset = Preset() diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Zone.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Zone.kt index f9ffeba..8d3b93e 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Zone.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/hardware/yamahaadvantage/model/features/Zone.kt @@ -3,7 +3,7 @@ package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.feature import com.fasterxml.jackson.annotation.JsonProperty -data class Zone( +class Zone( val id: String = "", @JsonProperty("func_list") val funcList: List = listOf(), @JsonProperty("input_list") val inputList: List = listOf(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Calibration.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Calibration.kt index 1f86c03..d9c87ae 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Calibration.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Calibration.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.dmx.fixture -data class Calibration( +class Calibration( val blue: Double? = 1.0, val green: Double? = 1.0, val red: Double? = 1.0 diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Channel.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Channel.kt index 51c298f..9a8e3a0 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Channel.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Channel.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.dmx.fixture -data class Channel( +class Channel( val channelOffset: Int = 0, val function: String? = null, val maxValue: Int = 255, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Fixture.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Fixture.kt index 996a423..089b4ad 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Fixture.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Fixture.kt @@ -12,7 +12,7 @@ import kotlin.math.round @JsonIgnoreProperties("channelsForCurrentMode") -data class Fixture( +class Fixture( val calibration: Calibration = Calibration(), val channels: Map> = mapOf(), val colorPresets: Map> = mapOf(), diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Range.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Range.kt index ce34a8a..44fe873 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Range.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/fixture/Range.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.dmx.fixture -data class Range( +class Range( val minValue: Int = 0, val name: String? = null, val type: RangeType? = null diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/Dmx.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/Dmx.kt index 2faa9d6..775d1bf 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/Dmx.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/Dmx.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.dmx.model -data class Dmx( +class Dmx( val port: String = "", val interfaceType: DmxInterfaceType = DmxInterfaceType.Dummy, val frameTime: Long = 40L, diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/DmxDevice.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/DmxDevice.kt index 75f5430..7ed6afb 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/DmxDevice.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/dmx/model/DmxDevice.kt @@ -5,7 +5,7 @@ import de.visualdigits.kotlin.klanglicht.model.dmx.fixture.Fixture @JsonIgnoreProperties("fixture") -data class DmxDevice( +class DmxDevice( val manufacturer: String = "", val model: String = "", val mode: String = "", diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Preferences.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Preferences.kt index a3d5ac5..659ac18 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Preferences.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Preferences.kt @@ -23,12 +23,16 @@ import java.nio.file.Paths @JsonIgnoreProperties("klanglichtDir", "dmxInterface", "fixtures", "serviceMap", "shellyMap", "twinklyMap", "stageMap", "log") -data class Preferences( - private val services: List = listOf(), - private val shelly: List? = listOf(), - private val twinkly: List? = listOf(), - private val stage: List = listOf(), - private val dmx: Dmx? = null +class Preferences( + var name: String = "", + var theme: String = "", + var fadeDurationDefault: Long = 0, + var ownUrl: String = "", + var services: List = listOf(), + var shelly: List? = listOf(), + var twinkly: List? = listOf(), + var stage: List = listOf(), + var dmx: Dmx? = null ) { private val log: Logger = LoggerFactory.getLogger(javaClass) @@ -73,6 +77,27 @@ data class Preferences( } } + fun initialHybridScene(): HybridScene { + val gains = stage.mapNotNull { sd -> + when (sd.type) { + HybridDeviceType.dmx -> { + dmx?.dmxDevices?.get(sd.id)?.gain?:1.0 + } + + HybridDeviceType.shelly -> getShellyGain(sd.id) + HybridDeviceType.twinkly -> getTwinklyConfiguration(sd.id)?.let { if (it.xledArray.isLoggedIn()) it.gain else null } + else -> null + } + } + return HybridScene( + ids = stage.map { it.id }, + hexColors = listOf("000000"), + gains = gains, + turnOns = "false", + preferences = this + ) + } + fun initialize(klanglichtDirectory: File) { val dmxFixtures = Fixtures.load(klanglichtDirectory) fixtures = dmx?.devices?.mapNotNull { stageFixture -> @@ -121,27 +146,6 @@ data class Preferences( this.xledDevices = xledDevices } - fun initialHybridScene(): HybridScene { - val gains = stage.mapNotNull { sd -> - when (sd.type) { - HybridDeviceType.dmx -> { - dmx?.dmxDevices?.get(sd.id)?.gain?:1.0 - } - - HybridDeviceType.shelly -> getShellyGain(sd.id) - HybridDeviceType.twinkly -> getTwinklyConfiguration(sd.id)?.let { if (it.xledArray.isLoggedIn()) it.gain else null } - else -> null - } - } - return HybridScene( - ids = stage.map { it.id }, - hexColors = listOf("000000"), - gains = gains, - turnOns = "false", - preferences = this - ) - } - fun getService(id: String): Service? = serviceMap[id] fun getStageIds(): List = stage.map { it.id } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Service.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Service.kt index 4dcaa4a..edd5e5a 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Service.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/Service.kt @@ -1,7 +1,7 @@ package de.visualdigits.kotlin.klanglicht.model.preferences -data class Service( +class Service( val name: String = "", val manufacturer: String = "", val model: String = "", diff --git a/klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/ShellyDeviceTest.kt b/klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/ShellyDeviceTest.kt index 81513c4..78592ea 100644 --- a/klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/ShellyDeviceTest.kt +++ b/klanglicht-module-base/src/test/kotlin/de/visualdigits/kotlin/klanglicht/model/preferences/ShellyDeviceTest.kt @@ -1,9 +1,12 @@ package de.visualdigits.kotlin.klanglicht.model.preferences +import de.visualdigits.kotlin.klanglicht.hardware.shelly.model.status.Light import de.visualdigits.kotlin.klanglicht.model.color.RGBColor +import de.visualdigits.kotlin.util.get import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.io.File +import java.net.URL @Disabled("for local testing only") class ShellyDeviceTest { @@ -15,6 +18,9 @@ class ShellyDeviceTest { @Test fun testSetColor() { - preferences.getShellyDevice("Starwars")?.setColor(RGBColor(0,0,255)) + val ipAddress = preferences.getShellyDevice("Starwars")?.ipAddress!! + val color = RGBColor(0,0,255) + URL("http://$ipAddress/color/0?turn=on&red=${color.red}&green=${color.green}&blue=${color.blue}&white=0&gain=100&transition=1&") + .get() } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/Application.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/Application.kt index d5452c9..c16bda4 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/Application.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/Application.kt @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.ConfigurableApplicationContext @SpringBootApplication -open class Application { +class Application { companion object { private var context: ConfigurableApplicationContext? = null diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/ResourceController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/ResourceController.kt index 5ee3444..3d3abaa 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/ResourceController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/ResourceController.kt @@ -1,6 +1,6 @@ package de.visualdigits.kotlin.klanglicht.rest -import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder +import de.visualdigits.kotlin.klanglicht.rest.configuration.ApplicationPreferences import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse import org.apache.tika.detect.Detector @@ -16,12 +16,11 @@ import java.io.BufferedInputStream import java.io.File import java.io.FileInputStream import java.io.IOException -import java.io.UnsupportedEncodingException import java.net.URLDecoder @Controller class ResourceController( - val configHolder: ConfigHolder + val prefs: ApplicationPreferences ) { private val log: Logger = LoggerFactory.getLogger(javaClass) @@ -31,7 +30,7 @@ class ResourceController( val src = URLDecoder .decode(request.requestURI, request.characterEncoding) ?.substring("/resources".length)?:"" - val file = configHolder.getAbsoluteResource(src) + val file = prefs.getAbsoluteResource(src) try { FileInputStream(file).use { ins -> response.outputStream.use { outs -> diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ApplicationPreferences.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ApplicationPreferences.kt index bee410e..47591a9 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ApplicationPreferences.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ApplicationPreferences.kt @@ -1,15 +1,75 @@ package de.visualdigits.kotlin.klanglicht.rest.configuration +import de.visualdigits.kotlin.klanglicht.hardware.lightmanager.model.lm.LMScenes +import de.visualdigits.kotlin.klanglicht.model.dmx.parameter.Fadeable +import de.visualdigits.kotlin.klanglicht.model.hybrid.HybridScene +import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences +import jakarta.annotation.PostConstruct +import jakarta.annotation.PreDestroy +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Value import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationPropertiesScan import org.springframework.context.annotation.Configuration +import java.io.File +import java.nio.file.Paths @Configuration @ConfigurationProperties(prefix = "application") @ConfigurationPropertiesScan class ApplicationPreferences { - var name: String = "" - var theme: String = "" - var fadeDurationDefault: Long = 0 - var ownUrl: String = "" + + private val log: Logger = LoggerFactory.getLogger(javaClass) + + var preferences: Preferences? = null + + @Value("\${application.klanglichtDirectory}") + var klanglichtDirectory: File = File("/") + + var currentScene: HybridScene? = null + val colorStore: MutableMap = mutableMapOf() + + @PostConstruct + fun initialize() { + preferences?.initialize(klanglichtDirectory) + + log.info("#### setUp - start") + log.info("##") + log.info("## klanglichtDirectory: " + klanglichtDirectory.absolutePath) + currentScene = preferences?.initialHybridScene() + currentScene?.write(preferences, true, 1000) + log.info("#### setUp - end") + } + + @PreDestroy + fun tearDown() { + log.info("#### tearDown - start") + preferences?.tearDownDmx() + log.info("#### tearDown - end") + } + + fun getAbsoluteResource(relativeResourePath: String): File { + return Paths.get(klanglichtDirectory.absolutePath, "resources", relativeResourePath).toFile() + } + + fun getFadeable(id: String): Fadeable<*>? { + return currentScene?.getFadeable(id) + } + + fun updateScene(nextScene: HybridScene) { + currentScene?.update(nextScene) + } + + fun putColor(id: String, hexColor: String?) { + hexColor?.let { colorStore[id] = it } + } + + fun getColor(id: String): String? { + return colorStore[id] + } + + fun scenes(): LMScenes { + return LMScenes.unmarshall(Paths.get(klanglichtDirectory.canonicalPath, "preferences", "scenes.json").toFile()) + } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt deleted file mode 100644 index 3e5e79e..0000000 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/ConfigHolder.kt +++ /dev/null @@ -1,70 +0,0 @@ -package de.visualdigits.kotlin.klanglicht.rest.configuration - -import de.visualdigits.kotlin.klanglicht.hardware.lightmanager.model.lm.LMScenes -import de.visualdigits.kotlin.klanglicht.model.dmx.parameter.Fadeable -import de.visualdigits.kotlin.klanglicht.model.hybrid.HybridScene -import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences -import de.visualdigits.kotlin.util.SystemUtils -import jakarta.annotation.PostConstruct -import jakarta.annotation.PreDestroy -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Component -import java.io.File -import java.nio.file.Paths - -@Component -class ConfigHolder { - - private val log: Logger = LoggerFactory.getLogger(javaClass) - - var preferences: Preferences? = null - - val klanglichtDirectory: File = File(SystemUtils.getUserHome(), ".klanglicht") - - var currentScene: HybridScene? = null - val colorStore: MutableMap = mutableMapOf() - - @PostConstruct - fun initialize() { - // load preferences - log.info("#### setUp - start") - log.info("##") - log.info("## klanglichtDirectory: " + klanglichtDirectory.absolutePath) - preferences = Preferences.load(klanglichtDirectory) - currentScene = preferences?.initialHybridScene() - currentScene?.write(preferences, true, 1000) - log.info("#### setUp - end") - } - - fun scenes(): LMScenes { - return LMScenes.unmarshall(Paths.get(klanglichtDirectory.canonicalPath, "preferences", "scenes.json").toFile()) - } - - @PreDestroy - fun tearDown() { - log.info("#### tearDown - start") - preferences?.tearDownDmx() - log.info("#### tearDown - end") - } - - fun getAbsoluteResource(relativeResourePath: String): File { - return Paths.get(klanglichtDirectory.absolutePath, "resources", relativeResourePath).toFile() - } - - fun getFadeable(id: String): Fadeable<*>? { - return currentScene?.getFadeable(id) - } - - fun updateScene(nextScene: HybridScene) { - currentScene?.update(nextScene) - } - - fun putColor(id: String, hexColor: String?) { - hexColor?.let { colorStore[id] = it } - } - - fun getColor(id: String): String? { - return colorStore[id] - } -} diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/RequestLoggingFilterConfig.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/RequestLoggingFilterConfig.kt index c2b0fef..bad8e82 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/RequestLoggingFilterConfig.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/RequestLoggingFilterConfig.kt @@ -4,10 +4,10 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration -open class RequestLoggingFilterConfig { +class RequestLoggingFilterConfig { @Bean - open fun logFilter(): SimpleRequestLoggingFilter { + fun logFilter(): SimpleRequestLoggingFilter { val filter = SimpleRequestLoggingFilter() filter.setBeforeMessagePrefix("Request [") filter.setIncludeQueryString(true) diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/SimpleRequestLoggingFilter.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/SimpleRequestLoggingFilter.kt index af9249b..cda581f 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/SimpleRequestLoggingFilter.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/SimpleRequestLoggingFilter.kt @@ -4,7 +4,7 @@ import jakarta.servlet.http.HttpServletRequest import org.springframework.beans.factory.annotation.Value import org.springframework.web.filter.AbstractRequestLoggingFilter -open class SimpleRequestLoggingFilter : AbstractRequestLoggingFilter() { +class SimpleRequestLoggingFilter : AbstractRequestLoggingFilter() { @Value("\${server.logging.requestLogging}") private var enableReuestLogging: Boolean? = false diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/WebConfig.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/WebConfig.kt index 2f9da35..ef5b4ec 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/WebConfig.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/configuration/WebConfig.kt @@ -15,9 +15,8 @@ import org.thymeleaf.templateresolver.ITemplateResolver import java.nio.file.Paths @Configuration -open class WebConfig( - private val prefs: ApplicationPreferences, - private val configHolder: ConfigHolder +class WebConfig( + private val prefs: ApplicationPreferences ) : WebMvcConfigurer { override fun addCorsMappings(registry: CorsRegistry) { @@ -26,13 +25,13 @@ open class WebConfig( @Bean @Description("Thymeleaf file system template resolver serving HTML 5") - open fun templateResolver(): ITemplateResolver { + fun templateResolver(): ITemplateResolver { val templateResolver = FileTemplateResolver() val templatesPath = Paths.get( - configHolder.klanglichtDirectory.absolutePath, + prefs.klanglichtDirectory.absolutePath, "resources", "themes", - prefs.theme, + prefs.preferences?.theme, "templates" ).toFile().absolutePath.replace("\\", "/") + "/" templateResolver.prefix = templatesPath @@ -45,7 +44,7 @@ open class WebConfig( @Bean @Description("Thymeleaf template engine with Spring integration") - open fun templateEngine(): SpringTemplateEngine { + fun templateEngine(): SpringTemplateEngine { val templateEngine = SpringTemplateEngine() templateEngine.setTemplateResolver(templateResolver()) return templateEngine @@ -53,7 +52,7 @@ open class WebConfig( @Bean @Description("Thymeleaf view resolver") - open fun viewResolver(): ViewResolver { + fun viewResolver(): ViewResolver { val viewResolver = ThymeleafViewResolver() viewResolver.templateEngine = templateEngine() viewResolver.characterEncoding = "UTF-8" diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/controller/HybridStageWebController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/controller/HybridStageWebController.kt index 9c8805e..0435ce7 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/controller/HybridStageWebController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/controller/HybridStageWebController.kt @@ -1,7 +1,6 @@ package de.visualdigits.kotlin.klanglicht.rest.hybrid.controller import de.visualdigits.kotlin.klanglicht.rest.configuration.ApplicationPreferences -import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMHtmlScenes import org.springframework.stereotype.Controller import org.springframework.ui.Model @@ -11,16 +10,15 @@ import org.springframework.web.bind.annotation.RequestMapping @Controller @RequestMapping("/v1/hybrid/web") class HybridStageWebController( - private val prefs: ApplicationPreferences, - private val configHolder: ConfigHolder, + private val prefs: ApplicationPreferences ) { @GetMapping("/scenes", produces = ["application/xhtml+xml"]) fun scenes(model: Model): String { - model.addAttribute("theme", prefs.theme) + model.addAttribute("theme", prefs.preferences?.theme) model.addAttribute("title", "Scenes") - val scenes = LMHtmlScenes(configHolder.scenes()) - model.addAttribute("content", scenes.toHtml(prefs, configHolder)) + val scenes = LMHtmlScenes(prefs.scenes()) + model.addAttribute("content", scenes.toHtml(prefs)) return "pagetemplate" } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/service/HybridStageService.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/service/HybridStageService.kt index 74d0219..207807e 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/service/HybridStageService.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/hybrid/service/HybridStageService.kt @@ -1,17 +1,15 @@ package de.visualdigits.kotlin.klanglicht.rest.hybrid.service -import de.visualdigits.kotlin.klanglicht.hardware.shelly.client.ShellyClient import de.visualdigits.kotlin.klanglicht.model.hybrid.HybridScene import de.visualdigits.kotlin.klanglicht.rest.configuration.ApplicationPreferences -import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder +import de.visualdigits.kotlin.klanglicht.rest.shelly.webclient.ShellyClient import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @Service class HybridStageService( - private val prefs: ApplicationPreferences, - private val configHolder: ConfigHolder + private val prefs: ApplicationPreferences ) { private val log: Logger = LoggerFactory.getLogger(javaClass) @@ -24,7 +22,7 @@ class HybridStageService( * @param gains The comma separated list of gains (taken from stage setup if omitted). * @param transition The fade duration in milli seconds. * @param turnOn Determines if the device should be turned on. - * @param store Determines if the colors should be saved in the ConfigHolder. + * @param store Determines if the colors should be saved in the prefs. * @param storeName An additional name to strore values. */ fun hexColor( @@ -36,29 +34,29 @@ class HybridStageService( store: Boolean = true, storeName: String? = null ) { - val currentScene = configHolder.currentScene?.clone() - val nextScene = configHolder.currentScene?.clone()?.let { n -> - HybridScene(ids, hexColors, gains, turnOn.toString(), preferences = configHolder.preferences).fadeableMap().forEach { + val currentScene = prefs.currentScene?.clone() + val nextScene = prefs.currentScene?.clone()?.let { n -> + HybridScene(ids, hexColors, gains, turnOn.toString(), preferences = prefs.preferences).fadeableMap().forEach { n.putFadeable(it.key, it.value) } n } if (store) { - configHolder.updateScene(nextScene!!) + prefs.updateScene(nextScene!!) if (storeName != null) { - configHolder.putColor(storeName, hexColors.joinToString(",")) + prefs.putColor(storeName, hexColors.joinToString(",")) } } log.info("nextScene: $nextScene") - currentScene?.fade(nextScene!!, transition?: prefs.fadeDurationDefault, configHolder.preferences!!) + currentScene?.fade(nextScene!!, transition?: prefs.preferences?.fadeDurationDefault?:2000, prefs.preferences!!) } fun putColor( id: String, hexColor: String, ) { - configHolder.putColor(id, hexColor) + prefs.putColor(id, hexColor) } @@ -67,7 +65,7 @@ class HybridStageService( transitionDuration: Long? ) { ids.forEach { id -> - configHolder.getFadeable(id)?.write(configHolder.preferences!!, transitionDuration = transitionDuration?:prefs.fadeDurationDefault) + prefs.getFadeable(id)?.write(prefs.preferences!!, transitionDuration = transitionDuration?:prefs.preferences?.fadeDurationDefault?:2000) } } @@ -78,13 +76,13 @@ class HybridStageService( ) { ids.forEach { id -> val sid = id.trim() - val shellyDevice = configHolder.preferences?.getShellyDevice(sid) + val shellyDevice = prefs.preferences?.getShellyDevice(sid) if (shellyDevice != null) { val ipAddress: String = shellyDevice.ipAddress - val lastColor = configHolder.getFadeable(sid) + val lastColor = prefs.getFadeable(sid) lastColor?.setGain(gain.toDouble()) try { - ShellyClient.setGain(ipAddress = ipAddress, gain = gain, transitionDuration = transitionDuration?: prefs.fadeDurationDefault) + ShellyClient.setGain(ipAddress = ipAddress, gain = gain, transitionDuration = transitionDuration?: prefs.preferences?.fadeDurationDefault?:2000) } catch (e: Exception) { log.warn("Could not get gain for shelly at '$ipAddress'") } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/controller/LightmanagerWebController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/controller/LightmanagerWebController.kt index 272c79c..0332fec 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/controller/LightmanagerWebController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/controller/LightmanagerWebController.kt @@ -1,7 +1,6 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.controller import de.visualdigits.kotlin.klanglicht.rest.configuration.ApplicationPreferences -import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMHtmlScenes import de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html.LMHtmlZones import de.visualdigits.kotlin.klanglicht.rest.lightmanager.service.LightmanagerService @@ -14,25 +13,24 @@ import org.springframework.web.bind.annotation.RequestMapping @RequestMapping("/v1/lightmanager/web") class LightmanagerWebController( private val prefs: ApplicationPreferences, - private val configHolder: ConfigHolder, private val lightmanagerService: LightmanagerService ) { @GetMapping("/scenes", produces = ["application/xhtml+xml"]) fun scenes(model: Model): String { - model.addAttribute("theme", prefs.theme) + model.addAttribute("theme", prefs.preferences?.theme) model.addAttribute("title", "Scenes") val scenes = lightmanagerService.scenes()?.let { LMHtmlScenes(it) } - model.addAttribute("content", scenes?.toHtml(prefs, configHolder)) + model.addAttribute("content", scenes?.toHtml(prefs)) return "pagetemplate" } @GetMapping("/zones", produces = ["application/xhtml+xml"]) fun zones(model: Model): String { - model.addAttribute("theme", prefs.theme) + model.addAttribute("theme", prefs.preferences?.theme) model.addAttribute("title", "Zones") val zones = lightmanagerService.zones()?.let { LMHtmlZones(it) } - model.addAttribute("content", zones?.toHtml(prefs, configHolder)) + model.addAttribute("content", zones?.toHtml(prefs)) return "pagetemplate" } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/ColorWheel.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/ColorWheel.kt index 2306558..cbc464f 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/ColorWheel.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/kotlin/klanglicht/rest/lightmanager/model/html/ColorWheel.kt @@ -1,7 +1,6 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html import de.visualdigits.kotlin.klanglicht.rest.configuration.ApplicationPreferences -import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -11,11 +10,11 @@ class ColorWheel( private val log: Logger = LoggerFactory.getLogger(javaClass) - override fun toHtml(prefs: ApplicationPreferences, configHolder: ConfigHolder?): String { - return toHtml(prefs, configHolder, false) + override fun toHtml(prefs: ApplicationPreferences): String { + return toHtml(prefs, false) } - fun toHtml(prefs: ApplicationPreferences, configHolder: ConfigHolder?, oddEven: Boolean): String { + fun toHtml(prefs: ApplicationPreferences, oddEven: Boolean): String { val wheelId = id!!.replace(" ", "") val sb = StringBuilder() @@ -25,13 +24,13 @@ class ColorWheel( renderColorWheelPanel(sb, wheelId, true) renderColorWheelPanel(sb, wheelId, false) - renderScript(sb, wheelId, true, configHolder) + renderScript(sb, wheelId, true, prefs) sb.append("\t\t\n") } else { sb.append("\t
\n") renderColorWheelPanel(sb, wheelId, null) - renderScript(sb, wheelId, false, configHolder) + renderScript(sb, wheelId, false, prefs) sb.append("\t\t
\n") } @@ -51,17 +50,17 @@ class ColorWheel( sb.append("\t\t\n") } - private fun renderScript(sb: StringBuilder, wheelId: String, oddEven: Boolean, configHolder: ConfigHolder?) { + private fun renderScript(sb: StringBuilder, wheelId: String, oddEven: Boolean, prefs: ApplicationPreferences) { if (oddEven) { sb.append("\t\t\n") } else { - val hexColor = configHolder?.getFadeable(wheelId) + val hexColor = prefs.getFadeable(wheelId) ?.getRgbColor()?.web() - ?:configHolder?.getColor(wheelId) + ?:prefs.getColor(wheelId) ?:"000000" sb.append("\t\t