Skip to content

Commit

Permalink
Replacing ConfigHolder by ApplicationPreferences populated from appli…
Browse files Browse the repository at this point in the history
…cation.yml instead of propreitary JSON
  • Loading branch information
sknull committed Apr 21, 2024
1 parent 2a73d27 commit af3b9c8
Show file tree
Hide file tree
Showing 89 changed files with 288 additions and 369 deletions.
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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<Light>()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "",
Expand All @@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Define> = listOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

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

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

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

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package de.visualdigits.kotlin.klanglicht.hardware.yamaha.model

open class XmlEntity
interface XmlEntity
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = listOf()
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.deviceinfo


data class AnalyticsInfo(
class AnalyticsInfo(
val uuid: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features


data class Ccs(
class Ccs(
val supported: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int> = listOf(),
@JsonProperty("client_max") val clientMax: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Zone> = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = listOf(),
@JsonProperty("master_role") val masterRole: MasterRole = MasterRole(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = listOf(),
val preset: PresetX = PresetX(),
@JsonProperty("recent_info") val recentInfo: RecentInfo = RecentInfo(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features


data class PlayQueue(
class PlayQueue(
val size: Int = 0
)
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.visualdigits.kotlin.klanglicht.hardware.yamahaadvantage.model.features


data class PresetX(
class PresetX(
val num: Int = 0
)
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
)
Loading

0 comments on commit af3b9c8

Please sign in to comment.