Hey OH-Community,
the last few days I stumpled upon a problem, I’ve gladly solved now… and want to share this solution here, in case someone find it useful…
I wanted to switch channels via voice over Alexa called by the channel name (not numbers), but also via my sitemap in OH (website and/or App)
so for unknown reasons, the Harmony Hub can only send one number as command… but i have 3 digit channel numbers…
This was a lot of try and error coding… so in case you have a better solution… please let me know… but for now i’m happy with the result…
The trick was to use Thread::sleep()
here is how i got it working…
My Hardware Setup:
- T-Home Media Receiver MR 303 Typ B+
- Logitech Harmony Hub
- Alexa Amazon Echo
.items file
// virtual items to allow Alexa to directly switch to a channel String THOME_PRG_SELECT "THome Alexa" Switch THOME_ARD "ARD" ["Switchable"] Switch THOME_ZDF "ZDF" ["Switchable"] String LR_THOME_DVR "T-Home Receiver" <receiver> {autoupdate="false", channel="harmonyhub:device:HoLLe:46182895:buttonPress"}
.rules file in my rules file i formated them to one line
// Rules to switch THome commands either via Alexa voice commands or select field in OH app rule "T-Home Alexa Voice commands" when Item THOME_PRG_SELECT changed to 401 or Item THOME_ARD received command ON then LR_THOME_DVR.sendCommand("4") Thread::sleep(2) LR_THOME_DVR.sendCommand("0") Thread::sleep(2) LR_THOME_DVR.sendCommand("1") Thread::sleep(2) LR_THOME_DVR.sendCommand("NumberEnter") end rule "T-Home Alexa Voice commands" when Item THOME_PRG_SELECT changed to 402 or Item THOME_ZDF received command ON then LR_THOME_DVR.sendCommand("4") Thread::sleep(2) LR_THOME_DVR.sendCommand("0") Thread::sleep(2) LR_THOME_DVR.sendCommand("2") Thread::sleep(2) LR_THOME_DVR.sendCommand("NumberEnter") end
.sitemap file
Frame label="TV" { Selection item=THOME_PRG_SELECT mappings=[ "401" = "ARD", "402" = "ZDF" ] }