commit a9021604a21fd4ad35332a1cf3ddfa5a8c31704a Author: Dr. Julian-Steffen Müller Date: Wed Jul 15 10:49:52 2020 +0200 First Version of AlexaTVConverter which controls AVR and TV to switch inputs diff --git a/AlexaTVConverter.lua b/AlexaTVConverter.lua new file mode 100644 index 0000000..28fe8ef --- /dev/null +++ b/AlexaTVConverter.lua @@ -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 \ No newline at end of file