First Version of AlexaTVConverter which controls AVR and TV to switch inputs

This commit is contained in:
2020-07-15 10:49:52 +02:00
commit a9021604a2

33
AlexaTVConverter.lua Normal file
View File

@@ -0,0 +1,33 @@
SERVICE_NAME = "AlexaTVConverter"
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