Expose input sources to Alexa

HI i would like to use Alex to switch the input sources from HDMI2 to HDMI4 this how it looks my items file:

String   BraviaInput               "Input"  [ "Switchable" ]               {channel="sony:simpleip:xcxcxcxc:input"}

this is my sitemap file:

Switch item=BraviaInput label="Input"icon="receiver" mappings=[HDMI2="HDMI2" , HDMI4="HDMI4"]
and on basicui/app i can switch with no problem from input sources.

image

what do i have to do or add on my items file “which is a string type” so that Alexa can send command through openhab ??

Thanks for your help

My approach for voice control is generally a different approach than for example a site map, and I would suggest the same in this case.
I would create an item labeled HDMI2 and an item labeled HDMI4, expose those to Alexa and with rules make it such that whenever those items receive an ON command, the right value is sent to the BeaviaInput item.

1 Like

@yortiz1979
Whatever you do - Remember to use code fences when posting codes in a thread.
It makes it alot easier to read and easy to copy for others to use.

Ok I’m sharing here my solution so im sure it will be of a lot of help for some other user and will save them some gray hair :slight_smile:
this is an example of my items file:

String   BraviaInput               "Input"  [ "Switchable" ]               {channel="sony:simpleip:5554545bbf:input"}
Dimmer   BraviaInputAlexa          "Input"  [ "Switchable" ]

the first one is the real item which is the string and the second is a dummy item which i create as a dimmer and tagged as Switchable so that can appear in Alexa. since its a dimmer you can creat rule now on any value from 0=ON 1-99 100=OFF and then created a rules as follow:

// Input for "Alexa HDMI"

rule "BraviaInputAlexa"
        when
                Item BraviaInputAlexa received command
        then
            switch (receivedCommand)
                {
                        case 1:        BraviaInput.sendCommand("HDMI2")
                        case 4:       BraviaInput.sendCommand("HDMI4")
                }
end

and it works fine :):star_struck:

Hi Kim, thanks, but really no idea what code fence is. i will google it :wink:

Using the reply box in the forum, its easy… Look at this screendump… Notice the red square I have inserted, (unfortunatly there is no icons, but place your mouse on it and you´ll see).

1 Like

@yortiz1979

1 Like

thank you guys, i have learned a lot on this forum lately :slight_smile:

1 Like

done! :wink:

2 Likes