RZL: Move onkyo config into seperate file

This commit is contained in:
uwap 2018-07-12 16:31:20 +02:00
parent 8738577001
commit 837f5a2bc4
5 changed files with 226 additions and 197 deletions

View file

@ -5,7 +5,9 @@ import { hex, rgb, rgba, rainbow } from "config/colors";
import { mdi, rawMdi, mdiBattery } from "config/icon";
import { esper_topics, esper_statistics, floalt, tradfri_remote } from "../utils";
const config : Config = {
import * as onkyo from "./onkyo";
const config: Config = {
space: {
name: "RZL",
color: "orange",
@ -101,116 +103,6 @@ const config : Config = {
},
defaultValue: "off"
},
onkyo_connection: {
state: {
name: "/service/onkyo/connected",
type: types.option({
"0": "disconnected",
"1": "connecting",
"2": "connected"
})
},
defaultValue: "disconnected"
},
onkyo_power: {
state: {
name: "/service/onkyo/status/system-power",
type: types.json("onkyo_raw", types.option({
PWR00: "off",
PWR01: "on"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({ off: "PWR00", on: "PWR01" })
},
defaultValue: "off"
},
onkyo_mute: {
state: {
name: "/service/onkyo/status/audio-muting",
type: types.json("onkyo_raw", types.option({
AMT00: "off",
AMT01: "on"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({ off: "AMT00", on: "AMT01" })
},
defaultValue: "off"
},
onkyo_volume: {
state: {
name: "/service/onkyo/status/volume",
type: types.json("val")
},
command: {
name: "/service/onkyo/set/volume",
type: types.string
},
defaultValue: "0"
},
onkyo_inputs: {
state: {
name: "/service/onkyo/status/input-selector",
type: types.json("onkyo_raw", types.option({
SLI11: "tisch",
SLI01: "chromecast",
SLI10: "pult",
SLI2B: "netzwerk",
SLI03: "front",
otherwise: "unknown"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({
tisch: "SLI11",
chromecast: "SLI01",
pult: "SLI10",
netzwerk: "SLI2B",
front: "SLI03",
unknown: "SLI00"
})
},
defaultValue: "unknown",
},
onkyo_radios: {
state: {
name: "/service/onkyo/status/latest-NPR",
type: types.option({
NPR01: "mpd",
NPR02: "kohina",
NPR03: "somafm_dronezone",
NPR04: "somafm_thetrip",
NPR05: "querfunk",
NPR06: "somafm_defconradio",
NPR07: "somafm_secretagent",
NPR08: "somafm_lush",
NPR09: "somafm_beatblender",
NPR0a: "ponyville",
otherwise: "unknown"
})
},
command: {
name: "/service/onkyo/command",
type: types.option({
mpd: "NPR01",
kohina: "NPR02",
somafm_dronezone: "NPR03",
somafm_thetrip: "NPR04",
querfunk: "NPR05",
somafm_defconradio: "NPR06",
somafm_secretagent: "NPR07",
somafm_lush: "NPR08",
somafm_beatblender: "NPR09",
ponyville: "NPR0a",
otherwise: "NPR00"
})
},
defaultValue: "unknown"
},
rundumleuchte: {
state: {
name: "/service/openhab/out/pca301_rundumleuchte/state",
@ -366,9 +258,12 @@ const config : Config = {
tradfri_remote.topics("65546"),
esper_topics("afba40", "flyfry"),
esper_topics("afba45", "alarm")
esper_topics("afba45", "alarm"),
onkyo.topics
],
controls: {
...onkyo.controls,
led_stahltrager: {
name: "LED Stahlträger",
position: [380, 590],
@ -523,89 +418,6 @@ const config : Config = {
}
]
},
onkyo: {
name: "Onkyo",
position: [350, 650],
iconColor: ({onkyo_connection, onkyo_power}) =>
onkyo_connection != "connected" ? hex("#888888") : (onkyo_power == "on" ? hex("#00FF00") : hex("#000000")),
icon: mdi("audio-video"),
ui: [
{
type: "toggle",
text: "Power",
icon: mdi("power"),
topic: "onkyo_power",
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "section",
text: "Lautstärkeregelung"
},
{
type: "slider",
text: "Volume",
topic: "onkyo_volume",
min: 0,
max: 50,
icon: mdi("volume-high"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "toggle",
text: "Mute",
topic: "onkyo_mute",
icon: mdi("volume-off"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "section",
text: "Eingänge"
},
{
type: "dropDown",
text: "Eingang",
topic: "onkyo_inputs",
options: {
netzwerk: "Netzwerk",
tisch: "Tisch",
chromecast: "Chromecast",
pult: "Pult",
front: "Front HDMI"
},
icon: mdi("usb"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "dropDown",
text: "Netzwerksender",
topic: "onkyo_radios",
options: {
mpd: "MPD",
kohina: "Kohina",
somafm_dronezone: "Drone Zone (SomaFM)",
somafm_thetrip: "The Trip (SomaFM)",
querfunk: "Querfunk",
somafm_defconradio: "Defcon Radio (SomaFM)",
somafm_secretagent: "Secret Agent (SomaFM)",
somafm_lush: "Lush (SomaFM)",
somafm_beatblender: "Beat Blender (Soma FM)",
ponyville: "Ponyville FM"
},
icon: mdi("radio"),
enableCondition: (state) => state.onkyo_connection == "connected" && state.onkyo_inputs == "netzwerk"
},
{
type: "section",
text: "External"
},
{
type: "link",
link: "http://mpd.rzl/mpd/player/index.php",
text: "Open MPD Interface",
icon: mdi("open-in-new")
}
]
},
rundumleuchte: {
name: "Rundumleuchte",
position: [310,275],
@ -972,7 +784,7 @@ const config : Config = {
topic: tradfri_remote.level("65546")
}
]
},
}
},
layers: [
{

204
config/rzl/onkyo.js Normal file
View file

@ -0,0 +1,204 @@
// @flow
import type { Topics, Controls } from "config/flowtypes";
import { mdi } from "config/icon";
import { hex } from "config/colors";
import * as types from "config/types";
export const topics: Topics = {
onkyo_connection: {
state: {
name: "/service/onkyo/connected",
type: types.option({
"0": "disconnected",
"1": "connecting",
"2": "connected"
})
},
defaultValue: "disconnected"
},
onkyo_power: {
state: {
name: "/service/onkyo/status/system-power",
type: types.json("onkyo_raw", types.option({
PWR00: "off",
PWR01: "on"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({ off: "PWR00", on: "PWR01" })
},
defaultValue: "off"
},
onkyo_mute: {
state: {
name: "/service/onkyo/status/audio-muting",
type: types.json("onkyo_raw", types.option({
AMT00: "off",
AMT01: "on"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({ off: "AMT00", on: "AMT01" })
},
defaultValue: "off"
},
onkyo_volume: {
state: {
name: "/service/onkyo/status/volume",
type: types.json("val")
},
command: {
name: "/service/onkyo/set/volume",
type: types.string
},
defaultValue: "0"
},
onkyo_inputs: {
state: {
name: "/service/onkyo/status/input-selector",
type: types.json("onkyo_raw", types.option({
SLI11: "tisch",
SLI01: "chromecast",
SLI10: "pult",
SLI2B: "netzwerk",
SLI03: "front",
otherwise: "unknown"
}))
},
command: {
name: "/service/onkyo/command",
type: types.option({
tisch: "SLI11",
chromecast: "SLI01",
pult: "SLI10",
netzwerk: "SLI2B",
front: "SLI03",
unknown: "SLI00"
})
},
defaultValue: "unknown",
},
onkyo_radios: {
state: {
name: "/service/onkyo/status/latest-NPR",
type: types.option({
NPR01: "mpd",
NPR02: "kohina",
NPR03: "somafm_dronezone",
NPR04: "somafm_thetrip",
NPR05: "querfunk",
NPR06: "somafm_defconradio",
NPR07: "somafm_secretagent",
NPR08: "somafm_lush",
NPR09: "somafm_beatblender",
NPR0a: "ponyville",
otherwise: "unknown"
})
},
command: {
name: "/service/onkyo/command",
type: types.option({
mpd: "NPR01",
kohina: "NPR02",
somafm_dronezone: "NPR03",
somafm_thetrip: "NPR04",
querfunk: "NPR05",
somafm_defconradio: "NPR06",
somafm_secretagent: "NPR07",
somafm_lush: "NPR08",
somafm_beatblender: "NPR09",
ponyville: "NPR0a",
otherwise: "NPR00"
})
},
defaultValue: "unknown"
}
};
export const controls: Controls = {
onkyo: {
name: "Onkyo",
position: [350, 650],
iconColor: ({onkyo_connection, onkyo_power}) =>
onkyo_connection != "connected" ? hex("#888888") : (onkyo_power == "on" ? hex("#00FF00") : hex("#000000")),
icon: mdi("audio-video"),
ui: [
{
type: "toggle",
text: "Power",
icon: mdi("power"),
topic: "onkyo_power",
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "section",
text: "Lautstärkeregelung"
},
{
type: "slider",
text: "Volume",
topic: "onkyo_volume",
min: 0,
max: 50,
icon: mdi("volume-high"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "toggle",
text: "Mute",
topic: "onkyo_mute",
icon: mdi("volume-off"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "section",
text: "Eingänge"
},
{
type: "dropDown",
text: "Eingang",
topic: "onkyo_inputs",
options: {
netzwerk: "Netzwerk",
tisch: "Tisch",
chromecast: "Chromecast",
pult: "Pult",
front: "Front HDMI"
},
icon: mdi("usb"),
enableCondition: ({ onkyo_connection }) => onkyo_connection == "connected"
},
{
type: "dropDown",
text: "Netzwerksender",
topic: "onkyo_radios",
options: {
mpd: "MPD",
kohina: "Kohina",
somafm_dronezone: "Drone Zone (SomaFM)",
somafm_thetrip: "The Trip (SomaFM)",
querfunk: "Querfunk",
somafm_defconradio: "Defcon Radio (SomaFM)",
somafm_secretagent: "Secret Agent (SomaFM)",
somafm_lush: "Lush (SomaFM)",
somafm_beatblender: "Beat Blender (Soma FM)",
ponyville: "Ponyville FM"
},
icon: mdi("radio"),
enableCondition: (state) => state.onkyo_connection == "connected" && state.onkyo_inputs == "netzwerk"
},
{
type: "section",
text: "External"
},
{
type: "link",
link: "http://mpd.rzl/mpd/player/index.php",
text: "Open MPD Interface",
icon: mdi("open-in-new")
}
]
}
};