Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sknull committed Mar 31, 2024
1 parent 107cb51 commit 13d8319
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 104 deletions.
8 changes: 8 additions & 0 deletions klanglicht-module-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,13 @@
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
</dependency>

<!-- jackson -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.16.1</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ import org.junit.jupiter.api.Test
class ShellyClientTest {

@Test
fun testPower() {
ShellyClient.setPower(ipAddress = "192.168.178.38", command = "relay/0", turnOn = false)
fun testPowerOn() {
ShellyClient.setPower(
ipAddress = "192.168.178.38",
command = "relay/0",
turnOn = true
)
}

@Test
fun testPowerOff() {
ShellyClient.setPower(
ipAddress = "192.168.178.38",
command = "relay/0",
turnOn = false
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.visualdigits.kotlin.klanglicht.dmx
package de.visualdigits.kotlin.klanglicht.model.dmx

import de.visualdigits.kotlin.klanglicht.hardware.color.RGBColor
import de.visualdigits.kotlin.klanglicht.hardware.dmx.parameter.IntParameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.visualdigits.kotlin.klanglicht.dmx
package de.visualdigits.kotlin.klanglicht.model.dmx

import de.visualdigits.kotlin.klanglicht.hardware.color.RGBWColor
import de.visualdigits.kotlin.klanglicht.hardware.dmx.parameter.IntParameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.visualdigits.kotlin.klanglicht.hardware.preferences

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 de.visualdigits.kotlin.klanglicht.hardware.hybrid.HybridScene
import org.junit.jupiter.api.Assertions.assertNotNull
Expand All @@ -13,19 +15,11 @@ class PreferencesTest {
fun testReadModel() {
val preferences = Preferences.load(
klanglichtDirectory = File(ClassLoader.getSystemResource(".klanglicht").toURI()),
preferencesFileName = "preferences_livingroom.json"
// preferencesFileName = "preferences_livingroom.json"
)

assertNotNull(Preferences.preferences)
val mapper = ObjectMapper(YAMLFactory())

val ids = preferences.getStageIds().joinToString(",")
val currentScene = preferences.initialHybridScene()
val nextScene = HybridScene(ids, "ff0000", "1.0", "true", preferences = preferences)
currentScene.update(nextScene)
val cloned = currentScene.clone()

val mapper = jacksonMapperBuilder().enable(SerializationFeature.INDENT_OUTPUT).build()

println()
println(mapper.writeValueAsString(preferences))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"name": "wohnzimmer",
"theme": "StarWars",
"fadeDurationDefault": 2000,

"services": [
{
"name": "lmair",
"manufacturer": "JB-Media",
"model": "Light-Manager Air",
"url": "http://192.168.178.28"
},
{
"name": "receiver",
"manufacturer": "Yamaha",
"model": "RX-V6A",
"url": "http://192.168.178.46"
}
],

"shelly": [
{
"name": "Starwars",
"model": "shelly-rgbw",
"ipAddress": "192.168.178.54",
"command": "color/0",
"gain": 0.2
},
{
"name": "Rgbw",
"model": "shelly-rgbw",
"ipAddress": "192.168.178.48",
"command": "color/0",
"gain": 0.1
},
{
"name": "Bar",
"model": "shelly-rgbw",
"ipAddress": "192.168.178.55",
"command": "color/0",
"gain": 0.1
},
{
"name": "Flur",
"model": "shelly-1",
"ipAddress": "192.168.178.38",
"command": "relay/0",
"gain": 0
},
{
"name": "Schlafzimmer",
"model": "shelly-1",
"ipAddress": "192.168.178.40",
"command": "relay/0",
"gain": 0
},
{
"name": "Wohnzimmer_Esstisch",
"model": "shelly-2.5",
"ipAddress": "192.168.178.37",
"command": "relay/0",
"gain": 0
},
{
"name": "Wohnzimmer_Deckenlampe",
"model": "shelly-2.5",
"ipAddress": "192.168.178.37",
"command": "relay/1",
"gain": 0
},
{
"name": "Kristall",
"model": "plug-s",
"ipAddress": "192.168.178.51",
"command": "relay/0",
"gain": 0
},
{
"name": "Regal",
"model": "shelly-plug-s",
"ipAddress": "192.168.178.39",
"command": "relay/0",
"gain": 0
}
],

"dmx": {
"port": "COM5",
"interfaceType": "Serial",
"frameTime": 40,
"enableRepeater": false,
"devices": [
{
"manufacturer": "Cameo",
"model": "Flat PAR Can RGB 10 IR",
"mode": "6-Channel Mode",
"baseChannel": 1,
"gain": 1.0
},
{
"manufacturer": "Cameo",
"model": "Flat PAR Can RGBW",
"mode": "8-Channel Mode",
"baseChannel": 21,
"gain": 1.0
},
{
"manufacturer": "Cameo",
"model": "Flat PAR Can RGB 10 IR",
"mode": "6-Channel Mode",
"baseChannel": 15,
"gain": 1.0
},
{
"manufacturer": "Cameo",
"model": "Flat PAR Can RGB 10 IR",
"mode": "6-Channel Mode",
"baseChannel": 29,
"gain": 1.0
}
]
},

"stage": [
{
"type": "shelly",
"id": "Starwars"
},
{
"type": "shelly",
"id": "Rgbw"
},
{
"type": "dmx",
"id": "15"
},
{
"type": "dmx",
"id": "29"
},
{
"type": "dmx",
"id": "21"
},
{
"type": "dmx",
"id": "1"
},
{
"type": "shelly",
"id": "Bar"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: wohnzimmer
theme: StarWars
fadeDurationDefault: 2000
services:
- name: lmair
manufacturer: JB-Media
model: Light-Manager Air
url: http://192.168.178.28
- name: receiver
manufacturer: Yamaha
model: RX-V6A
url: http://192.168.178.46
shelly:
- name: Starwars
model: shelly-rgbw
ipAddress: 192.168.178.54
command: color/0
gain: 0.2
- name: Rgbw
model: shelly-rgbw
ipAddress: 192.168.178.48
command: color/0
gain: 0.1
- name: Bar
model: shelly-rgbw
ipAddress: 192.168.178.55
command: color/0
gain: 0.1
- name: Flur
model: shelly-1
ipAddress: 192.168.178.38
command: relay/0
gain: 0
- name: Schlafzimmer
model: shelly-1
ipAddress: 192.168.178.40
command: relay/0
gain: 0
- name: Wohnzimmer_Esstisch
model: shelly-2.5
ipAddress: 192.168.178.37
command: relay/0
gain: 0
- name: Wohnzimmer_Deckenlampe
model: shelly-2.5
ipAddress: 192.168.178.37
command: relay/1
gain: 0
- name: Kristall
model: plug-s
ipAddress: 192.168.178.51
command: relay/0
gain: 0
- name: Regal
model: shelly-plug-s
ipAddress: 192.168.178.39
command: relay/0
gain: 0
dmx:
port: COM5
interfaceType: Serial
frameTime: 40
enableRepeater: false
devices:
- manufacturer: Cameo
model: Flat PAR Can RGB 10 IR
mode: 6-Channel Mode
baseChannel: 1
gain: 1
- manufacturer: Cameo
model: Flat PAR Can RGBW
mode: 8-Channel Mode
baseChannel: 21
gain: 1
- manufacturer: Cameo
model: Flat PAR Can RGB 10 IR
mode: 6-Channel Mode
baseChannel: 15
gain: 1
- manufacturer: Cameo
model: Flat PAR Can RGB 10 IR
mode: 6-Channel Mode
baseChannel: 29
gain: 1
stage:
- type: shelly
id: Starwars
- type: shelly
id: Rgbw
- type: dmx
id: '15'
- type: dmx
id: '29'
- type: dmx
id: '21'
- type: dmx
id: '1'
- type: shelly
id: Bar
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ import java.net.URLEncoder
import java.nio.charset.StandardCharsets

@Controller
class ResourceController {
class ResourceController(
val configHolder: ConfigHolder
) {

private val log: Logger = LoggerFactory.getLogger(javaClass)

@Autowired
val configHolder: ConfigHolder? = null

@GetMapping("/resources/**")
@ResponseBody
fun resource(request: HttpServletRequest, response: HttpServletResponse) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.visualdigits.kotlin.klanglicht.rest.hybrid.controller

import de.visualdigits.kotlin.klanglicht.rest.hybrid.handler.HybridStageHandler
import de.visualdigits.kotlin.klanglicht.rest.hybrid.service.HybridStageService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -10,10 +10,9 @@ import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/v1/hybrid/json")
class HybridStageRestController {

@Autowired
val hybridStageHandler: HybridStageHandler? = null
class HybridStageRestController(
val hybridStageService: HybridStageService? = null
) {

@GetMapping("hexColor")
fun hexColor(
Expand All @@ -25,7 +24,7 @@ class HybridStageRestController {
@RequestParam(value = "store", required = false, defaultValue = "true") store: Boolean,
@RequestParam(value = "storeName", required = false) storeName: String?
) {
hybridStageHandler?.hexColor(
hybridStageService?.hexColor(
ids = ids,
hexColors = hexColors,
gains = gains,
Expand All @@ -41,7 +40,7 @@ class HybridStageRestController {
@RequestParam(value = "id") id: String,
@RequestParam(value = "hexColor") hexColor: String
) {
hybridStageHandler?.putColor(
hybridStageService?.putColor(
id = id,
hexColor = hexColor
)
Expand Down
Loading

0 comments on commit 13d8319

Please sign in to comment.