Skip to content

Commit

Permalink
Added missing sound programs for Yamaha. Added new feature to set pur…
Browse files Browse the repository at this point in the history
…e direct status for Yamaha
  • Loading branch information
sknull committed Jun 12, 2024
1 parent bbf2424 commit 784955c
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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&"
}

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,6 +48,7 @@ class ScenesService(
is LMActionLmYamahaAvantage -> {
when (action.command) {
"surroundProgram" -> yamahaAvantageService.setSurroundProgram(program = action.program)
"setPureDirect" -> yamahaAvantageService.setPureDirect(enable = action.enable)
}
}

Expand Down Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
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
import de.visualdigits.klanglicht.hardware.yamahaadvantage.model.deviceinfo.DeviceInfo
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(
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

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

0 comments on commit 784955c

Please sign in to comment.