diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMActionLmYamahaAvantage.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMActionLmYamahaAvantage.kt index 571aab9..8342573 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMActionLmYamahaAvantage.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMActionLmYamahaAvantage.kt @@ -3,12 +3,13 @@ package de.visualdigits.klanglicht.hardware.lightmanager.model.lm class LMActionLmYamahaAvantage( val command: String? = null, val program: String? = null, + val enable: Boolean? = null, ) : LMAction() { override fun toString(): String { - return "[YamahaAvantage] command=$command program=$program" + return "[YamahaAvantage] command=$command program=$program enable=$enable" } - override fun url(): String = "/v1/scenes/json/yamahaAvantage?command=$command&program=$program&" + override fun url(): String = "/v1/scenes/json/yamahaAvantage?command=$command&program=$program&enable=$enable&" } diff --git a/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMScenes.kt b/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMScenes.kt index 98f595d..8be376e 100644 --- a/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMScenes.kt +++ b/klanglicht-module-base/src/main/kotlin/de/visualdigits/klanglicht/hardware/lightmanager/model/lm/LMScenes.kt @@ -1,11 +1,8 @@ package de.visualdigits.klanglicht.hardware.lightmanager.model.lm import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.dataformat.yaml.YAMLFactory -import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder import com.fasterxml.jackson.module.kotlin.kotlinModule import java.io.File import java.util.Locale diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/hybrid/service/HybridStageService.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/hybrid/service/HybridStageService.kt index 23ad3b4..ea147e9 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/hybrid/service/HybridStageService.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/hybrid/service/HybridStageService.kt @@ -1,7 +1,7 @@ package de.visualdigits.klanglicht.hybrid.service -import de.visualdigits.klanglicht.model.hybrid.HybridScene import de.visualdigits.klanglicht.configuration.ApplicationPreferences +import de.visualdigits.klanglicht.model.hybrid.HybridScene import de.visualdigits.klanglicht.shelly.webclient.ShellyClient import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/lightmanager/model/html/page/LMHtmlScenes.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/lightmanager/model/html/page/LMHtmlScenes.kt index ab212ac..11532f9 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/lightmanager/model/html/page/LMHtmlScenes.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/lightmanager/model/html/page/LMHtmlScenes.kt @@ -1,8 +1,8 @@ package de.visualdigits.klanglicht.lightmanager.model.html.page +import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMSceneGroup import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMScenes -import de.visualdigits.klanglicht.configuration.ApplicationPreferences import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/controller/ScenesRestController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/controller/ScenesRestController.kt index 772fa5a..6d026c5 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/controller/ScenesRestController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/controller/ScenesRestController.kt @@ -53,8 +53,9 @@ class ScenesRestController( @GetMapping("yamahaAvantage") fun yamaha( @RequestParam(value = "command") command: String, - @RequestParam(value = "program") program: String + @RequestParam(value = "program") program: String, + @RequestParam(value = "enable") enable: Boolean ) { - scenesService.yamahaAvantage(command, program) + scenesService.yamahaAvantage(command, program, enable) } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/service/ScenesService.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/service/ScenesService.kt index 4001530..c19e00c 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/service/ScenesService.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/scenes/service/ScenesService.kt @@ -1,11 +1,11 @@ package de.visualdigits.klanglicht.scenes.service +import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMActionHybrid import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMActionLmAir import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMActionLmYamahaAvantage import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMActionPause import de.visualdigits.klanglicht.hardware.lightmanager.model.lm.LMActionShelly -import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.hybrid.service.HybridStageService import de.visualdigits.klanglicht.lightmanager.service.LightmanagerService import de.visualdigits.klanglicht.shelly.service.ShellyService @@ -48,6 +48,7 @@ class ScenesService( is LMActionLmYamahaAvantage -> { when (action.command) { "surroundProgram" -> yamahaAvantageService.setSurroundProgram(program = action.program) + "setPureDirect" -> yamahaAvantageService.setPureDirect(enable = action.enable) } } @@ -80,9 +81,10 @@ class ScenesService( lightmanagerService.controlIndex(index = sceneIndex) } - fun yamahaAvantage(command: String, program: String) { + fun yamahaAvantage(command: String, program: String, enable: Boolean) { when (command) { "surroundProgram" -> yamahaAvantageService.setSurroundProgram(program = program) + "setPureDirect" -> yamahaAvantageService.setPureDirect(enable = enable) } } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/controller/ShellyWebController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/controller/ShellyWebController.kt index d59114e..25c2629 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/controller/ShellyWebController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/controller/ShellyWebController.kt @@ -2,7 +2,6 @@ package de.visualdigits.klanglicht.shelly.controller import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.shelly.model.html.ShellyStatus -import de.visualdigits.klanglicht.shelly.service.ShellyService import jakarta.servlet.http.HttpServletRequest import org.springframework.stereotype.Controller import org.springframework.ui.Model diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyService.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyService.kt index fce31e8..0483d1c 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyService.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyService.kt @@ -1,8 +1,8 @@ package de.visualdigits.klanglicht.shelly.service +import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.hardware.shelly.model.ShellyDevice import de.visualdigits.klanglicht.hardware.shelly.model.status.Status -import de.visualdigits.klanglicht.configuration.ApplicationPreferences import de.visualdigits.klanglicht.shelly.webclient.ShellyClient import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/controller/YamahaAvantageRestController.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/controller/YamahaAvantageRestController.kt index 9d1beb1..b36e36e 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/controller/YamahaAvantageRestController.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/controller/YamahaAvantageRestController.kt @@ -21,4 +21,10 @@ class YamahaAvantageRestController( log.info("Setting surround sound program to '$program'") yamahaAvantageService.setSurroundProgram(program) } + + @PutMapping("/setPureDirect") + fun controlSurroundProgram(@RequestParam("enable") enable: Boolean) { + log.info("Setting pure direct to '$enable'") + yamahaAvantageService.setPureDirect(enable) + } } diff --git a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/service/YamahaAvantageService.kt b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/service/YamahaAvantageService.kt index e799b34..8a67c99 100644 --- a/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/service/YamahaAvantageService.kt +++ b/klanglicht-rest/src/main/kotlin/de/visualdigits/klanglicht/yamahaavantage/service/YamahaAvantageService.kt @@ -1,6 +1,5 @@ package de.visualdigits.klanglicht.yamahaavantage.service -import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import de.visualdigits.klanglicht.hardware.yamahaadvantage.model.ResponseCode import de.visualdigits.klanglicht.hardware.yamahaadvantage.model.SoundProgramList @@ -8,10 +7,8 @@ import de.visualdigits.klanglicht.hardware.yamahaadvantage.model.deviceinfo.Devi import de.visualdigits.klanglicht.hardware.yamahaadvantage.model.features.Features import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import org.springframework.web.reactive.function.client.WebClient -import java.net.URL @Service class YamahaAvantageService( @@ -89,6 +86,15 @@ class YamahaAvantageService( .block() } + fun setPureDirect(enable: Boolean?) { + webClientReceiver + .get() + .uri("/YamahaExtendedControl/v1/main/setPureDirect?enable=$enable") + .retrieve() + .bodyToMono(String::class.java) + .block() + } + fun setSurroundProgram(program: String?): ResponseCode { log.info("Setting program '${mapPrograms[program]}'") return program?.let { p -> diff --git a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/lightmanager/service/LightmanagerServiceTest.kt b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/lightmanager/service/LightmanagerServiceTest.kt index 7693005..75c7b94 100644 --- a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/lightmanager/service/LightmanagerServiceTest.kt +++ b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/lightmanager/service/LightmanagerServiceTest.kt @@ -3,7 +3,6 @@ package de.visualdigits.klanglicht.lightmanager.service import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder -import de.visualdigits.klanglicht.lightmanager.service.LightmanagerService import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyServiceTest.kt b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyServiceTest.kt index 6ebf45a..8217476 100644 --- a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyServiceTest.kt +++ b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/service/ShellyServiceTest.kt @@ -1,6 +1,5 @@ package de.visualdigits.klanglicht.shelly.service -import de.visualdigits.klanglicht.shelly.service.ShellyService import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired diff --git a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/webclient/ShellyClientTest.kt b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/webclient/ShellyClientTest.kt index 1a4fcdd..3e1caf3 100644 --- a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/webclient/ShellyClientTest.kt +++ b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/shelly/webclient/ShellyClientTest.kt @@ -1,6 +1,5 @@ package de.visualdigits.klanglicht.shelly.webclient -import de.visualdigits.klanglicht.shelly.webclient.ShellyClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/yamahaavantage/webclient/YamahaAvantageReceiverClientTest.kt b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/yamahaavantage/webclient/YamahaAvantageReceiverClientTest.kt index d247ad2..b4ad91d 100644 --- a/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/yamahaavantage/webclient/YamahaAvantageReceiverClientTest.kt +++ b/klanglicht-rest/src/test/kotlin/de/visualdigits/klanglicht/yamahaavantage/webclient/YamahaAvantageReceiverClientTest.kt @@ -2,7 +2,6 @@ package de.visualdigits.klanglicht.yamahaavantage.webclient import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder -import com.fasterxml.jackson.module.kotlin.jsonMapper import de.visualdigits.klanglicht.yamahaavantage.service.YamahaAvantageService import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Disabled