35 lines
1.1 KiB
Lua
35 lines
1.1 KiB
Lua
SERVICE_NAME = "AlexaTVConverter"
|
|
SERVICE_VERSION = "1.0.0"
|
|
|
|
TOPIC_SOURCE = "wohnzimmer/tv/alexainput/set";
|
|
|
|
TOPIC_TV_INPUT = "";
|
|
TOPIC_AVR_INPUT = "wohnzimmer/avr/input/set";
|
|
|
|
function thrawn_on_start()
|
|
thrawn_register_service(SERVICE_NAME)
|
|
|
|
thrawn_log("Starting LUA Service " .. SERVICE_NAME)
|
|
|
|
|
|
thrawn_subscribe(TOPIC_SOURCE)
|
|
end
|
|
|
|
function thrawn_on_update(state)
|
|
thrawn_log("RECV: " .. state.value .. " ON TOPIC " .. state.topic)
|
|
if state.topic == TOPIC_SOURCE then
|
|
if state.value == "PLAYSTATION" then
|
|
--thrawn_publish(TOPIC_TV_INPUT, "")
|
|
thrawn_publish(thrawn_create_topic_state(TOPIC_AVR_INPUT, "PS4"))
|
|
elseif state.value == "XBOX" then
|
|
--thrawn_publish(TOPIC_TV_INPUT, "")
|
|
thrawn_publish(thrawn_create_topic_state(TOPIC_AVR_INPUT, "XBoxOne"))
|
|
elseif state.value == "NINTENDO" then
|
|
--thrawn_publish(TOPIC_TV_INPUT, "")
|
|
thrawn_publish(thrawn_create_topic_state(TOPIC_AVR_INPUT, "Switch"))
|
|
elseif state.value == "APPLETV" then
|
|
--thrawn_publish(TOPIC_TV_INPUT, "")
|
|
thrawn_publish(thrawn_create_topic_state(TOPIC_AVR_INPUT, "AppleTV"))
|
|
end
|
|
end
|
|
end |